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

Function TableFromVector

cpp/src/parquet/arrow/reader_writer_benchmark.cc:155–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153
154template <typename ParquetType, typename ArrowType = ArrowType<ParquetType>>
155std::shared_ptr<Table> TableFromVector(const std::vector<typename ArrowType::c_type>& vec,
156 bool nullable,
157 int64_t null_percentage = kAlternatingOrNa) {
158 if (!nullable) {
159 ARROW_CHECK_EQ(null_percentage, kAlternatingOrNa);
160 }
161 std::shared_ptr<::arrow::DataType> type = std::make_shared<ArrowType>();
162 NumericBuilder<ArrowType> builder;
163 if (nullable) {
164 // Note true values select index 1 of sample_values
165 auto valid_bytes = RandomVector<uint8_t>(/*true_percentage=*/null_percentage,
166 vec.size(), /*sample_values=*/{1, 0});
167 EXIT_NOT_OK(builder.AppendValues(vec.data(), vec.size(), valid_bytes.data()));
168 } else {
169 EXIT_NOT_OK(builder.AppendValues(vec.data(), vec.size(), nullptr));
170 }
171 std::shared_ptr<::arrow::Array> array;
172 EXIT_NOT_OK(builder.Finish(&array));
173
174 auto field = ::arrow::field("column", type, nullable);
175 auto schema = ::arrow::schema({field});
176 return Table::Make(schema, {array});
177}
178
179template <>
180std::shared_ptr<Table> TableFromVector<BooleanType, ::arrow::BooleanType>(

Callers

nothing calls this directly

Calls 7

fieldFunction · 0.70
schemaFunction · 0.50
MakeFunction · 0.50
sizeMethod · 0.45
AppendValuesMethod · 0.45
dataMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected