(Doc section: Helper Functions) Generate some data for the rest of this example.
| 33 | // (Doc section: Helper Functions) |
| 34 | // Generate some data for the rest of this example. |
| 35 | arrow::Result<std::shared_ptr<arrow::Table>> CreateTable() { |
| 36 | // This code should look familiar from the basic Arrow example, and is not the |
| 37 | // focus of this example. However, we need data to work on it, and this makes that! |
| 38 | auto schema = |
| 39 | arrow::schema({arrow::field("a", arrow::int64()), arrow::field("b", arrow::int64()), |
| 40 | arrow::field("c", arrow::int64())}); |
| 41 | std::shared_ptr<arrow::Array> array_a; |
| 42 | std::shared_ptr<arrow::Array> array_b; |
| 43 | std::shared_ptr<arrow::Array> array_c; |
| 44 | arrow::NumericBuilder<arrow::Int64Type> builder; |
| 45 | ARROW_RETURN_NOT_OK(builder.AppendValues({0, 1, 2, 3, 4, 5, 6, 7, 8, 9})); |
| 46 | ARROW_RETURN_NOT_OK(builder.Finish(&array_a)); |
| 47 | builder.Reset(); |
| 48 | ARROW_RETURN_NOT_OK(builder.AppendValues({9, 8, 7, 6, 5, 4, 3, 2, 1, 0})); |
| 49 | ARROW_RETURN_NOT_OK(builder.Finish(&array_b)); |
| 50 | builder.Reset(); |
| 51 | ARROW_RETURN_NOT_OK(builder.AppendValues({1, 2, 1, 2, 1, 2, 1, 2, 1, 2})); |
| 52 | ARROW_RETURN_NOT_OK(builder.Finish(&array_c)); |
| 53 | return arrow::Table::Make(schema, {array_a, array_b, array_c}); |
| 54 | } |
| 55 | |
| 56 | // Set up a dataset by writing two Parquet files. |
| 57 | arrow::Result<std::string> CreateExampleParquetDataset( |