iChauster commented on code in PR #13426:
URL: https://github.com/apache/arrow/pull/13426#discussion_r923504556
##########
cpp/src/arrow/compute/exec/test_util.cc:
##########
@@ -460,42 +460,39 @@ void PrintTo(const Declaration& decl, std::ostream* os) {
*os << "}";
}
-std::shared_ptr<Table> MakeRandomTable(TableGenerationProperties properties) {
+std::shared_ptr<Table> MakeRandomTimeSeriesTable(
+ const TableGenerationProperties& properties) {
int total_columns = properties.num_columns + 2;
std::vector<std::shared_ptr<Array>> columns;
columns.reserve(total_columns);
- arrow::FieldVector field_vector = arrow::FieldVector();
+ arrow::FieldVector field_vector;
field_vector.reserve(total_columns);
- field_vector.push_back(std::make_shared<Field>("time", int64()));
- field_vector.push_back(std::make_shared<Field>("id", int32()));
+ field_vector.push_back(field("time", int64()));
+ field_vector.push_back(field("id", int32()));
- int num_rows = 0;
- std::vector<int64_t> time_column;
- std::vector<int32_t> id_column;
+ Int64Builder time_column_builder;
+ Int32Builder id_column_builder;
for (int time = properties.start; time <= properties.end;
- time += properties.time_frequency) {
+ time += properties.time_frequency) {
for (int id = 0; id < properties.num_ids; id++) {
- time_column.push_back(time);
- id_column.push_back(id);
- num_rows += 1;
+ time_column_builder.Append(time);
+ id_column_builder.Append(id);
}
}
- std::shared_ptr<Array> time_array;
- ArrayFromVector<Int64Type, int64_t>(int64(), time_column, &time_array);
- columns.push_back(time_array);
- std::shared_ptr<Array> id_array;
- ArrayFromVector<Int32Type, int32_t>(int32(), id_column, &id_array);
- columns.push_back(id_array);
+
+ int num_rows = time_column_builder.length();
+ columns.push_back(time_column_builder.Finish().ValueOrDie());
+ columns.push_back(id_column_builder.Finish().ValueOrDie());
Review Comment:
Is using `ValueOrDie()` here okay? I tried using `CHECK_OK_AND_ASSIGN` but I
don't think that works in a non-void function.
--
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]