Merge pull request #18750 from ClickHouse/fix-bad-code-joins

Remove bad code in HashJoin
This commit is contained in:
alexey-milovidov 2021-01-05 19:57:49 +03:00 committed by GitHub
commit fd27990d96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 7 deletions

View File

@ -357,10 +357,14 @@ void HashJoin::init(Type type_)
joinDispatch(kind, strictness, data->maps, [&](auto, auto, auto & map) { map.create(data->type); });
}
size_t HashJoin::getTotalRowCount() const
bool HashJoin::overDictionary() const
{
std::shared_lock lock(data->rwlock);
return getTotalRowCountLocked();
return data->type == Type::DICT;
}
bool HashJoin::empty() const
{
return data->type == Type::EMPTY;
}
size_t HashJoin::getTotalByteCount() const
@ -369,6 +373,18 @@ size_t HashJoin::getTotalByteCount() const
return getTotalByteCountLocked();
}
size_t HashJoin::getTotalRowCount() const
{
std::shared_lock lock(data->rwlock);
return getTotalRowCountLocked();
}
bool HashJoin::alwaysReturnsEmptySet() const
{
std::shared_lock lock(data->rwlock);
return isInnerOrRight(getKind()) && data->empty && !overDictionary();
}
size_t HashJoin::getTotalRowCountLocked() const
{
size_t res = 0;

View File

@ -150,9 +150,6 @@ class HashJoin : public IJoin
public:
HashJoin(std::shared_ptr<TableJoin> table_join_, const Block & right_sample_block, bool any_take_last_row_ = false);
bool empty() const { return data->type == Type::EMPTY; }
bool overDictionary() const { return data->type == Type::DICT; }
/** Add block of data from right hand of JOIN to the map.
* Returns false, if some limit was exceeded and you should not insert more data.
*/
@ -188,7 +185,7 @@ public:
/// Sum size in bytes of all buffers, used for JOIN maps and for all memory pools.
size_t getTotalByteCount() const final;
bool alwaysReturnsEmptySet() const final { return isInnerOrRight(getKind()) && data->empty && !overDictionary(); }
bool alwaysReturnsEmptySet() const final;
ASTTableJoin::Kind getKind() const { return kind; }
ASTTableJoin::Strictness getStrictness() const { return strictness; }
@ -397,6 +394,9 @@ private:
/// Call with already locked rwlock.
size_t getTotalRowCountLocked() const;
size_t getTotalByteCountLocked() const;
bool empty() const;
bool overDictionary() const;
};
}