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

Method DoQueries

be/src/kudu/util/cache-bench.cc:103–129  ·  view source on GitHub ↗

Run queries against the cache until '*done' becomes true. Returns a pair of the number of cache hits and lookups.

Source from the content-addressed store, hash-verified

101 // Run queries against the cache until '*done' becomes true.
102 // Returns a pair of the number of cache hits and lookups.
103 pair<int64_t, int64_t> DoQueries(const atomic<bool>* done) {
104 const BenchSetup& setup = GetParam();
105 Random r(GetRandomSeed32());
106 int64_t lookups = 0;
107 int64_t hits = 0;
108 while (!*done) {
109 uint32_t int_key;
110 if (setup.pattern == BenchSetup::Pattern::ZIPFIAN) {
111 int_key = r.Skewed(Bits::Log2Floor(setup.max_key()));
112 } else {
113 int_key = r.Uniform(setup.max_key());
114 }
115 char key_buf[sizeof(int_key)];
116 memcpy(key_buf, &int_key, sizeof(int_key));
117 Slice key_slice(key_buf, arraysize(key_buf));
118 auto h(cache_->Lookup(key_slice, Cache::EXPECT_IN_CACHE));
119 if (h) {
120 ++hits;
121 } else {
122 auto ph(cache_->Allocate(
123 key_slice, /* val_len=*/kEntrySize, /* charge=*/kEntrySize));
124 cache_->Insert(std::move(ph), nullptr);
125 }
126 ++lookups;
127 }
128 return {hits, lookups};
129 }
130
131 // Starts the given number of threads to concurrently call DoQueries.
132 // Returns the aggregated number of cache hits and lookups.

Callers

nothing calls this directly

Calls 8

GetRandomSeed32Function · 0.85
moveFunction · 0.85
SkewedMethod · 0.45
max_keyMethod · 0.45
UniformMethod · 0.45
LookupMethod · 0.45
AllocateMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected