Skip to content

Commit

Permalink
Initial stuff, TODO: fix this.
Browse files Browse the repository at this point in the history
  • Loading branch information
joka921 committed Apr 17, 2024
1 parent 08ca01b commit fb85d67
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/engine/TransitivePathBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ struct TransitivePathSide {
os << "Id: " << std::get<Id>(value_);
}

os << ", subColumn: " << subCol_ << "to " << outputCol_;
os << ", subColumn: " <<
subCol_ << "to " << outputCol_;

if (treeAndCol_.has_value()) {
const auto& [tree, col] = treeAndCol_.value();
Expand Down Expand Up @@ -266,7 +267,7 @@ class TransitivePathBase : public Operation {

// The internal implementation of `bindLeftSide` and `bindRightSide` which
// share a lot of code.
std::shared_ptr<TransitivePathBase> bindLeftOrRightSide(
virtual std::shared_ptr<TransitivePathBase> bindLeftOrRightSide(
std::shared_ptr<QueryExecutionTree> leftOrRightOp, size_t inputCol,
bool isLeft) const;
};
12 changes: 12 additions & 0 deletions src/engine/TransitivePathBinSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ TransitivePathBinSearch::TransitivePathBinSearch(
std::move(leftSide),
std::move(rightSide), minDist, maxDist) {
auto [startSide, targetSide] = decideDirection();
alternativelySortedSubtree_ = QueryExecutionTree::createSortedTree(
subtree_, {targetSide.subCol_, targetSide.subCol_});
subtree_ = QueryExecutionTree::createSortedTree(
subtree_, {startSide.subCol_, targetSide.subCol_});
}
Expand All @@ -29,3 +31,13 @@ BinSearchMap TransitivePathBinSearch::setupEdgesMap(
return BinSearchMap{dynSub.getColumn(startSide.subCol_),
dynSub.getColumn(targetSide.subCol_)};
}

// _____________________________________________________________________________
std::vector<ColumnIndex> TransitivePathBinSearch::resultSortedOn() const {
if (!isBoundOrId()) {
AD_CORRECTNESS_CHECK(subtree_);
return {subtree_->resultSortedOn().at(1)};
} else {
return TransitivePathBase::resultSortedOn();
}
}
10 changes: 10 additions & 0 deletions src/engine/TransitivePathBinSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,19 @@ class TransitivePathBinSearch : public TransitivePathImpl<BinSearchMap> {
TransitivePathSide rightSide, size_t minDist,
size_t maxDist);


std::vector<ColumnIndex> resultSortedOn() const override;

// TODO<joka921> Overwrite s.t. we can do this with the alternative subtree.
virtual std::shared_ptr<TransitivePathBase> bindLeftOrRightSide(
std::shared_ptr<QueryExecutionTree> leftOrRightOp, size_t inputCol,
bool isLeft) const;

private:
// initialize the map from the subresult
BinSearchMap setupEdgesMap(
const IdTable& dynSub, const TransitivePathSide& startSide,
const TransitivePathSide& targetSide) const override;

std::shared_ptr<QueryExecutionTree> alternativelySortedSubtree_;
};
7 changes: 4 additions & 3 deletions test/QueryPlannerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,10 @@ TEST(QueryPlanner, TransitivePathBindRight) {
h::TransitivePath(
left, right, 0, std::numeric_limits<size_t>::max(),
scan("?y", "<p>", "<o>"),
// TODO<joka921> Get rid of this sort operation
h::Sort(scan("?_qlever_internal_variable_query_planner_0", "<p>",
"?_qlever_internal_variable_query_planner_1"))));
scan("?_qlever_internal_variable_query_planner_0", "<p>",
"?_qlever_internal_variable_query_planner_1")),
ad_utility::testing::getQec("<x> <p> <o>. <x2> <p> <o2>")
);
}

// __________________________________________________________________________
Expand Down

0 comments on commit fb85d67

Please sign in to comment.