mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Renamed StringRangeHash to StringRangePointersHash and added StringRangePointersEqualTo.
This commit is contained in:
parent
de15c44ff7
commit
aeaec2e6d7
@ -23,7 +23,9 @@ using ASTPtr = std::shared_ptr<IAST>;
|
||||
|
||||
class Set;
|
||||
using SetPtr = std::shared_ptr<Set>;
|
||||
using PreparedSets = std::unordered_map<StringRange, SetPtr, StringRangeHash>;
|
||||
/// Will compare sets by their position in query string. It's possible because IAST::clone() doesn't chane IAST::range.
|
||||
/// It should be taken into account when we want to change AST part which contains sets.
|
||||
using PreparedSets = std::unordered_map<StringRange, SetPtr, StringRangePointersHash, StringRangePointersEqualTo>;
|
||||
|
||||
class IBlockInputStream;
|
||||
using BlockInputStreamPtr = std::shared_ptr<IBlockInputStream>;
|
||||
|
@ -36,8 +36,6 @@ struct StringRange
|
||||
first = token_begin->begin;
|
||||
second = token_last->end;
|
||||
}
|
||||
|
||||
bool operator==(const StringRange & rhs) const { return std::tie(first, second) == std::tie(rhs.first, rhs.second); }
|
||||
};
|
||||
|
||||
using StringPtr = std::shared_ptr<String>;
|
||||
@ -48,7 +46,8 @@ inline String toString(const StringRange & range)
|
||||
return range.first ? String(range.first, range.second) : String();
|
||||
}
|
||||
|
||||
struct StringRangeHash
|
||||
/// Hashes only the values of pointers in StringRange. Is used with StringRangePointersEqualTo comparator.
|
||||
struct StringRangePointersHash
|
||||
{
|
||||
UInt64 operator()(const StringRange & range) const
|
||||
{
|
||||
@ -59,5 +58,15 @@ struct StringRangeHash
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
/// Ranges are equal only when they point to the same memory region.
|
||||
/// It may be used when it's enough to compare substrings by their position in the same string.
|
||||
struct StringRangePointersEqualTo
|
||||
{
|
||||
constexpr bool operator()(const StringRange &lhs, const StringRange &rhs) const
|
||||
{
|
||||
return std::tie(lhs.first, lhs.second) == std::tie(rhs.first, rhs.second);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
@ -14,7 +14,7 @@ class Set;
|
||||
using SetPtr = std::shared_ptr<Set>;
|
||||
|
||||
/// Information about calculated sets in right hand side of IN.
|
||||
using PreparedSets = std::unordered_map<StringRange, SetPtr, StringRangeHash>;
|
||||
using PreparedSets = std::unordered_map<StringRange, SetPtr, StringRangePointersHash, StringRangePointersEqualTo>;
|
||||
|
||||
|
||||
/** Query along with some additional data,
|
||||
|
Loading…
Reference in New Issue
Block a user