ClickHouse/dbms/src/Common/tests/hash_table.cpp

52 lines
1.0 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
2014-03-17 02:01:03 +00:00
int main(int argc, char ** argv)
{
{
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::iterator it;
bool inserted;
2014-03-17 02:01:03 +00:00
cont.emplace(3, it, inserted);
std::cerr << inserted << ", " << *it << std::endl;
2014-03-17 02:01:03 +00:00
cont.emplace(3, it, inserted);
std::cerr << inserted << ", " << *it << std::endl;
2014-03-17 02:01:03 +00:00
for (auto x : cont)
std::cerr << x << 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
}