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

Function CreateRandomBitsBuffer

cpp/src/arrow/util/bit_util_benchmark.cc:112–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112static std::shared_ptr<Buffer> CreateRandomBitsBuffer(int64_t nbits,
113 int64_t set_percentage) {
114 ::arrow::random::RandomArrayGenerator rag(/*seed=*/23);
115 double set_probability =
116 static_cast<double>(set_percentage == -1 ? 0 : set_percentage) / 100.0;
117 std::shared_ptr<Buffer> buffer =
118 rag.Boolean(nbits, set_probability)->data()->buffers[1];
119
120 if (set_percentage == -1) {
121 internal::BitmapWriter writer(buffer->mutable_data(), /*start_offset=*/0,
122 /*length=*/nbits);
123 for (int x = 0; x < nbits; x++) {
124 if (x % 2 == 0) {
125 writer.Set();
126 } else {
127 writer.Clear();
128 }
129 writer.Next();
130 }
131 }
132 return buffer;
133}
134
135template <typename DoAnd>
136static void BenchmarkAndImpl(benchmark::State& state, DoAnd&& do_and) {

Callers 2

BenchmarkBitRunReaderFunction · 0.85
BenchmarkSetBitRunReaderFunction · 0.85

Calls 6

dataMethod · 0.45
BooleanMethod · 0.45
mutable_dataMethod · 0.45
SetMethod · 0.45
ClearMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected