mkql_rh_hash_utils.cpp 722 B

123456789101112131415161718192021222324252627282930313233
  1. #include "mkql_rh_hash_utils.h"
  2. namespace NKikimr {
  3. namespace NMiniKQL {
  4. ui64 RHHashTableNeedsGrow(ui64 size, ui64 capacity) {
  5. return size * 2 >= capacity;
  6. }
  7. ui64 CalculateRHHashTableGrowFactor(ui64 currentCapacity) {
  8. ui64 growFactor;
  9. if (currentCapacity < 100'000) {
  10. growFactor = 8;
  11. } else if (currentCapacity < 1'000'000) {
  12. growFactor = 4;
  13. } else {
  14. growFactor = 2;
  15. }
  16. return growFactor;
  17. }
  18. ui64 CalculateRHHashTableCapacity(ui64 targetSize) {
  19. ui64 capacity = 256;
  20. while (RHHashTableNeedsGrow(targetSize, capacity)) {
  21. capacity *= CalculateRHHashTableGrowFactor(capacity);
  22. }
  23. return capacity;
  24. }
  25. } // namespace NMiniKQL
  26. } // namespace NKikimr