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

Method CreateHashTable

be/src/benchmarks/hash-table-benchmark.cc:166–204  ·  view source on GitHub ↗

Construct hash table and buffer pool client. Created objects and resources (e.g. reservations) are automatically freed in TearDown().

Source from the content-addressed store, hash-verified

164 /// Created objects and resources (e.g. reservations) are automatically freed
165 /// in TearDown().
166 bool CreateHashTable(int64_t block_size = 8 * 1024 * 1024, int max_num_blocks = 100,
167 int initial_reserved_blocks = 10, int64_t suballocator_buffer_len = 64 * 1024) {
168 ExecEnv* exec_env = test_env_->exec_env();
169 BufferPool* buffer_pool = exec_env->buffer_pool();
170 RuntimeProfile* profile = RuntimeProfile::Create(&pool_, "ht");
171
172 // Set up memory tracking for the hash table.
173 MemTracker* client_tracker =
174 pool_.Add(new MemTracker(-1, "client", runtime_state_->instance_mem_tracker()));
175 int64_t initial_reservation_bytes = block_size * initial_reserved_blocks;
176 int64_t max_reservation_bytes = block_size * max_num_blocks;
177
178 // Set up the memory allocator.
179 BufferPool::ClientHandle* client = pool_.Add(new BufferPool::ClientHandle);
180 clients_.push_back(client);
181 Status status = buffer_pool->RegisterClient("htbenchmark", nullptr,
182 runtime_state_->instance_buffer_reservation(), client_tracker,
183 max_reservation_bytes, profile, client);
184 if (!status.ok()) {
185 std::cout << "Registering client to buffer pool failed" << std::endl;
186 return false;
187 }
188 bool success = client->IncreaseReservation(initial_reservation_bytes);
189 if (!success) {
190 std::cout << "Client increasing reservation failed" << std::endl;
191 return false;
192 }
193 Suballocator* allocator =
194 pool_.Add(new Suballocator(buffer_pool, client, suballocator_buffer_len));
195
196 int64_t max_num_buckets = 1L << 31;
197 hash_table_ = pool_.Add(HashTable::Create(
198 allocator, true, 1, nullptr, max_num_buckets, initial_num_buckets));
199 status = hash_table_->Init(&success);
200 if (!(status.ok() && success)) {
201 std::cout << "HashTable Init failed" << std::endl;
202 }
203 return status.ok() && success;
204 }
205 TupleRow* CreateTupleRow(int32_t val) {
206 uint8_t* tuple_row_mem = mem_pool_.Allocate(sizeof(int32_t*));
207 Tuple* tuple_mem = Tuple::Create(sizeof(char) + sizeof(int32_t), &mem_pool_);

Callers

nothing calls this directly

Calls 11

CreateClass · 0.85
exec_envMethod · 0.80
instance_mem_trackerMethod · 0.80
push_backMethod · 0.80
buffer_poolMethod · 0.45
AddMethod · 0.45
RegisterClientMethod · 0.45
okMethod · 0.45
IncreaseReservationMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected