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

Function BuildDictionary

cpp/src/arrow/compute/kernels/vector_hash_benchmark.cc:35–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33namespace compute {
34
35static void BuildDictionary(benchmark::State& state) { // NOLINT non-const reference
36 const int64_t iterations = 1024;
37
38 std::vector<int64_t> values;
39 std::vector<bool> is_valid;
40 for (int64_t i = 0; i < iterations; i++) {
41 for (int64_t j = 0; j < i; j++) {
42 is_valid.push_back((i + j) % 9 != 0);
43 values.push_back(j);
44 }
45 }
46
47 std::shared_ptr<Array> arr;
48 ArrayFromVector<Int64Type, int64_t>(is_valid, values, &arr);
49
50 while (state.KeepRunning()) {
51 ABORT_NOT_OK(DictionaryEncode(arr));
52 }
53 state.counters["null_percent"] =
54 static_cast<double>(arr->null_count()) / arr->length() * 100;
55 state.SetBytesProcessed(state.iterations() * values.size() * sizeof(int64_t));
56 state.SetItemsProcessed(state.iterations() * values.size());
57}
58
59static void BuildStringDictionary(
60 benchmark::State& state) { // NOLINT non-const reference

Callers

nothing calls this directly

Calls 5

DictionaryEncodeFunction · 0.85
push_backMethod · 0.80
null_countMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected