Fix build problems

This commit is contained in:
Josip Mrden
2023-06-20 10:50:58 +02:00
parent 00fb8149b5
commit 58867362d6
3 changed files with 26 additions and 14 deletions

View File

@@ -727,18 +727,20 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor {
expression->MapTo(symbol);
auto unwind_operator = std::make_unique<Unwind>(input, prop_filter.value_, symbol);
auto index_stats = db_->GetIndexStats(GetLabel(found_index->label), GetProperty(prop_filter.property_));
if (index_stats) {
scope_.symbol_stats[node_symbol.name()] = SymbolStatistics{
.name = node_symbol.name(), .cardinality = index_stats->count, .degree = index_stats->avg_degree};
if (index_stats.has_value()) {
scope_.symbol_stats[node_symbol.name()] = SymbolStatistics{.name = node_symbol.name(),
.cardinality = index_stats.value().count,
.degree = index_stats.value().avg_degree};
}
return std::make_unique<ScanAllByLabelPropertyValue>(
std::move(unwind_operator), node_symbol, GetLabel(found_index->label), GetProperty(prop_filter.property_),
prop_filter.property_.name, expression, view);
} else if (prop_filter.type_ == PropertyFilter::Type::IS_NOT_NULL) {
auto index_stats = db_->GetIndexStats(GetLabel(found_index->label), GetProperty(prop_filter.property_));
if (index_stats) {
scope_.symbol_stats[node_symbol.name()] = SymbolStatistics{
.name = node_symbol.name(), .cardinality = index_stats->count, .degree = index_stats->avg_degree};
if (index_stats.has_value()) {
scope_.symbol_stats[node_symbol.name()] = SymbolStatistics{.name = node_symbol.name(),
.cardinality = index_stats.value().count,
.degree = index_stats.value().avg_degree};
}
return std::make_unique<ScanAllByLabelProperty>(input, node_symbol, GetLabel(found_index->label),
GetProperty(prop_filter.property_), prop_filter.property_.name,
@@ -746,9 +748,10 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor {
} else {
MG_ASSERT(prop_filter.value_, "Property filter should either have bounds or a value expression.");
auto index_stats = db_->GetIndexStats(GetLabel(found_index->label), GetProperty(prop_filter.property_));
if (index_stats) {
scope_.symbol_stats[node_symbol.name()] = SymbolStatistics{
.name = node_symbol.name(), .cardinality = index_stats->count, .degree = index_stats->avg_degree};
if (index_stats.has_value()) {
scope_.symbol_stats[node_symbol.name()] = SymbolStatistics{.name = node_symbol.name(),
.cardinality = index_stats.value().count,
.degree = index_stats.value().avg_degree};
}
return std::make_unique<ScanAllByLabelPropertyValue>(input, node_symbol, GetLabel(found_index->label),
GetProperty(prop_filter.property_),
@@ -767,9 +770,10 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor {
filters_.EraseLabelFilter(node_symbol, label, &removed_expressions);
filter_exprs_for_removal_.insert(removed_expressions.begin(), removed_expressions.end());
auto index_stats = db_->GetLabelIndexStats(GetLabel(label));
if (index_stats) {
scope_.symbol_stats[node_symbol.name()] = SymbolStatistics{
.name = node_symbol.name(), .cardinality = index_stats->count, .degree = index_stats->avg_degree};
if (index_stats.has_value()) {
scope_.symbol_stats[node_symbol.name()] = SymbolStatistics{.name = node_symbol.name(),
.cardinality = index_stats.value().count,
.degree = index_stats.value().avg_degree};
}
return std::make_unique<ScanAllByLabel>(input, node_symbol, GetLabel(label), view);
}

View File

@@ -218,6 +218,10 @@ class InteractiveDbAccessor {
return dba_->GetIndexStats(label, property);
}
std::optional<memgraph::storage::LabelIndexStats> GetLabelIndexStats(memgraph::storage::LabelId label) const {
return dba_->GetLabelIndexStats(label);
}
// Save the cached vertex counts to a stream.
void Save(std::ostream &out) {
out << "vertex-count " << vertices_count_ << std::endl;

View File

@@ -500,11 +500,15 @@ class FakeDbAccessor {
return false;
}
memgraph::storage::IndexStats GetIndexStats(memgraph::storage::LabelId label,
memgraph::storage::PropertyId property) const {
std::optional<memgraph::storage::IndexStats> GetIndexStats(memgraph::storage::LabelId label,
memgraph::storage::PropertyId property) const {
return memgraph::storage::IndexStats{.statistic = 0, .avg_group_size = 1}; // unique id
}
std::optional<memgraph::storage::LabelIndexStats> GetLabelIndexStats(memgraph::storage::LabelId label) const {
return memgraph::storage::LabelIndexStats{.count = 0, .avg_degree = 0}; // unique id
}
void SetIndexCount(memgraph::storage::LabelId label, int64_t count) { label_index_[label] = count; }
void SetIndexCount(memgraph::storage::LabelId label, memgraph::storage::PropertyId property, int64_t count) {