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

Function BM_ReadInt64Column

cpp/src/parquet/column_io_benchmark.cc:170–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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