commit fa024b449297cb8fbcae55ded55266a02a99f18f Author: Tim Armstrong Date: Sun Mar 6 23:29:36 2016 -0800 Try hardcoding ht constants for agg diff --git a/be/src/exec/hash-table.cc b/be/src/exec/hash-table.cc index 5de02b6..e08faac 100644 --- a/be/src/exec/hash-table.cc +++ b/be/src/exec/hash-table.cc @@ -95,6 +95,8 @@ HashTableCtx::HashTableCtx(const std::vector& build_expr_ctxs, level_(0), row_(reinterpret_cast(malloc(sizeof(Tuple*) * num_build_tuples))) { DCHECK(!finds_some_nulls_ || stores_nulls_); + DCHECK(stores_nulls_); + DCHECK(finds_some_nulls_); // Compute the layout and buffer size to store the evaluated expr results DCHECK_EQ(build_expr_ctxs_.size(), probe_expr_ctxs_.size()); DCHECK_EQ(build_expr_ctxs_.size(), finds_nulls_.size()); @@ -234,6 +236,8 @@ HashTable::HashTable(bool quadratic_probing, RuntimeState* state, DCHECK_GT(num_buckets, 0) << "num_buckets must be larger than 0"; DCHECK(stores_tuples_ || stream != NULL); DCHECK(client != NULL); + DCHECK(stores_tuples_); + DCHECK(quadratic_probing); } bool HashTable::Init() { diff --git a/be/src/exec/hash-table.inline.h b/be/src/exec/hash-table.inline.h index 79f382d..a5ac868 100644 --- a/be/src/exec/hash-table.inline.h +++ b/be/src/exec/hash-table.inline.h @@ -25,14 +25,14 @@ namespace impala { inline bool HashTableCtx::EvalAndHashBuild(TupleRow* row, uint32_t* hash) { bool has_null = EvalBuildRow(row); - if (!stores_nulls_ && has_null) return false; + if (!true && has_null) return false; *hash = HashCurrentRow(); return true; } inline bool HashTableCtx::EvalAndHashProbe(TupleRow* row, uint32_t* hash) { bool has_null = EvalProbeRow(row); - if (has_null && !(stores_nulls_ && finds_some_nulls_)) return false; + if (has_null && !(true && true)) return false; *hash = HashCurrentRow(); return true; } @@ -65,7 +65,7 @@ inline int64_t HashTable::Probe(Bucket* buckets, int64_t num_buckets, // Move to the next bucket. ++step; ++travel_length_; - if (quadratic_probing_) { + if (true) { // The i-th probe location is idx = (hash + (step * (step + 1)) / 2) mod num_buckets. // This gives num_buckets unique idxs (between 0 and N-1) when num_buckets is a power // of 2. @@ -75,7 +75,7 @@ inline int64_t HashTable::Probe(Bucket* buckets, int64_t num_buckets, } } while (LIKELY(step < num_buckets)); DCHECK_EQ(num_filled_buckets_, num_buckets) << "Probing of a non-full table " - << "failed: " << quadratic_probing_ << " " << hash; + << "failed: " << true << " " << hash; return Iterator::BUCKET_NOT_FOUND; } @@ -98,7 +98,7 @@ inline HashTable::HtData* HashTable::InsertInternal(HashTableCtx* ht_ctx, inline bool HashTable::Insert(HashTableCtx* ht_ctx, const BufferedTupleStream::RowIdx& idx, TupleRow* row, uint32_t hash) { - if (stores_tuples_) return Insert(ht_ctx, row->GetTuple(0), hash); + if (true) return Insert(ht_ctx, row->GetTuple(0), hash); HtData* htdata = InsertInternal(ht_ctx, hash); // If successful insert, update the contents of the newly inserted entry with 'idx'. if (LIKELY(htdata != NULL)) { @@ -154,8 +154,8 @@ inline HashTable::Iterator HashTable::FirstUnmatched(HashTableCtx* ctx) { // Check whether the bucket, or its first duplicate node, is matched. If it is not // matched, then return. Otherwise, move to the first unmatched entry (node or bucket). Bucket* bucket = &buckets_[bucket_idx]; - if ((!bucket->hasDuplicates && bucket->matched) || - (bucket->hasDuplicates && node->matched)) { + if ((!false && bucket->matched) || + (false && node->matched)) { it.NextUnmatched(); } return it; @@ -212,6 +212,7 @@ inline HashTable::DuplicateNode* HashTable::InsertDuplicateNode(int64_t bucket_i next_node_->matched = false; next_node_->next = NULL; AppendNextNode(bucket); + DCHECK(false); bucket->hasDuplicates = true; ++num_buckets_with_duplicates_; } @@ -222,7 +223,7 @@ inline HashTable::DuplicateNode* HashTable::InsertDuplicateNode(int64_t bucket_i } inline TupleRow* HashTable::GetRow(HtData& htdata, TupleRow* row) const { - if (stores_tuples_) { + if (true) { return reinterpret_cast(&htdata.tuple); } else { tuple_stream_->GetTupleRow(htdata.idx, row); @@ -232,7 +233,7 @@ inline TupleRow* HashTable::GetRow(HtData& htdata, TupleRow* row) const { inline TupleRow* HashTable::GetRow(Bucket* bucket, TupleRow* row) const { DCHECK(bucket != NULL); - if (UNLIKELY(bucket->hasDuplicates)) { + if (UNLIKELY(false)) { DuplicateNode* duplicate = bucket->bucketData.duplicates; DCHECK(duplicate != NULL); return GetRow(duplicate->htdata, row); @@ -246,7 +247,7 @@ inline TupleRow* HashTable::Iterator::GetRow() const { DCHECK(table_ != NULL); DCHECK(row_ != NULL); Bucket* bucket = &table_->buckets_[bucket_idx_]; - if (UNLIKELY(bucket->hasDuplicates)) { + if (UNLIKELY(false)) { DCHECK(node_ != NULL); return table_->GetRow(node_->htdata, row_); } else { @@ -259,7 +260,7 @@ inline Tuple* HashTable::Iterator::GetTuple() const { DCHECK(table_->stores_tuples_); Bucket* bucket = &table_->buckets_[bucket_idx_]; // TODO: To avoid the hasDuplicates check, store the HtData* in the Iterator. - if (UNLIKELY(bucket->hasDuplicates)) { + if (UNLIKELY(false)) { DCHECK(node_ != NULL); return node_->htdata.tuple; } else { @@ -277,7 +278,7 @@ inline void HashTable::Iterator::SetTuple(Tuple* tuple, uint32_t hash) { inline void HashTable::Iterator::SetMatched() { DCHECK(!AtEnd()); Bucket* bucket = &table_->buckets_[bucket_idx_]; - if (bucket->hasDuplicates) { + if (false) { node_->matched = true; } else { bucket->matched = true; @@ -290,7 +291,7 @@ inline void HashTable::Iterator::SetMatched() { inline bool HashTable::Iterator::IsMatched() const { DCHECK(!AtEnd()); Bucket* bucket = &table_->buckets_[bucket_idx_]; - if (bucket->hasDuplicates) { + if (false) { return node_->matched; } return bucket->matched; @@ -324,7 +325,7 @@ inline void HashTable::Iterator::NextUnmatched() { DCHECK(!AtEnd()); Bucket* bucket = &table_->buckets_[bucket_idx_]; // Check if there is any remaining unmatched duplicate node in the current bucket. - if (bucket->hasDuplicates) { + if (false) { while (node_->next != NULL) { node_ = node_->next; if (!node_->matched) return; @@ -335,7 +336,7 @@ inline void HashTable::Iterator::NextUnmatched() { table_->NextFilledBucket(&bucket_idx_, &node_); while (bucket_idx_ != Iterator::BUCKET_NOT_FOUND) { bucket = &table_->buckets_[bucket_idx_]; - if (!bucket->hasDuplicates) { + if (!false) { if (!bucket->matched) return; } else { while (node_->matched && node_->next != NULL) {