[fix](bloom-filter) Fix error when handle empty string in bloom filter (#7448)

This commit is contained in:
EmmyMiao87
2021-12-31 16:05:33 +08:00
committed by GitHub
parent b2c5f25ef4
commit 46ca012e2b

View File

@ -206,11 +206,12 @@ struct StringFindOp {
template <class BloomFilterAdaptor>
struct FixedStringFindOp : public StringFindOp<BloomFilterAdaptor> {
ALWAYS_INLINE bool find_olap_engine(const BloomFilterAdaptor& bloom_filter,
const void* data) const {
const auto* value = reinterpret_cast<const StringValue*>(data);
auto end_ptr = value->ptr + value->len - 1;
while (end_ptr > value->ptr && *end_ptr == '\0') --end_ptr;
return bloom_filter.test_bytes(value->ptr, end_ptr - value->ptr + 1);
const void* input_data) const {
const auto* value = reinterpret_cast<const StringValue*>(input_data);
int64_t size = value->len;
char* data = value->ptr;
while (size > 0 && data[size - 1] == '\0') size--;
return bloom_filter.test_bytes(value->ptr, size);
}
};