| 659 | } |
| 660 | |
| 661 | VectorPtr restoreVector(std::istream& in, memory::MemoryPool* pool) { |
| 662 | BOLT_CHECK_NOT_NULL(pool); |
| 663 | // Encoding. |
| 664 | auto encoding = readEncoding(in); |
| 665 | |
| 666 | // Type kind. |
| 667 | auto type = restoreType(in); |
| 668 | |
| 669 | // Vector size. |
| 670 | auto size = read<int32_t>(in); |
| 671 | |
| 672 | switch (encoding) { |
| 673 | case Encoding::kFlat: |
| 674 | if (type->isRow()) { |
| 675 | return readRowVector(type, size, in, pool); |
| 676 | } else if (type->isArray()) { |
| 677 | return readArrayVector(type, size, in, pool); |
| 678 | } else if (type->isMap()) { |
| 679 | return readMapVector(type, size, in, pool); |
| 680 | } |
| 681 | return readFlatVector(type, size, in, pool); |
| 682 | case Encoding::kConstant: |
| 683 | return readConstantVector(type, size, in, pool); |
| 684 | case Encoding::kDictionary: |
| 685 | return readDictionaryVector(type, size, in, pool); |
| 686 | case Encoding::kLazy: |
| 687 | return readLazyVector(type, size, in, pool); |
| 688 | default: |
| 689 | BOLT_UNREACHABLE(); |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | VectorPtr restoreVectorFromFile( |
| 694 | const char* FOLLY_NONNULL filePath, |