1 #include <gtest/gtest.h>
3 #include "hash-store.h"
4 #include "standard-hash-table.h"
5 #include "tuple-types.h"
10 using namespace impala;
21 template <
int buffer_size>
24 ProbeTuple*
tuples = GenTuples(num_probe_tuples, max_id);
25 HashStore<buffer_size> hs;
28 hs.Aggregate(tuples, num_probe_tuples);
30 SanityCheck<buffer_size>(hs, num_probe_tuples, max_id, num_tables);
37 template <
int buffer_size>
39 uint64_t num_probe_tuples,
int max_id,
int num_tables) {
41 for (
int i = 0; i < hs.num_tables_; ++i) {
42 StandardHashTable& ht = hs.tables_[i];
43 for (StandardHashTable::Iterator it = ht.Begin(); it.HasNext(); it.Next()) {
44 total_count += it.GetRow()->count;
47 ASSERT_EQ(num_probe_tuples, total_count);
48 ASSERT_EQ(num_tables, hs.num_tables_)
49 <<
"You do not have the number of tables that you hoped.\n"
50 <<
"This could mean that there weren't enough probe tuples to fill the keyspace, "
51 <<
"skewed hashing lead a hash table that we expected not to overflow to overflow, "
52 <<
"or a genuine bug.";
53 if (buffer_size > 0) {
58 template <
int buffer_size>
67 delta =
static_cast<int64_t
>(time) - static_cast<int64_t>(prev);
69 LOG(ERROR) << build_tuples <<
"\t"
78 template <
int buffer_size>
79 inline static void Test() {
83 LOG(ERROR) <<
"#BuildTuples\tTime\tdTime";
91 for (
int num_tables = 1; num_tables <= 1<<12; num_tables *= 2) {
99 int build_tuples = (StandardHashTable::NODES * num_tables / 10) * 8;
100 prev = NextTestCase<buffer_size>(build_tuples, prev, num_tables);
107 int main(
int argc,
char** argv) {
108 google::InitGoogleLogging(argv[0]);
109 ::testing::InitGoogleTest(&argc, argv);
112 return RUN_ALL_TESTS();
117 GrowingTest::Test<0>();
120 GrowingTest::Test< (1 << 13) + 3 * 64 >();
static void SanityCheck(const HashStore< buffer_size > &hs, uint64_t num_probe_tuples, int max_id, int num_tables)
ProbeTuple tuples[BUFFER_TUPLES]
static std::string Print(bool value, TUnit::type ignored, bool verbose=false)
static uint64_t NextTestCase(int build_tuples, uint64_t prev, int num_tables)
static const uint64_t NUM_PROBE_TUPLES
uint64_t Test(T *ht, const ProbeTuple *input, uint64_t num_tuples)
int main(int argc, char **argv)
static void Init()
Initialize CpuInfo.
static uint64_t AggregateTest(uint64_t num_probe_tuples, int max_id, int num_tables)