| 306 | } |
| 307 | |
| 308 | std::string printTypeAndEncodingTree( |
| 309 | const BaseVector& vector, |
| 310 | const std::string& indent) { |
| 311 | std::ostringstream out; |
| 312 | |
| 313 | const auto newIndent = addIndent(indent); |
| 314 | switch (vector.encoding()) { |
| 315 | case VectorEncoding::Simple::CONSTANT: |
| 316 | case VectorEncoding::Simple::DICTIONARY: { |
| 317 | out << indent << VectorEncoding::mapSimpleToName(vector.encoding()) |
| 318 | << " "; |
| 319 | printSizeAndNullCount(vector, out); |
| 320 | out << std::endl; |
| 321 | // Constant vector of primitive type doesn't have valueVector. |
| 322 | if (vector.valueVector()) { |
| 323 | out << printTypeAndEncodingTree(*vector.valueVector(), newIndent); |
| 324 | } else { |
| 325 | out << newIndent << vector.type()->toString() << std::endl; |
| 326 | } |
| 327 | break; |
| 328 | } |
| 329 | case VectorEncoding::Simple::FLAT: |
| 330 | printEncodingAndType(vector, indent, out); |
| 331 | break; |
| 332 | case VectorEncoding::Simple::ARRAY: { |
| 333 | auto* arrayVector = vector.as<ArrayVector>(); |
| 334 | printEncodingAndType(vector, indent, out); |
| 335 | out << indent << "Elements: " << std::endl; |
| 336 | out << printTypeAndEncodingTree(*arrayVector->elements(), newIndent); |
| 337 | break; |
| 338 | } |
| 339 | case VectorEncoding::Simple::MAP: { |
| 340 | auto* mapVector = vector.as<MapVector>(); |
| 341 | printEncodingAndType(vector, indent, out); |
| 342 | out << indent << "Keys: " << std::endl; |
| 343 | out << printTypeAndEncodingTree(*mapVector->mapKeys(), newIndent); |
| 344 | out << indent << "Values: " << std::endl; |
| 345 | out << printTypeAndEncodingTree(*mapVector->mapValues(), newIndent); |
| 346 | break; |
| 347 | } |
| 348 | case VectorEncoding::Simple::ROW: { |
| 349 | printEncodingAndType(vector, indent, out); |
| 350 | const auto* rowVector = vector.as<RowVector>(); |
| 351 | const auto& rowType = vector.type()->asRow(); |
| 352 | for (auto i = 0; i < rowType.size(); ++i) { |
| 353 | out << indent << "Field " << rowType.nameOf(i) << ":" << std::endl; |
| 354 | out << printTypeAndEncodingTree(*rowVector->childAt(i), newIndent); |
| 355 | } |
| 356 | break; |
| 357 | } |
| 358 | default: |
| 359 | BOLT_UNSUPPORTED( |
| 360 | "Unsupported encoding: {}", |
| 361 | VectorEncoding::mapSimpleToName(vector.encoding())); |
| 362 | } |
| 363 | |
| 364 | return out.str(); |
| 365 | } |
no test coverage detected