amol- commented on a change in pull request #11197:
URL: https://github.com/apache/arrow/pull/11197#discussion_r713041858
##########
File path: cpp/examples/arrow/row_wise_conversion_example.cc
##########
@@ -61,51 +65,52 @@ arrow::Status VectorToColumnarTable(const
std::vector<struct data_row>& rows,
arrow::MemoryPool* pool = arrow::default_memory_pool();
Int64Builder id_builder(pool);
- DoubleBuilder cost_builder(pool);
- ListBuilder components_builder(pool, std::make_shared<DoubleBuilder>(pool));
- // The following builder is owned by components_builder.
- DoubleBuilder& cost_components_builder =
- *(static_cast<DoubleBuilder*>(components_builder.value_builder()));
+ Int64Builder components_builder(pool);
+ ListBuilder component_cost_builder(pool,
std::make_shared<DoubleBuilder>(pool));
+ // The following builder is owned by component_cost_builder.
+ DoubleBuilder& component_item_cost_builder =
+ *(static_cast<DoubleBuilder*>(component_cost_builder.value_builder()));
// Now we can loop over our existing data and insert it into the builders.
The
// `Append` calls here may fail (e.g. we cannot allocate enough additional
memory).
// Thus we need to check their return values. For more information on these
values,
// check the documentation about `arrow::Status`.
for (const data_row& row : rows) {
ARROW_RETURN_NOT_OK(id_builder.Append(row.id));
- ARROW_RETURN_NOT_OK(cost_builder.Append(row.cost));
+ ARROW_RETURN_NOT_OK(components_builder.Append(row.components));
// Indicate the start of a new list row. This will memorise the current
// offset in the values builder.
- ARROW_RETURN_NOT_OK(components_builder.Append());
+ ARROW_RETURN_NOT_OK(component_cost_builder.Append());
// Store the actual values. The final nullptr argument tells the underlying
// builder that all added values are valid, i.e. non-null.
-
ARROW_RETURN_NOT_OK(cost_components_builder.AppendValues(row.cost_components.data(),
-
row.cost_components.size()));
+
ARROW_RETURN_NOT_OK(component_item_cost_builder.AppendValues(row.component_cost.data(),
+
row.component_cost.size()));
Review comment:
Maybe add a comment about the fact that we expect the same memory layout
for `std::vector<double>::data` and what
`component_item_cost_builder.AppendValues` expects.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]