| 1022 | } |
| 1023 | |
| 1024 | void readRowVector( |
| 1025 | ByteInputStream* source, |
| 1026 | const TypePtr& type, |
| 1027 | bolt::memory::MemoryPool* pool, |
| 1028 | VectorPtr& result, |
| 1029 | vector_size_t resultOffset, |
| 1030 | bool useLosslessTimestamp) { |
| 1031 | if (isTimestampWithTimeZoneType(type)) { |
| 1032 | auto* row = result->as<RowVector>(); |
| 1033 | readTimestampWithTimeZone(source, pool, row, resultOffset); |
| 1034 | return; |
| 1035 | } |
| 1036 | |
| 1037 | const int32_t numChildren = source->read<int32_t>(); |
| 1038 | |
| 1039 | std::vector<VectorPtr>* children; |
| 1040 | auto encoding = result->encoding(); |
| 1041 | BOLT_CHECK( |
| 1042 | encoding == VectorEncoding::Simple::ROW || |
| 1043 | encoding == VectorEncoding::Simple::VARIANT, |
| 1044 | "readRowVector: unexpected encoding {}, expected ROW or VARIANT", |
| 1045 | encoding); |
| 1046 | if (encoding == VectorEncoding::Simple::ROW) { |
| 1047 | children = &result->asUnchecked<RowVector>()->children(); |
| 1048 | } else { |
| 1049 | children = &result->asUnchecked<VariantVector>()->children(); |
| 1050 | } |
| 1051 | |
| 1052 | // The on-wire encoding for both ROW and VARIANT is a ROW-like structure. |
| 1053 | // Don't assume the logical type is a RowType (VARIANT is not). |
| 1054 | BOLT_USER_CHECK_EQ( |
| 1055 | numChildren, |
| 1056 | static_cast<int32_t>(type->size()), |
| 1057 | "Mismatched number of children in serialized struct. Expected {} for type {}, got {}", |
| 1058 | type->size(), |
| 1059 | type->toString(), |
| 1060 | numChildren); |
| 1061 | |
| 1062 | std::vector<TypePtr> childTypes; |
| 1063 | childTypes.reserve(type->size()); |
| 1064 | for (uint32_t i = 0; i < type->size(); ++i) { |
| 1065 | childTypes.push_back(type->childAt(i)); |
| 1066 | } |
| 1067 | readColumns( |
| 1068 | source, pool, childTypes, *children, resultOffset, useLosslessTimestamp); |
| 1069 | |
| 1070 | auto size = source->read<int32_t>(); |
| 1071 | // Set the size of the row but do not alter the size of the |
| 1072 | // children. The children get adjusted in a separate pass over the |
| 1073 | // data. The parent and child size MUST be separate until the second pass. |
| 1074 | if (result->encoding() == VectorEncoding::Simple::ROW) { |
| 1075 | result->asUnchecked<RowVector>()->BaseVector::resize(resultOffset + size); |
| 1076 | } else { |
| 1077 | result->asUnchecked<VariantVector>()->BaseVector::resize( |
| 1078 | resultOffset + size); |
| 1079 | } |
| 1080 | |
| 1081 | for (int32_t i = 0; i <= size; ++i) { |
nothing calls this directly
no test coverage detected