@@ -60,39 +60,33 @@ Result<std::unique_ptr<MapSharedShreddingColumnAllocator>> CreateMapSharedShredd
6060
6161} // namespace
6262
63- MapSharedShreddingBatchConverter::ColumnContext::ColumnContext (
64- const std::string& field_name, int32_t num_columns,
65- std::unique_ptr<MapSharedShreddingColumnAllocator>&& allocator)
66- : field_name(field_name), num_columns(num_columns), allocator(std::move(allocator)) {}
67-
6863Result<std::shared_ptr<MapSharedShreddingBatchConverter>> MapSharedShreddingBatchConverter::Create (
6964 const std::shared_ptr<arrow::Schema>& logical_schema,
7065 const std::shared_ptr<MapSharedShreddingContext>& context, const CoreOptions& options,
7166 const std::shared_ptr<MemoryPool>& pool) {
72- std::map<std::string, int32_t > field_to_k = context->ComputeNextK ();
67+ std::map<std::string, int32_t > field_to_num_columns = context->ComputeNextK ();
7368 std::shared_ptr<arrow::Schema> physical_schema =
74- MapSharedShreddingUtils::LogicalToPhysicalSchema (logical_schema, field_to_k );
69+ MapSharedShreddingUtils::LogicalToPhysicalSchema (logical_schema, field_to_num_columns );
7570 std::vector<ColumnContext> contexts;
7671 std::vector<std::string> shredding_field_names;
77- contexts.reserve (field_to_k .size ());
78- shredding_field_names.reserve (field_to_k .size ());
72+ contexts.reserve (field_to_num_columns .size ());
73+ shredding_field_names.reserve (field_to_num_columns .size ());
7974 // Iterate in schema field order (not map order) so that shredding_field_names_
8075 // matches the order in which shredding columns appear in the schema.
8176 // This is critical for the sequential matching logic in Convert().
8277 for (int32_t i = 0 ; i < logical_schema->num_fields (); ++i) {
8378 const std::string& name = logical_schema->field (i)->name ();
84- auto k_it = field_to_k.find (name);
85- if (k_it == field_to_k.end ()) {
86- continue ;
79+ auto it = field_to_num_columns.find (name);
80+ if (it != field_to_num_columns.end ()) {
81+ int32_t num_columns = it->second ;
82+ PAIMON_ASSIGN_OR_RAISE (MapSharedShreddingColumnPlacementPolicy placement_policy,
83+ options.GetMapSharedShreddingColumnPlacementPolicy (name));
84+ PAIMON_ASSIGN_OR_RAISE (
85+ std::unique_ptr<MapSharedShreddingColumnAllocator> allocator,
86+ CreateMapSharedShreddingColumnAllocator (num_columns, placement_policy));
87+ contexts.emplace_back (name, num_columns, std::move (allocator));
88+ shredding_field_names.push_back (name);
8789 }
88- int32_t num_columns = k_it->second ;
89- PAIMON_ASSIGN_OR_RAISE (MapSharedShreddingColumnPlacementPolicy placement_policy,
90- options.GetMapSharedShreddingColumnPlacementPolicy (name));
91- PAIMON_ASSIGN_OR_RAISE (
92- std::unique_ptr<MapSharedShreddingColumnAllocator> allocator,
93- CreateMapSharedShreddingColumnAllocator (num_columns, placement_policy));
94- contexts.emplace_back (name, num_columns, std::move (allocator));
95- shredding_field_names.push_back (name);
9690 }
9791 return std::shared_ptr<MapSharedShreddingBatchConverter>(
9892 new MapSharedShreddingBatchConverter (logical_schema, physical_schema, std::move (contexts),
0 commit comments