1 #include <gtest/gtest.h>
3 #include "hash-store.h"
4 #include "standard-hash-table.h"
5 #include "tuple-types.h"
11 using namespace impala;
22 template <
int buffer_size>
25 ProbeTuple*
tuples = GenTuples(num_probe_tuples, max_id);
26 HashStore<buffer_size> hs;
29 hs.Aggregate(tuples, num_probe_tuples);
31 SanityCheck<buffer_size>(hs, num_probe_tuples, max_id, num_tables);
38 template <
int buffer_size>
40 uint64_t num_probe_tuples,
int max_id,
int num_tables) {
42 for (
int i = 0; i < hs.num_tables_; ++i) {
43 StandardHashTable& ht = hs.tables_[i];
44 for (StandardHashTable::Iterator it = ht.Begin(); it.HasNext(); it.Next()) {
45 total_count += it.GetRow()->count;
48 ASSERT_EQ(num_probe_tuples, total_count);
49 ASSERT_EQ(num_tables, hs.num_tables_)
50 <<
"You do not have the number of tables that you hoped.\n"
51 <<
"This could mean that there weren't enough probe tuples to fill the keyspace, "
52 <<
"skewed hashing lead a hash table that we expected not to overflow to overflow, "
53 <<
"or a genuine bug.";
54 if (buffer_size > 0) {
59 template <
int buffer_size>
68 delta =
static_cast<int64_t
>(time) - static_cast<int64_t>(prev);
70 LOG(ERROR) << build_tuples <<
"\t"
79 template <
int buffer_size>
80 inline static void Test() {
84 LOG(ERROR) <<
"#BuildTuples\tTime\tdTime";
92 for (
int num_tables = 1; num_tables <= 1<<12; num_tables *= 2) {
100 int build_tuples = (StandardHashTable::NODES * num_tables / 10) * 8;
101 prev = NextTestCase<buffer_size>(build_tuples, prev, num_tables);
108 int main(
int argc,
char** argv) {
109 google::InitGoogleLogging(argv[0]);
110 ::testing::InitGoogleTest(&argc, argv);
113 return RUN_ALL_TESTS();
118 GrowingTest::Test<0>();
121 GrowingTest::Test< (1 << 13) + 3 * 64 >();
uint64_t ElapsedTime() const
Returns time in cpu ticks.
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)