MCPcopy Create free account
hub / github.com/apache/arrow / CreateTable

Function CreateTable

cpp/examples/tutorial_examples/dataset_example.cc:35–54  ·  view source on GitHub ↗

(Doc section: Helper Functions) Generate some data for the rest of this example.

Source from the content-addressed store, hash-verified

33// (Doc section: Helper Functions)
34// Generate some data for the rest of this example.
35arrow::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.
57arrow::Result<std::string> CreateExampleParquetDataset(

Callers

nothing calls this directly

Calls 6

schemaFunction · 0.50
fieldFunction · 0.50
MakeFunction · 0.50
AppendValuesMethod · 0.45
FinishMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected