This constructor takes an optional encoding and vector. In cases where the vector (data) is not available when the stream is created, callers can also manually specify the encoding, which only applies to the top level stream. If both are specified, `encoding` takes precedence over the actual encoding of `vector`. Only 'flat' encoding can take precedence over the input data encoding.
| 1232 | // encoding of `vector`. Only 'flat' encoding can take precedence over the |
| 1233 | // input data encoding. |
| 1234 | VectorStream( |
| 1235 | const TypePtr& type, |
| 1236 | std::optional<VectorEncoding::Simple> encoding, |
| 1237 | std::optional<VectorPtr> vector, |
| 1238 | StreamArena* streamArena, |
| 1239 | int32_t initialNumRows, |
| 1240 | bool useLosslessTimestamp) |
| 1241 | : type_(type), |
| 1242 | streamArena_(streamArena), |
| 1243 | encoding_(getEncoding(encoding, vector)), |
| 1244 | useLosslessTimestamp_(useLosslessTimestamp), |
| 1245 | nulls_(streamArena, true, true), |
| 1246 | lengths_(streamArena), |
| 1247 | values_(streamArena), |
| 1248 | isLongDecimal_(type_->isLongDecimal()) { |
| 1249 | if (initialNumRows == 0) { |
| 1250 | initializeHeader(typeToEncodingName(type), *streamArena); |
| 1251 | return; |
| 1252 | } |
| 1253 | |
| 1254 | if (encoding_.has_value()) { |
| 1255 | switch (encoding_.value()) { |
| 1256 | case VectorEncoding::Simple::CONSTANT: { |
| 1257 | initializeHeader(kRLE, *streamArena); |
| 1258 | isConstantStream_ = true; |
| 1259 | children_.emplace_back(std::make_unique<VectorStream>( |
| 1260 | type_, |
| 1261 | std::nullopt, |
| 1262 | std::nullopt, |
| 1263 | streamArena, |
| 1264 | initialNumRows, |
| 1265 | useLosslessTimestamp)); |
| 1266 | return; |
| 1267 | } |
| 1268 | case VectorEncoding::Simple::DICTIONARY: { |
| 1269 | initializeHeader(kDictionary, *streamArena); |
| 1270 | values_.startWrite(initialNumRows * 4); |
| 1271 | isDictionaryStream_ = true; |
| 1272 | children_.emplace_back(std::make_unique<VectorStream>( |
| 1273 | type_, |
| 1274 | std::nullopt, |
| 1275 | std::nullopt, |
| 1276 | streamArena, |
| 1277 | initialNumRows, |
| 1278 | useLosslessTimestamp)); |
| 1279 | return; |
| 1280 | } |
| 1281 | default: |
| 1282 | break; |
| 1283 | } |
| 1284 | } |
| 1285 | |
| 1286 | initializeHeader(typeToEncodingName(type), *streamArena); |
| 1287 | nulls_.startWrite(1 + (initialNumRows / 8)); |
| 1288 | |
| 1289 | switch (type_->kind()) { |
| 1290 | case TypeKind::ROW: |
| 1291 | case TypeKind::VARIANT: |
nothing calls this directly
no test coverage detected