MCPcopy Create free account
hub / github.com/apache/arrow / MakeSimpleSchema

Function MakeSimpleSchema

cpp/src/parquet/arrow/arrow_reader_writer_test.cc:556–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

554}
555
556static std::shared_ptr<GroupNode> MakeSimpleSchema(const DataType& type,
557 Repetition::type repetition) {
558 int32_t byte_width = -1;
559
560 switch (type.id()) {
561 case ::arrow::Type::DICTIONARY: {
562 const auto& dict_type = static_cast<const ::arrow::DictionaryType&>(type);
563 const DataType& values_type = *dict_type.value_type();
564 switch (values_type.id()) {
565 case ::arrow::Type::FIXED_SIZE_BINARY:
566 byte_width =
567 static_cast<const ::arrow::FixedSizeBinaryType&>(values_type).byte_width();
568 break;
569 case ::arrow::Type::HALF_FLOAT:
570 byte_width = sizeof(::arrow::HalfFloatType::c_type);
571 break;
572 case ::arrow::Type::DECIMAL128:
573 case ::arrow::Type::DECIMAL256: {
574 const auto& decimal_type = static_cast<const DecimalType&>(values_type);
575 byte_width = DecimalType::DecimalSize(decimal_type.precision());
576 } break;
577 default:
578 break;
579 }
580 } break;
581 case ::arrow::Type::FIXED_SIZE_BINARY:
582 byte_width = static_cast<const ::arrow::FixedSizeBinaryType&>(type).byte_width();
583 break;
584 case ::arrow::Type::HALF_FLOAT:
585 byte_width = sizeof(::arrow::HalfFloatType::c_type);
586 break;
587 case ::arrow::Type::DECIMAL128:
588 case ::arrow::Type::DECIMAL256: {
589 const auto& decimal_type = static_cast<const DecimalType&>(type);
590 byte_width = DecimalType::DecimalSize(decimal_type.precision());
591 } break;
592 default:
593 break;
594 }
595 auto pnode = PrimitiveNode::Make("column1", repetition, get_logical_type(type),
596 get_physical_type(type), byte_width);
597 NodePtr node_ =
598 GroupNode::Make("schema", Repetition::REQUIRED, std::vector<NodePtr>({pnode}));
599 return std::static_pointer_cast<GroupNode>(node_);
600}
601
602void ReadSingleColumnFileStatistics(std::unique_ptr<FileReader> file_reader,
603 std::shared_ptr<Scalar>* min,

Callers 3

TYPED_TESTFunction · 0.85
MakeTestFileMethod · 0.85
WriteBufferedFileMethod · 0.85

Calls 7

get_physical_typeFunction · 0.85
get_logical_typeFunction · 0.70
MakeFunction · 0.50
idMethod · 0.45
value_typeMethod · 0.45
byte_widthMethod · 0.45
precisionMethod · 0.45

Tested by

no test coverage detected