enable used flags's reinit only when the hash talbe rehash

This commit is contained in:
lgbo-ustc 2023-05-06 10:37:38 +08:00
parent 8adc878049
commit a07359fbe8
2 changed files with 13 additions and 1 deletions

View File

@ -79,9 +79,15 @@ namespace JoinStuff
{
assert(flags[nullptr].size() <= size);
need_flags = true;
// For one disjunct clause case, we don't need to reinit each time we call addJoinedBlock.
// and there is no value inserted in this JoinUsedFlags before addJoinedBlock finish.
// So we reinit only when the hash table is rehashed to a larger size.
if (flags.empty() || flags[nullptr].size() < size) [[unlikely]]
{
flags[nullptr] = std::vector<std::atomic_bool>(size);
}
}
}
/// for multiple disjuncts
template <JoinKind KIND, JoinStrictness STRICTNESS>

View File

@ -0,0 +1,6 @@
<test>
<create_query>CREATE TABLE test_join_used_flags (i64 Int64, i32 Int32) ENGINE = Memory</create_query>
<fill_query>INSERT INTO test_join_used_flags SELECT number AS i64, rand32() AS i32 FROM numbers(20000000)</fill_query>
<query>SELECT l.i64, r.i64, l.i32, r.i32 FROM test_join_used_flags l RIGHT JOIN test_join_used_flags r USING i64 format Null</query>
<drop_query>DROP TABLE IF EXISTS test_join_used_flags</drop_query>
</test>