| 68 | } |
| 69 | |
| 70 | static void BM_WriteInt64Column(::benchmark::State& state, Repetition::type repetition, |
| 71 | Compression::type codec, Encoding::type encoding) { |
| 72 | format::ColumnChunk thrift_metadata; |
| 73 | |
| 74 | ::arrow::random::RandomArrayGenerator rgen(1337); |
| 75 | auto values = rgen.Int64(state.range(0), 0, 1000000, 0); |
| 76 | const auto& int64_values = static_cast<const ::arrow::Int64Array&>(*values); |
| 77 | |
| 78 | std::vector<int16_t> definition_levels(state.range(0), 1); |
| 79 | std::vector<int16_t> repetition_levels(state.range(0), 0); |
| 80 | std::shared_ptr<ColumnDescriptor> schema = Int64Schema(repetition); |
| 81 | std::shared_ptr<WriterProperties> properties = WriterProperties::Builder() |
| 82 | .compression(codec) |
| 83 | ->encoding(encoding) |
| 84 | ->disable_dictionary() |
| 85 | ->build(); |
| 86 | auto metadata = ColumnChunkMetaDataBuilder::Make( |
| 87 | properties, schema.get(), reinterpret_cast<uint8_t*>(&thrift_metadata)); |
| 88 | |
| 89 | int64_t data_size = values->length() * sizeof(int64_t); |
| 90 | int64_t stream_size = 0; |
| 91 | for (auto _ : state) { |
| 92 | auto stream = CreateOutputStream(); |
| 93 | std::shared_ptr<Int64Writer> writer = BuildWriter( |
| 94 | state.range(0), stream, metadata.get(), schema.get(), properties.get(), codec); |
| 95 | writer->WriteBatch(int64_values.length(), definition_levels.data(), |
| 96 | repetition_levels.data(), int64_values.raw_values()); |
| 97 | writer->Close(); |
| 98 | stream_size = stream->Tell().ValueOrDie(); |
| 99 | } |
| 100 | SetBytesProcessed(state, repetition); |
| 101 | state.counters["compression_ratio"] = static_cast<double>(data_size) / stream_size; |
| 102 | } |
| 103 | |
| 104 | template <Repetition::type repetition, |
| 105 | Compression::type codec = Compression::UNCOMPRESSED, |
nothing calls this directly
no test coverage detected