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;
32 template <
int buffer_size>
36 HashStore<buffer_size> hs;
39 hs.Aggregate(tuples, num_probe_tuples);
41 SanityCheck<buffer_size>(hs, num_probe_tuples, num_tables);
48 template <
int buffer_size>
50 uint64_t num_probe_tuples,
int num_tables) {
53 for (
int i = 0; i < hs.num_tables_; ++i) {
54 StandardHashTable& ht = hs.tables_[i];
55 for (StandardHashTable::Iterator it = ht.Begin(); it.HasNext(); it.Next()) {
56 total_count += it.GetRow()->count;
60 ASSERT_EQ(num_probe_tuples, total_count);
62 ASSERT_EQ(num_tables, hs.num_tables_)
63 <<
"You do not have the number of tables that you hoped.\n"
64 <<
"This could mean that there weren't enough probe tuples to fill the keyspace, "
65 <<
"skewed hashing lead a hash table that we expected not to overflow to overflow, "
66 <<
"or a genuine bug.";
67 if (buffer_size > 0) {
72 template <
int buffer_size>
81 delta =
static_cast<int64_t
>(time) - static_cast<int64_t>(prev);
92 template <
int buffer_size>
93 inline static void Test() {
97 LOG(ERROR) <<
"#BuildTuples\tTime\tdTime";
105 for (
int num_tables = 1; num_tables <= 1<<10; num_tables *= 2) {
106 prev = NextTestCase<buffer_size>(prev, num_tables);
113 int main(
int argc,
char** argv) {
114 google::InitGoogleLogging(argv[0]);
115 ::testing::InitGoogleTest(&argc, argv);
118 return RUN_ALL_TESTS();
123 GrowingTest::Test<0>();
126 GrowingTest::Test< (1 << 13) + 3 * 64 >();
static const int TUPLES_IN_TABLE
uint64_t ElapsedTime() const
Returns time in cpu ticks.
static void SanityCheck(const HashStore< buffer_size > &hs, uint64_t num_probe_tuples, int num_tables)
ProbeTuple tuples[BUFFER_TUPLES]
static uint64_t NextTestCase(uint64_t prev, int num_tables)
static std::string Print(bool value, TUnit::type ignored, bool verbose=false)
static uint64_t AggregateTest(uint64_t num_probe_tuples, 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.