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

Function GetTable

cpp/examples/arrow/execution_plan_documentation_examples.cc:111–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109/// \return The created table
110
111arrow::Result<std::shared_ptr<arrow::Table>> GetTable() {
112 auto null_long = std::numeric_limits<int64_t>::quiet_NaN();
113 ARROW_ASSIGN_OR_RAISE(auto int64_array,
114 GetArrayDataSample<arrow::Int64Type>(
115 {1, 2, null_long, 3, null_long, 4, 5, 6, 7, 8}));
116
117 arrow::BooleanBuilder boolean_builder;
118 std::shared_ptr<arrow::BooleanArray> bool_array;
119
120 std::vector<uint8_t> bool_values = {false, true, true, false, true,
121 false, false, false, false, true};
122 std::vector<bool> is_valid = {false, true, true, true, true,
123 true, false, true, true, true};
124
125 ARROW_RETURN_NOT_OK(boolean_builder.Reserve(10));
126
127 ARROW_RETURN_NOT_OK(boolean_builder.AppendValues(bool_values, is_valid));
128
129 ARROW_RETURN_NOT_OK(boolean_builder.Finish(&bool_array));
130
131 auto record_batch =
132 arrow::RecordBatch::Make(arrow::schema({arrow::field("a", arrow::int64()),
133 arrow::field("b", arrow::boolean())}),
134 10, {int64_array, bool_array});
135 ARROW_ASSIGN_OR_RAISE(auto table, arrow::Table::FromRecordBatches({record_batch}));
136 return table;
137}
138
139/// \brief Create a sample dataset
140/// \return An in-memory dataset based on GetTable()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected