| 577 | } |
| 578 | |
| 579 | Result<std::shared_ptr<Table>> MakeRandomTimeSeriesTable( |
| 580 | const TableGenerationProperties& properties) { |
| 581 | int total_columns = properties.num_columns + 2; |
| 582 | std::vector<std::shared_ptr<Array>> columns; |
| 583 | columns.reserve(total_columns); |
| 584 | arrow::FieldVector field_vector; |
| 585 | field_vector.reserve(total_columns); |
| 586 | |
| 587 | field_vector.push_back(field("time", int64())); |
| 588 | field_vector.push_back(field("id", int32())); |
| 589 | Int64Builder time_column_builder; |
| 590 | Int32Builder id_column_builder; |
| 591 | for (int64_t time = properties.start; time <= properties.end; |
| 592 | time += properties.time_frequency) { |
| 593 | for (int32_t id = 0; id < properties.num_ids; id++) { |
| 594 | ARROW_RETURN_NOT_OK(time_column_builder.Append(time)); |
| 595 | ARROW_RETURN_NOT_OK(id_column_builder.Append(id)); |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | int64_t num_rows = time_column_builder.length(); |
| 600 | ARROW_ASSIGN_OR_RAISE(auto time_column, time_column_builder.Finish()); |
| 601 | ARROW_ASSIGN_OR_RAISE(auto id_column, id_column_builder.Finish()); |
| 602 | columns.push_back(std::move(time_column)); |
| 603 | columns.push_back(std::move(id_column)); |
| 604 | |
| 605 | for (int i = 0; i < properties.num_columns; i++) { |
| 606 | field_vector.push_back( |
| 607 | field(properties.column_prefix + std::to_string(i), float64())); |
| 608 | random::RandomArrayGenerator rand(properties.seed + i); |
| 609 | columns.push_back( |
| 610 | rand.Float64(num_rows, properties.min_column_value, properties.max_column_value)); |
| 611 | } |
| 612 | std::shared_ptr<arrow::Schema> schema = arrow::schema(std::move(field_vector)); |
| 613 | return Table::Make(schema, columns, num_rows); |
| 614 | } |
| 615 | |
| 616 | Result<std::shared_ptr<Table>> RunEndEncodeTableColumns( |
| 617 | const Table& table, const std::vector<int>& column_indices) { |