Skip to content

Commit

Permalink
[oap ] Replace arrow::field() to make_shared to create arrow::Field i…
Browse files Browse the repository at this point in the history
…n ArrowSchema
  • Loading branch information
rui-mo authored and glutenperfbot committed Oct 16, 2024
1 parent aff25b2 commit 2e726a3
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions velox/dwio/parquet/writer/arrow/ArrowSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,16 +529,24 @@ Status FieldToNode(
// the encoding, not the schema level.
const ::arrow::DictionaryType& dict_type =
static_cast<const ::arrow::DictionaryType&>(*field->type());
std::shared_ptr<::arrow::Field> unpacked_field = ::arrow::field(
name, dict_type.value_type(), field->nullable(), field->metadata());
std::shared_ptr<::arrow::Field> unpacked_field =
::std::make_shared<::arrow::Field>(
name,
dict_type.value_type(),
field->nullable(),
field->metadata());
return FieldToNode(
name, unpacked_field, properties, arrow_properties, out);
}
case ArrowTypeId::EXTENSION: {
auto ext_type =
std::static_pointer_cast<::arrow::ExtensionType>(field->type());
std::shared_ptr<::arrow::Field> storage_field = ::arrow::field(
name, ext_type->storage_type(), field->nullable(), field->metadata());
std::shared_ptr<::arrow::Field> storage_field =
::std::make_shared<::arrow::Field>(
name,
ext_type->storage_type(),
field->nullable(),
field->metadata());
return FieldToNode(
name, storage_field, properties, arrow_properties, out);
}
Expand Down Expand Up @@ -660,7 +668,7 @@ Status GroupToStruct(
arrow_fields.push_back(out->children[i].field);
}
auto struct_type = ::arrow::struct_(arrow_fields);
out->field = ::arrow::field(
out->field = ::std::make_shared<::arrow::Field>(
node.name(),
struct_type,
node.is_optional(),
Expand Down Expand Up @@ -745,14 +753,14 @@ Status MapToSchemaField(
RETURN_NOT_OK(NodeToSchemaField(
*key_value.field(1), current_levels, ctx, key_value_field, value_field));

key_value_field->field = ::arrow::field(
key_value_field->field = ::std::make_shared<::arrow::Field>(
group.name(),
::arrow::struct_({key_field->field, value_field->field}),
/*nullable=*/false,
FieldIdMetadata(key_value.field_id()));
key_value_field->level_info = current_levels;

out->field = ::arrow::field(
out->field = ::std::make_shared<::arrow::Field>(
group.name(),
std::make_shared<::arrow::MapType>(key_value_field->field),
group.is_optional(),
Expand Down Expand Up @@ -838,15 +846,15 @@ Status ListToSchemaField(
ARROW_ASSIGN_OR_RAISE(
std::shared_ptr<ArrowType> type,
GetTypeForNode(column_index, primitive_node, ctx));
auto item_field = ::arrow::field(
auto item_field = ::std::make_shared<::arrow::Field>(
list_node.name(),
type,
/*nullable=*/false,
FieldIdMetadata(list_node.field_id()));
RETURN_NOT_OK(PopulateLeaf(
column_index, item_field, current_levels, ctx, out, child_field));
}
out->field = ::arrow::field(
out->field = ::std::make_shared<::arrow::Field>(
group.name(),
::arrow::list(child_field->field),
group.is_optional(),
Expand Down Expand Up @@ -882,7 +890,7 @@ Status GroupToSchemaField(
int16_t repeated_ancestor_def_level = current_levels.IncrementRepeated();
RETURN_NOT_OK(
GroupToStruct(node, current_levels, ctx, out, &out->children[0]));
out->field = ::arrow::field(
out->field = ::std::make_shared<::arrow::Field>(
node.name(),
::arrow::list(out->children[0].field),
/*nullable=*/false,
Expand Down Expand Up @@ -936,7 +944,8 @@ Status NodeToSchemaField(
// a: repeated int32;
int16_t repeated_ancestor_def_level = current_levels.IncrementRepeated();
out->children.resize(1);
auto child_field = ::arrow::field(node.name(), type, /*nullable=*/false);
auto child_field = ::std::make_shared<::arrow::Field>(
node.name(), type, /*nullable=*/false);
RETURN_NOT_OK(PopulateLeaf(
column_index,
child_field,
Expand All @@ -945,7 +954,7 @@ Status NodeToSchemaField(
out,
&out->children[0]));

out->field = ::arrow::field(
out->field = ::std::make_shared<::arrow::Field>(
node.name(),
::arrow::list(child_field),
/*nullable=*/false,
Expand All @@ -960,7 +969,7 @@ Status NodeToSchemaField(
// A normal (required/optional) primitive node
return PopulateLeaf(
column_index,
::arrow::field(
::std::make_shared<::arrow::Field>(
node.name(),
type,
node.is_optional(),
Expand Down

0 comments on commit 2e726a3

Please sign in to comment.