Fix bounds
This commit is contained in:
parent
65e9ceb779
commit
a20edf2b74
@ -676,23 +676,33 @@ int64_t LabelPropertyIndex::VertexCount(LabelId label, PropertyId property,
|
|||||||
const std::optional<utils::Bound<PropertyValue>> &upper) const {
|
const std::optional<utils::Bound<PropertyValue>> &upper) const {
|
||||||
auto it = index_.find({label, property});
|
auto it = index_.find({label, property});
|
||||||
MG_ASSERT(it != index_.end(), "Index for label {} and property {} doesn't exist", label.AsUint(), property.AsUint());
|
MG_ASSERT(it != index_.end(), "Index for label {} and property {} doesn't exist", label.AsUint(), property.AsUint());
|
||||||
const auto get_iter = [&it](const auto &value, const auto def) {
|
const auto lower_it = std::invoke(
|
||||||
if (value) {
|
[&index = it->second](const auto value, const auto def) {
|
||||||
auto found_it = it->second.find(value->value());
|
if (value) {
|
||||||
if (value->IsInclusive()) {
|
if (value->IsInclusive()) {
|
||||||
return found_it;
|
return index.lower_bound(value->value());
|
||||||
}
|
}
|
||||||
return found_it != it->second.end() ? ++found_it : found_it;
|
return index.upper_bound(value->value());
|
||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
};
|
},
|
||||||
const auto lower_it = get_iter(lower, it->second.begin());
|
lower, it->second.begin());
|
||||||
const auto upper_it = get_iter(upper, it->second.end());
|
const auto upper_it = std::invoke(
|
||||||
|
[&index = it->second](const auto value, const auto def) {
|
||||||
|
if (value) {
|
||||||
|
if (value->IsInclusive()) {
|
||||||
|
return index.upper_bound(value->value());
|
||||||
|
}
|
||||||
|
return index.lower_bound(value->value());
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
},
|
||||||
|
upper, it->second.end());
|
||||||
return static_cast<int64_t>(std::distance(lower_it, upper_it));
|
return static_cast<int64_t>(std::distance(lower_it, upper_it));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelPropertyIndex::RunGC() {
|
void LabelPropertyIndex::RunGC() {
|
||||||
// TODO What to do?
|
// TODO(jbajic) What to do?
|
||||||
// for (auto &index_entry : index_) {
|
// for (auto &index_entry : index_) {
|
||||||
// index_entry.second.run_gc();
|
// index_entry.second.run_gc();
|
||||||
// }
|
// }
|
||||||
|
Loading…
Reference in New Issue
Block a user