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

Method RegisterQueriesAndClients

be/src/runtime/bufferpool/buffer-pool-test.cc:482–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480const int64_t BufferPoolTest::TEST_BUFFER_LEN;
481
482void BufferPoolTest::RegisterQueriesAndClients(BufferPool* pool, int query_id_hi,
483 int num_queries, int64_t initial_query_reservation, int64_t query_reservation_limit,
484 mt19937* rng) {
485 Status status;
486
487 int clients_per_query = 32;
488 BufferPool::ClientHandle* clients[num_queries];
489
490 for (int i = 0; i < num_queries; ++i) {
491 int64_t query_id = QueryId(query_id_hi, i);
492
493 // Initialize a tracker for a new query.
494 ReservationTracker* query_reservation = GetQueryReservationTracker(query_id);
495 query_reservation->InitChildTracker(
496 NULL, &global_reservations_, NULL, query_reservation_limit);
497
498 // Test that closing then reopening child tracker works.
499 query_reservation->Close();
500 query_reservation->InitChildTracker(
501 NULL, &global_reservations_, NULL, query_reservation_limit);
502 EXPECT_TRUE(query_reservation->IncreaseReservationToFit(initial_query_reservation));
503
504 clients[i] = new BufferPool::ClientHandle[clients_per_query];
505
506 for (int j = 0; j < clients_per_query; ++j) {
507 int64_t initial_client_reservation =
508 initial_query_reservation / clients_per_query + j
509 < initial_query_reservation % clients_per_query;
510 // Reservation limit can be anything greater or equal to the initial reservation.
511 int64_t client_reservation_limit = initial_client_reservation + (*rng)() % 100000;
512 string name = Substitute("Client $0 for query $1", j, query_id);
513 EXPECT_OK(pool->RegisterClient(name, NULL, query_reservation, NULL,
514 client_reservation_limit, NewProfile(), &clients[i][j]));
515 EXPECT_TRUE(clients[i][j].IncreaseReservationToFit(initial_client_reservation));
516 }
517
518 for (int j = 0; j < clients_per_query; ++j) {
519 ASSERT_TRUE(clients[i][j].is_registered());
520 }
521 }
522
523 // Deregister clients then query.
524 for (int i = 0; i < num_queries; ++i) {
525 for (int j = 0; j < clients_per_query; ++j) {
526 pool->DeregisterClient(&clients[i][j]);
527 ASSERT_FALSE(clients[i][j].is_registered());
528 }
529
530 delete[] clients[i];
531
532 GetQueryReservationTracker(QueryId(query_id_hi, i))->Close();
533 }
534}
535
536/// Test that queries and clients can be registered and deregistered with the reservation
537/// trackers and the buffer pool.

Callers

nothing calls this directly

Calls 7

SubstituteFunction · 0.85
InitChildTrackerMethod · 0.80
is_registeredMethod · 0.80
DeregisterClientMethod · 0.80
CloseMethod · 0.45
RegisterClientMethod · 0.45

Tested by

no test coverage detected