MCPcopy Create free account
hub / github.com/apache/impala / FillWithRle

Function FillWithRle

be/src/benchmarks/rle-benchmark.cc:61–81  ·  view source on GitHub ↗

RLE encodes NUM_OUT_VALUES number of bytes into the buffer. The length of runs are pseudo random between 1 and max_run_length.

Source from the content-addressed store, hash-verified

59/// RLE encodes NUM_OUT_VALUES number of bytes into the buffer.
60/// The length of runs are pseudo random between 1 and max_run_length.
61int FillWithRle(vector<uint8_t>* buffer, int bit_width, int max_run_length) {
62 RleEncoder encoder(buffer->data(), buffer->size(), bit_width);
63
64 uniform_int_distribution<int> uniform_dist(1, max_run_length);
65 minstd_rand rand_engine;
66 uint8_t val = 0;
67 int run_length = 0;
68 for (int i = 0; i < NUM_OUT_VALUES; ++i) {
69 if (!encoder.Put(val)) {
70 LOG(ERROR) << Substitute(
71 "Error during RLE encoding. bit_widths: $0 max_run_length: $1",
72 bit_width, max_run_length);
73 }
74 if (run_length == 0) {
75 run_length = uniform_dist(rand_engine);
76 val = (val + 1) % (1 << bit_width);
77 }
78 --run_length;
79 }
80 return encoder.Flush();
81}
82
83struct BenchmarkParams {
84 int bit_width;

Callers 1

BenchmarkParamsMethod · 0.85

Calls 5

SubstituteFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
PutMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected