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

Method MakeParquetObject

cpp/src/arrow/filesystem/s3fs_benchmark.cc:149–176  ·  view source on GitHub ↗

Make an object with Parquet data. Appends integer columns to the beginning (to act as indices).

Source from the content-addressed store, hash-verified

147 /// Make an object with Parquet data.
148 /// Appends integer columns to the beginning (to act as indices).
149 Status MakeParquetObject(const std::string& path, int num_columns, int num_rows) {
150 std::vector<std::shared_ptr<ChunkedArray>> columns;
151 FieldVector fields{
152 field("timestamp", int64(), /*nullable=*/true,
153 key_value_metadata(
154 {{"min", "0"}, {"max", "10000000000"}, {"null_probability", "0"}})),
155 field("val", int32(), /*nullable=*/true,
156 key_value_metadata(
157 {{"min", "0"}, {"max", "1000000000"}, {"null_probability", "0"}}))};
158 for (int i = 0; i < num_columns; i++) {
159 std::stringstream ss;
160 ss << "col" << i;
161 fields.push_back(
162 field(ss.str(), float64(), /*nullable=*/true,
163 key_value_metadata(
164 {{"min", "-1.e10"}, {"max", "1e10"}, {"null_probability", "0"}})));
165 }
166 auto batch = random::GenerateBatch(fields, num_rows, 0);
167 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Table> table,
168 Table::FromRecordBatches({batch}));
169
170 std::shared_ptr<io::OutputStream> sink;
171 ARROW_ASSIGN_OR_RAISE(sink, fs_->OpenOutputStream(path));
172 RETURN_NOT_OK(
173 parquet::arrow::WriteTable(*table, arrow::default_memory_pool(), sink, num_rows));
174
175 return Status::OK();
176 }
177
178 void TearDown(const ::benchmark::State& state) override {
179 ASSERT_OK(minio_->Stop());

Callers

nothing calls this directly

Calls 10

key_value_metadataFunction · 0.85
GenerateBatchFunction · 0.85
default_memory_poolFunction · 0.85
push_backMethod · 0.80
strMethod · 0.80
fieldFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
WriteTableFunction · 0.50
OKFunction · 0.50
OpenOutputStreamMethod · 0.45

Tested by

no test coverage detected