ClickHouse/src/Common/tests/hash_table.cpp

51 lines
1.1 KiB
C++
Raw Normal View History

2014-03-17 02:01:03 +00:00
#include <iostream>
#include <iomanip>
#include <Interpreters/AggregationCommon.h>
#include <Common/HashTable/HashMap.h>
#include <Common/HashTable/HashSet.h>
2014-03-17 02:01:03 +00:00
2017-12-01 18:36:55 +00:00
int main(int, char **)
2014-03-17 02:01:03 +00:00
{
{
2017-08-30 18:13:32 +00:00
using Cont = HashSet<int, DefaultHash<int>, HashTableGrower<1>>;
Cont cont;
2014-03-17 02:01:03 +00:00
cont.insert(1);
cont.insert(2);
2014-03-17 02:01:03 +00:00
Cont::LookupResult it;
bool inserted;
int key = 3;
cont.emplace(key, it, inserted);
std::cerr << inserted << ", " << key << std::endl;
2014-03-17 02:01:03 +00:00
cont.emplace(key, it, inserted);
std::cerr << inserted << ", " << key << std::endl;
2014-03-17 02:01:03 +00:00
for (auto x : cont)
A Proper lookup table that uses HashTable's API This is the first step of allowing heterogeneous cells in hash tables. performance test results are ``` 1. HashMap<UInt16, UInt8, TrivialHash, HashTableFixedGrower<16>>; 2. NewLookupMap<UInt16, UInt8> ResolutionWidth 30000 1 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................223550276.46 ResolutionWidth 30000 2 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................248772721.24 Best: 2 - 24877272124 ResolutionWidth 100000 1 ..........................................................................................................................................................................................................................................................238498413.99 ResolutionWidth 100000 2 ..........................................................................................................................................................................................................................................................261808889.98 Best: 2 - 26180888998 ResolutionWidth 300000 1 ...................................................................................239307348.81 ResolutionWidth 300000 2 ...................................................................................257592761.30 Best: 2 - 25759276130 ResolutionWidth 1000000 1 .........................240144759.26 ResolutionWidth 1000000 2 .........................257093531.91 Best: 2 - 25709353191 ResolutionWidth 5000000 1 .....241573260.35 ResolutionWidth 5000000 2 .....259314162.79 Best: 2 - 25931416279 ResolutionDepth 30000 1 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................217108119.84 ResolutionDepth 30000 2 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................249459504.41 Best: 2 - 24945950441 ResolutionDepth 100000 1 ..........................................................................................................................................................................................................................................................229065162.17 ResolutionDepth 100000 2 ..........................................................................................................................................................................................................................................................253769105.64 Best: 2 - 25376910564 ResolutionDepth 300000 1 ...................................................................................233079225.18 ResolutionDepth 300000 2 ...................................................................................256316273.78 Best: 2 - 25631627378 ResolutionDepth 1000000 1 .........................234184633.51 ResolutionDepth 1000000 2 .........................261100491.57 Best: 2 - 26110049157 ResolutionDepth 5000000 1 .....233118795.66 ResolutionDepth 5000000 2 .....252436160.41 Best: 2 - 25243616041 ```
2019-02-28 09:35:38 +00:00
std::cerr << x.getValue() << std::endl;
2014-03-17 02:01:03 +00:00
2017-07-31 21:39:24 +00:00
DB::WriteBufferFromOwnString wb;
cont.writeText(wb);
2014-03-17 02:01:03 +00:00
2017-07-31 21:39:24 +00:00
std::cerr << "dump: " << wb.str() << std::endl;
}
2014-03-17 02:01:03 +00:00
{
using Cont = HashSet<
DB::UInt128,
DB::UInt128TrivialHash>;
Cont cont;
2017-07-31 21:39:24 +00:00
DB::WriteBufferFromOwnString wb;
cont.write(wb);
2017-07-31 21:39:24 +00:00
std::cerr << "dump: " << wb.str() << std::endl;
}
return 0;
2014-03-17 02:01:03 +00:00
}