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

Function BM_ReadInt64Column

cpp/src/parquet/column_io_benchmark.cc:169–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169static void BM_ReadInt64Column(::benchmark::State& state, Repetition::type repetition,
170 Compression::type codec, Encoding::type encoding) {
171 const auto kNumValues = state.range(0);
172 const auto kBatchSize = state.range(1);
173
174 ::arrow::random::RandomArrayGenerator rgen(1337);
175 auto values = rgen.Int64(kNumValues, 0, 1000000, 0);
176 const auto& int64_values = static_cast<const ::arrow::Int64Array&>(*values);
177
178 std::vector<int16_t> definition_levels(kNumValues, 1);
179 std::vector<int16_t> repetition_levels(kNumValues, 0);
180 std::shared_ptr<ColumnDescriptor> schema = Int64Schema(repetition);
181 std::shared_ptr<WriterProperties> properties = WriterProperties::Builder()
182 .compression(codec)
183 ->encoding(encoding)
184 ->disable_dictionary()
185 ->build();
186
187 format::ColumnChunk thrift_metadata;
188 auto metadata = ColumnChunkMetaDataBuilder::Make(
189 properties, schema.get(), reinterpret_cast<uint8_t*>(&thrift_metadata));
190
191 auto stream = CreateOutputStream();
192 std::shared_ptr<Int64Writer> writer = BuildWriter(
193 kNumValues, stream, metadata.get(), schema.get(), properties.get(), codec);
194 writer->WriteBatch(int64_values.length(), definition_levels.data(),
195 repetition_levels.data(), int64_values.raw_values());
196 writer->Close();
197
198 PARQUET_ASSIGN_OR_THROW(auto src, stream->Finish());
199 int64_t stream_size = src->size();
200 int64_t data_size = int64_values.length() * sizeof(int64_t);
201
202 std::vector<int64_t> values_out(kBatchSize);
203 std::vector<int16_t> definition_levels_out(kBatchSize);
204 std::vector<int16_t> repetition_levels_out(kBatchSize);
205 while (state.KeepRunning()) {
206 std::shared_ptr<Int64Reader> reader =
207 BuildReader(src, kNumValues, codec, schema.get());
208 int64_t values_read = 0;
209 for (int64_t i = 0; i < kNumValues; i += values_read) {
210 reader->ReadBatch(kBatchSize, definition_levels_out.data(),
211 repetition_levels_out.data(), values_out.data(), &values_read);
212 ARROW_CHECK_NE(values_read, 0) << "Unexpected end of column";
213 }
214 }
215 SetBytesProcessed(state, repetition);
216 state.counters["compression_ratio"] = static_cast<double>(data_size) / stream_size;
217}
218
219template <Repetition::type repetition,
220 Compression::type codec = Compression::UNCOMPRESSED,

Callers

nothing calls this directly

Calls 15

CreateOutputStreamFunction · 0.85
BuildWriterFunction · 0.85
BuildReaderFunction · 0.85
Int64SchemaFunction · 0.70
BuilderFunction · 0.70
MakeFunction · 0.70
SetBytesProcessedFunction · 0.70
Int64Method · 0.45
buildMethod · 0.45
encodingMethod · 0.45
compressionMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected