fix: fix LoadMetrics bool type error (#45209)

#44584

Signed-off-by: thekingking <1677273255@qq.com>
This commit is contained in:
Jingsong Yin 2025-11-01 01:19:32 +08:00 committed by GitHub
parent 0cc79772e7
commit e25ee08566
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1062,57 +1062,59 @@ class SkipIndexStatsBuilder {
} }
return std::make_unique<BooleanFieldChunkMetrics>( return std::make_unique<BooleanFieldChunkMetrics>(
info.contains_true_, info.contains_false_); info.contains_true_, info.contains_false_);
}
T min, max;
if constexpr (std::is_same_v<T, std::string>) {
min = std::string(info.min_);
max = std::string(info.max_);
} else { } else {
min = info.min_; T min, max;
max = info.max_;
}
if constexpr (std::is_floating_point_v<T>) {
return std::make_unique<FloatFieldChunkMetrics<T>>(min, max);
}
if (!enable_bloom_filter_) {
if constexpr (std::is_same_v<T, std::string>) { if constexpr (std::is_same_v<T, std::string>) {
return std::make_unique<StringFieldChunkMetrics>( min = std::string(info.min_);
min, max, nullptr, nullptr); max = std::string(info.max_);
} else {
min = info.min_;
max = info.max_;
} }
return std::make_unique<IntFieldChunkMetrics<T>>(min, max, nullptr); if constexpr (std::is_floating_point_v<T>) {
} return std::make_unique<FloatFieldChunkMetrics<T>>(min, max);
BloomFilterPtr bloom_filter =
NewBloomFilterWithType(info.unique_values_.size(),
DEFAULT_BLOOM_FILTER_FALSE_POSITIVE_RATE,
BFType::Blocked);
if constexpr (std::is_same_v<T, std::string>) {
for (const auto& val : info.unique_values_) {
bloom_filter->Add(val);
} }
if (info.ngram_values_.empty()) { if (!enable_bloom_filter_) {
return std::make_unique<StringFieldChunkMetrics>( if constexpr (std::is_same_v<T, std::string>) {
min, max, std::move(bloom_filter), nullptr); return std::make_unique<StringFieldChunkMetrics>(
min, max, nullptr, nullptr);
}
return std::make_unique<IntFieldChunkMetrics<T>>(
min, max, nullptr);
} }
BloomFilterPtr ngram_bloom_filter = BloomFilterPtr bloom_filter =
NewBloomFilterWithType(info.ngram_values_.size(), NewBloomFilterWithType(info.unique_values_.size(),
DEFAULT_BLOOM_FILTER_FALSE_POSITIVE_RATE, DEFAULT_BLOOM_FILTER_FALSE_POSITIVE_RATE,
BFType::Blocked); BFType::Blocked);
for (const auto& ngram : info.ngram_values_) { if constexpr (std::is_same_v<T, std::string>) {
ngram_bloom_filter->Add(std::string_view(ngram)); for (const auto& val : info.unique_values_) {
bloom_filter->Add(val);
}
if (info.ngram_values_.empty()) {
return std::make_unique<StringFieldChunkMetrics>(
min, max, std::move(bloom_filter), nullptr);
}
BloomFilterPtr ngram_bloom_filter = NewBloomFilterWithType(
info.ngram_values_.size(),
DEFAULT_BLOOM_FILTER_FALSE_POSITIVE_RATE,
BFType::Blocked);
for (const auto& ngram : info.ngram_values_) {
ngram_bloom_filter->Add(std::string_view(ngram));
}
return std::make_unique<StringFieldChunkMetrics>(
min,
max,
std::move(bloom_filter),
std::move(ngram_bloom_filter));
} }
return std::make_unique<StringFieldChunkMetrics>(
min,
max,
std::move(bloom_filter),
std::move(ngram_bloom_filter));
}
for (const auto& val : info.unique_values_) { for (const auto& val : info.unique_values_) {
bloom_filter->Add(reinterpret_cast<const uint8_t*>(&val), bloom_filter->Add(reinterpret_cast<const uint8_t*>(&val),
sizeof(val)); sizeof(val));
}
return std::make_unique<IntFieldChunkMetrics<T>>(
min, max, std::move(bloom_filter));
} }
return std::make_unique<IntFieldChunkMetrics<T>>(
min, max, std::move(bloom_filter));
} }
private: private: