Skip to content

Commit

Permalink
Format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JoBuRo committed Jun 24, 2024
1 parent 2451fd7 commit d700df2
Show file tree
Hide file tree
Showing 25 changed files with 1,001 additions and 688 deletions.
34 changes: 18 additions & 16 deletions src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
add_subdirectory(sparqlExpressions)
add_library(SortPerformanceEstimator SortPerformanceEstimator.cpp)
qlever_target_link_libraries(SortPerformanceEstimator)
add_library(engine
Engine.cpp QueryExecutionTree.cpp Operation.cpp Result.cpp LocalVocab.cpp
IndexScan.cpp Join.cpp Sort.cpp
Distinct.cpp OrderBy.cpp Filter.cpp
Server.cpp QueryPlanner.cpp QueryPlanningCostFactors.cpp
OptionalJoin.cpp CountAvailablePredicates.cpp GroupBy.cpp HasPredicateScan.cpp
Union.cpp MultiColumnJoin.cpp TransitivePathBase.cpp
TransitivePathHashMap.cpp TransitivePathBinSearch.cpp Service.cpp
Values.cpp Bind.cpp Minus.cpp RuntimeInformation.cpp CheckUsePatternTrick.cpp
VariableToColumnMap.cpp ExportQueryExecutionTrees.cpp
CartesianProductJoin.cpp TextIndexScanForWord.cpp TextIndexScanForEntity.cpp
TextLimit.cpp
idTable/CompressedExternalIdTable.h PathSearch.cpp)
qlever_target_link_libraries(engine util index parser sparqlExpressions http SortPerformanceEstimator Boost::iostreams)
add_library(SortPerformanceEstimator SortPerformanceEstimator.cpp)
qlever_target_link_libraries(SortPerformanceEstimator) add_library(
engine Engine.cpp QueryExecutionTree.cpp Operation.cpp Result
.cpp LocalVocab.cpp IndexScan.cpp Join.cpp Sort.cpp Distinct
.cpp OrderBy.cpp Filter.cpp Server.cpp QueryPlanner
.cpp QueryPlanningCostFactors.cpp OptionalJoin
.cpp CountAvailablePredicates.cpp GroupBy.cpp HasPredicateScan
.cpp Union.cpp MultiColumnJoin.cpp TransitivePathBase
.cpp TransitivePathHashMap.cpp TransitivePathBinSearch
.cpp Service.cpp Values.cpp Bind.cpp Minus
.cpp RuntimeInformation.cpp CheckUsePatternTrick
.cpp VariableToColumnMap.cpp ExportQueryExecutionTrees
.cpp CartesianProductJoin.cpp TextIndexScanForWord
.cpp TextIndexScanForEntity.cpp TextLimit.cpp idTable /
CompressedExternalIdTable.h PathSearch.cpp)
qlever_target_link_libraries(
engine util index parser sparqlExpressions http
SortPerformanceEstimator Boost::iostreams)
5 changes: 2 additions & 3 deletions src/engine/GroupByHashMapOptimization.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
static constexpr auto valueAdder = []() {
auto numericValueAdder =
[]<typename T>(T value, double& sum, [[maybe_unused]] const bool& error)
requires std::is_arithmetic_v<T> {
sum += static_cast<double>(value);
};
requires std::is_arithmetic_v<T>
{ sum += static_cast<double>(value); };
auto nonNumericValueAdder = [](sparqlExpression::detail::NotNumeric,
[[maybe_unused]] const double& sum,
bool& error) { error = true; };
Expand Down
16 changes: 9 additions & 7 deletions src/engine/PathSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ PathSearch::PathSearch(QueryExecutionContext* qec,
variableColumns_[config_.pathColumn_] = makeAlwaysDefinedColumn(2);
variableColumns_[config_.edgeColumn_] = makeAlwaysDefinedColumn(3);

for (size_t edgePropertyIndex = 0; edgePropertyIndex < config_.edgeProperties_.size(); edgePropertyIndex++) {
for (size_t edgePropertyIndex = 0;
edgePropertyIndex < config_.edgeProperties_.size();
edgePropertyIndex++) {
auto edgeProperty = config_.edgeProperties_[edgePropertyIndex];
variableColumns_[edgeProperty] = makeAlwaysDefinedColumn(4 + edgePropertyIndex);
variableColumns_[edgeProperty] =
makeAlwaysDefinedColumn(4 + edgePropertyIndex);
}
}

Expand Down Expand Up @@ -101,16 +104,15 @@ Result PathSearch::computeResult([[maybe_unused]] bool requestLaziness) {
edgePropertyLists.push_back(dynSub.getColumn(edgePropertyIndex));
}


auto subStartColumn = subtree_->getVariableColumn(config_.start_);
auto subEndColumn = subtree_->getVariableColumn(config_.end_);
buildGraph(dynSub.getColumn(subStartColumn),
dynSub.getColumn(subEndColumn), edgePropertyLists);
buildGraph(dynSub.getColumn(subStartColumn), dynSub.getColumn(subEndColumn),
edgePropertyLists);

auto paths = findPaths();

CALL_FIXED_SIZE(std::array{getResultWidth()}, &PathSearch::pathsToResultTable,
this, idTable, paths);
CALL_FIXED_SIZE(std::array{getResultWidth()},
&PathSearch::pathsToResultTable, this, idTable, paths);
}

return {std::move(idTable), resultSortedOn(), subRes->getSharedLocalVocab()};
Expand Down
29 changes: 18 additions & 11 deletions src/engine/PathSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <vector>

#include "engine/Operation.h"
#include "engine/VariableToColumnMap.h"
#include "engine/PathSearchVisitors.h"
#include "engine/VariableToColumnMap.h"
#include "global/Id.h"
#include "index/Vocabulary.h"

Expand All @@ -36,15 +36,15 @@ struct PathSearchConfiguration {
// The source node ID.
Id source_;
// A list of target node IDs.
std::vector<Id> targets_;
std::vector<Id> targets_;
// Variable representing the start column in the result.
Variable start_;
Variable start_;
// Variable representing the end column in the result.
Variable end_;
Variable end_;
// Variable representing the path column in the result.
Variable pathColumn_;
Variable pathColumn_;
// Variable representing the edge column in the result.
Variable edgeColumn_;
Variable edgeColumn_;
// Variables representing edge property columns.
std::vector<Variable> edgeProperties_;
};
Expand Down Expand Up @@ -78,11 +78,18 @@ class PathSearch : public Operation {

const PathSearchConfiguration& getConfig() const { return config_; }

ColumnIndex getStartIndex() const { return variableColumns_.at(config_.start_).columnIndex_; }
ColumnIndex getEndIndex() const { return variableColumns_.at(config_.end_).columnIndex_; }
ColumnIndex getPathIndex() const { return variableColumns_.at(config_.pathColumn_).columnIndex_; }
ColumnIndex getEdgeIndex() const { return variableColumns_.at(config_.edgeColumn_).columnIndex_; }

ColumnIndex getStartIndex() const {
return variableColumns_.at(config_.start_).columnIndex_;
}
ColumnIndex getEndIndex() const {
return variableColumns_.at(config_.end_).columnIndex_;
}
ColumnIndex getPathIndex() const {
return variableColumns_.at(config_.pathColumn_).columnIndex_;
}
ColumnIndex getEdgeIndex() const {
return variableColumns_.at(config_.edgeColumn_).columnIndex_;
}

string getCacheKeyImpl() const override;
string getDescriptor() const override;
Expand Down
15 changes: 9 additions & 6 deletions src/engine/PathSearchVisitors.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

#pragma once

#include <optional>
#include <algorithm>

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/graph_selectors.hpp>
#include <boost/graph/graph_traits.hpp>
#include <optional>

/**
* @brief Represents an edge in the graph.
Expand Down Expand Up @@ -143,7 +142,8 @@ class AllPathsVisitor : public boost::default_dfs_visitor {
*/
void examine_edge(EdgeDescriptor edgeDesc, const Graph& graph) {
const Edge& edge = graph[edgeDesc];
if (targets_.empty() || (currentPath_.ends_with(edge.start_) && targets_.find(edge.end_) != targets_.end())) {
if (targets_.empty() || (currentPath_.ends_with(edge.start_) &&
targets_.find(edge.end_) != targets_.end())) {
auto pathCopy = currentPath_;
pathCopy.push_back(edge);
allPaths_.push_back(pathCopy);
Expand All @@ -161,20 +161,23 @@ class AllPathsVisitor : public boost::default_dfs_visitor {
}

/**
* @brief Called when a vertex has been finished during the depth-first search.
* @brief Called when a vertex has been finished during the depth-first
* search.
* @param vertex The descriptor of the vertex being finished.
* @param graph The graph being searched.
*/
void finish_vertex(VertexDescriptor vertex, const Graph& graph) {
(void)graph;
if (!currentPath_.empty() && Id::fromBits(currentPath_.lastNode().value()) == indexToId_[vertex]) {
if (!currentPath_.empty() &&
Id::fromBits(currentPath_.lastNode().value()) == indexToId_[vertex]) {
currentPath_.edges_.pop_back();
}
}
};

/**
* @brief Visitor for performing Dijkstra's algorithm to find all shortest paths.
* @brief Visitor for performing Dijkstra's algorithm to find all shortest
* paths.
*/
class DijkstraAllPathsVisitor : public boost::default_dijkstra_visitor {
// The source vertex descriptor.
Expand Down
24 changes: 12 additions & 12 deletions src/engine/QueryPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2124,22 +2124,22 @@ void QueryPlanner::GraphPatternPlanner::visitPathSearch(
};
auto source = tripleComponentToId(pathQuery.source_);
std::vector<Id> targets;
for (auto comp: pathQuery.targets_) {
for (auto comp : pathQuery.targets_) {
targets.push_back(tripleComponentToId(comp));
}
auto config = PathSearchConfiguration{
pathQuery.algorithm_,
std::move(source),
std::move(targets),
std::move(pathQuery.start_.value()),
std::move(pathQuery.end_.value()),
std::move(pathQuery.pathColumn_.value()),
std::move(pathQuery.edgeColumn_.value()),
std::move(pathQuery.edgeProperties_)
};
auto config =
PathSearchConfiguration{pathQuery.algorithm_,
std::move(source),
std::move(targets),
std::move(pathQuery.start_.value()),
std::move(pathQuery.end_.value()),
std::move(pathQuery.pathColumn_.value()),
std::move(pathQuery.edgeColumn_.value()),
std::move(pathQuery.edgeProperties_)};

for (auto& sub : candidatesIn) {
auto pathSearch = std::make_shared<PathSearch>(PathSearch(qec_, std::move(sub._qet), config));
auto pathSearch = std::make_shared<PathSearch>(
PathSearch(qec_, std::move(sub._qet), config));
auto plan = makeSubtreePlan<PathSearch>(std::move(pathSearch));
candidatesOut.push_back(std::move(plan));
}
Expand Down
6 changes: 3 additions & 3 deletions src/engine/idTable/IdTableRow.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ class RowReferenceImpl {
}

// Assignment from a `const` RowReference to a `mutable` RowReference
This& operator=(const RowReferenceWithRestrictedAccess<
Table, ad_utility::IsConst::True>& other) &&
requires(!isConst) {
This& operator=(
const RowReferenceWithRestrictedAccess<
Table, ad_utility::IsConst::True>& other) && requires(!isConst) {
return assignmentImpl(*this, other);
}

Expand Down
2 changes: 0 additions & 2 deletions src/engine/raw_thoughts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,3 @@ I don't see a problem why it couldn't also be a parameter per context variable.
HARDER THAN BROCCOLI:
cross product with contexts
cross product (not full) with co-occurring n-tuples of entities (?x ?y ?z - see graphs above).


31 changes: 10 additions & 21 deletions src/engine/sparqlExpressions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
add_library(sparqlExpressions
SparqlExpressionValueGetters.cpp
NaryExpression.cpp
SetOfIntervals.cpp
SparqlExpressionPimpl.cpp
SampleExpression.cpp
RelationalExpressions.cpp
AggregateExpression.cpp
RegexExpression.cpp
LangExpression.cpp
NumericUnaryExpressions.cpp
NumericBinaryExpressions.cpp
DateExpressions.cpp
StringExpressions.cpp
IsSomethingExpressions.cpp
ConditionalExpressions.cpp
SparqlExpressionTypes.cpp
SparqlExpression.cpp
ConvertToNumericExpression.cpp
RdfTermExpressions.cpp)
add_library(
sparqlExpressions SparqlExpressionValueGetters.cpp NaryExpression
.cpp SetOfIntervals.cpp SparqlExpressionPimpl.cpp SampleExpression
.cpp RelationalExpressions.cpp AggregateExpression.cpp RegexExpression
.cpp LangExpression.cpp NumericUnaryExpressions
.cpp NumericBinaryExpressions.cpp DateExpressions.cpp StringExpressions
.cpp IsSomethingExpressions.cpp ConditionalExpressions
.cpp SparqlExpressionTypes.cpp SparqlExpression
.cpp ConvertToNumericExpression.cpp RdfTermExpressions.cpp)

qlever_target_link_libraries(sparqlExpressions util index Boost::url)
qlever_target_link_libraries(sparqlExpressions util index Boost::url)
68 changes: 34 additions & 34 deletions src/engine/sparqlExpressions/ConditionalExpressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,35 +66,36 @@ class CoalesceExpression : public VariadicExpression {

auto visitConstantExpressionResult =
[&nextUnboundIndices, &unboundIndices, &isUnbound, &result,
ctx ]<SingleExpressionResult T>(T && childResult)
ctx]<SingleExpressionResult T>(T&& childResult)
requires isConstantResult<T> {
IdOrLiteralOrIri constantResult{AD_FWD(childResult)};
if (isUnbound(constantResult)) {
nextUnboundIndices = std::move(unboundIndices);
return;
}
ad_utility::chunkedForLoop<CHUNK_SIZE>(
0, unboundIndices.size(),
[&unboundIndices, &result, &constantResult](size_t idx) {
// GCC 12 & 13 report this as potential uninitialized
// use of a variable when compiling with -O3, which seems to
// be a false positive, so we suppress the warning here. See
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109561 for
// more information.
DISABLE_UNINITIALIZED_WARNINGS
result[unboundIndices[idx]] = constantResult;
},
[ctx]() { ctx->cancellationHandle_->throwIfCancelled(); });
};
IdOrLiteralOrIri constantResult{AD_FWD(childResult)};
if (isUnbound(constantResult)) {
nextUnboundIndices = std::move(unboundIndices);
return;
}
ad_utility::chunkedForLoop<CHUNK_SIZE>(
0, unboundIndices.size(),
[&unboundIndices, &result, &constantResult](size_t idx) {
// GCC 12 & 13 report this as potential uninitialized
// use of a variable when compiling with -O3, which seems to
// be a false positive, so we suppress the warning here. See
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109561 for
// more information.
DISABLE_UNINITIALIZED_WARNINGS
result[unboundIndices[idx]] = constantResult;
},
[ctx]() { ctx->cancellationHandle_->throwIfCancelled(); });
};
ENABLE_UNINITIALIZED_WARNINGS

// For a single child result, write the result at the indices where the
// result so far is unbound, and the child result is bound. While doing so,
// set up the `nextUnboundIndices` vector for the next step.
auto visitVectorExpressionResult =
[&result, &unboundIndices, &nextUnboundIndices, &ctx, &
isUnbound ]<SingleExpressionResult T>(T && childResult)
requires std::is_rvalue_reference_v<T&&> {
[&result, &unboundIndices, &nextUnboundIndices, &ctx,
&isUnbound]<SingleExpressionResult T>(T&& childResult)
requires std::is_rvalue_reference_v<T&&>
{
static_assert(!isConstantResult<T>);
auto gen = detail::makeGenerator(AD_FWD(childResult), ctx->size(), ctx);
// Iterator to the next index where the result so far is unbound.
Expand Down Expand Up @@ -126,18 +127,17 @@ class CoalesceExpression : public VariadicExpression {
[ctx]() { ctx->cancellationHandle_->throwIfCancelled(); });
};
auto visitExpressionResult =
[
&visitConstantExpressionResult, &visitVectorExpressionResult
]<SingleExpressionResult T>(T && childResult)
requires std::is_rvalue_reference_v<T&&> {
// If the previous expression result is a constant, we can skip the
// loop.
if constexpr (isConstantResult<T>) {
visitConstantExpressionResult(AD_FWD(childResult));
} else {
visitVectorExpressionResult(AD_FWD(childResult));
}
};
[&visitConstantExpressionResult,
&visitVectorExpressionResult]<SingleExpressionResult T>(
T&& childResult) requires std::is_rvalue_reference_v<T&&> {
// If the previous expression result is a constant, we can skip the
// loop.
if constexpr (isConstantResult<T>) {
visitConstantExpressionResult(AD_FWD(childResult));
} else {
visitVectorExpressionResult(AD_FWD(childResult));
}
};

// Evaluate the children one by one, stopping as soon as all result are
// bound.
Expand Down
Loading

0 comments on commit d700df2

Please sign in to comment.