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

Function GetNestedFactory

cpp/src/parquet/arrow/schema.cc:999–1042  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

997}
998
999std::function<std::shared_ptr<::arrow::DataType>(FieldVector)> GetNestedFactory(
1000 const ArrowType& origin_type, const ArrowType& inferred_type) {
1001 switch (inferred_type.id()) {
1002 case ::arrow::Type::STRUCT:
1003 if (origin_type.id() == ::arrow::Type::STRUCT) {
1004 return [](FieldVector fields) { return ::arrow::struct_(std::move(fields)); };
1005 }
1006 break;
1007 case ::arrow::Type::LIST:
1008 case ::arrow::Type::LARGE_LIST: {
1009 switch (origin_type.id()) {
1010 case ::arrow::Type::LIST:
1011 return GetListFactory<::arrow::ListType>();
1012 case ::arrow::Type::LARGE_LIST:
1013 return GetListFactory<::arrow::LargeListType>();
1014 case ::arrow::Type::LIST_VIEW:
1015 return GetListFactory<::arrow::ListViewType>();
1016 case ::arrow::Type::LARGE_LIST_VIEW:
1017 return GetListFactory<::arrow::LargeListViewType>();
1018 case ::arrow::Type::FIXED_SIZE_LIST: {
1019 const auto list_size =
1020 checked_cast<const ::arrow::FixedSizeListType&>(origin_type).list_size();
1021 return GetListFactory<::arrow::FixedSizeListType>(list_size);
1022 }
1023 default:
1024 break;
1025 }
1026 break;
1027 }
1028 case ::arrow::Type::MAP:
1029 if (origin_type.id() == ::arrow::Type::MAP) {
1030 const bool keys_sorted =
1031 checked_cast<const ::arrow::MapType&>(origin_type).keys_sorted();
1032 return [keys_sorted](FieldVector fields) {
1033 DCHECK_EQ(fields.size(), 1);
1034 return std::make_shared<::arrow::MapType>(std::move(fields[0]), keys_sorted);
1035 };
1036 }
1037 break;
1038 default:
1039 break;
1040 }
1041 return {};
1042}
1043
1044Result<bool> ApplyOriginalStorageMetadata(const Field& origin_field,
1045 SchemaField* inferred) {

Callers 1

Calls 4

struct_Function · 0.85
idMethod · 0.45
list_sizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected