MCPcopy Create free account
hub / github.com/bytedance/bolt / printTypeAndEncodingTree

Function printTypeAndEncodingTree

bolt/vector/VectorPrinter.cpp:308–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308std::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}

Callers 1

printVectorFunction · 0.85

Calls 13

addIndentFunction · 0.85
mapSimpleToNameFunction · 0.85
printSizeAndNullCountFunction · 0.85
printEncodingAndTypeFunction · 0.85
childAtMethod · 0.80
strMethod · 0.80
encodingMethod · 0.45
toStringMethod · 0.45
typeMethod · 0.45
mapKeysMethod · 0.45
mapValuesMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected