Skip to content

Commit

Permalink
Some more improvements...
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Kalmbach <[email protected]>
  • Loading branch information
joka921 committed Jan 20, 2025
1 parent ba013e8 commit 1136073
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/engine/QueryPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,6 @@ auto QueryPlanner::seedWithScansAndText(
vector<SubtreePlan>& seeds = result.plans_;
// add all child plans as seeds
uint64_t idShift = tg._nodeMap.size();
LOG(WARN) << "idShift is " << idShift << std::endl;
for (const auto& vec : children) {
AD_CONTRACT_CHECK(
idShift < 128,
Expand Down Expand Up @@ -1344,10 +1343,8 @@ size_t QueryPlanner::countSubgraphs(
// Remove duplicate plans from `graph`.
auto getId = [](const SubtreePlan* v) { return v->_idsOfIncludedNodes; };
ql::ranges::sort(graph, ql::ranges::less{}, getId);
LOG(INFO) << "graph size before pruning" << graph.size() << std::endl;
graph.erase(std::ranges::unique(graph, ql::ranges::equal_to{}, getId).begin(),
graph.end());
LOG(INFO) << "graph size after pruning" << graph.size() << std::endl;

// Qlever currently limits the number of triples etc. per group to be <= 64
// anyway, so we can simply assert here.
Expand Down
6 changes: 3 additions & 3 deletions src/engine/Values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ void Values::writeValues(IdTable* idTablePtr, LocalVocab* localVocab) {
rowIdx++;
}
AD_CORRECTNESS_CHECK(rowIdx == parsedValues_._values.size());
LOG(INFO) << "Number of tuples in VALUES clause: " << rowIdx << std::endl;
LOG(INFO) << "Number of entries in local vocabulary per column: "
<< absl::StrJoin(numLocalVocabPerColumn, ", ") << std::endl;
LOG(DEBUG) << "Number of tuples in VALUES clause: " << rowIdx << std::endl;
LOG(DEBUG) << "Number of entries in local vocabulary per column: "
<< absl::StrJoin(numLocalVocabPerColumn, ", ") << std::endl;
*idTablePtr = std::move(idTable).toDynamic();
}
35 changes: 35 additions & 0 deletions src/index/CompressedRelation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,36 @@ static auto getBeginAndEnd(auto& range) {
return std::pair{ql::ranges::begin(range), ql::ranges::end(range)};
}

// The first and the last block might be incomplete (that is, only
// a part of these blocks is actually part of the result,
// set up a lambda which allows us to read these blocks, and returns
// the size of the result.
static auto tripleInSpec =
[](const auto& scanSpec, const CompressedBlockMetadata::PermutedTriple& t) {
// TODO<joka921> Make this a free function, make this simpler
if (!scanSpec.col0Id().has_value()) {
return true;
}
if (scanSpec.col0Id().value() != t.col0Id_) {
return false;
}
if (!scanSpec.col1Id().has_value()) {
return true;
}
if (scanSpec.col1Id().value() != t.col1Id_) {
return false;
}
if (!scanSpec.col2Id().has_value()) {
return true;
}
if (scanSpec.col2Id().value() != t.col2Id_) {
return false;
}
// The unlikely case that there only is a single triple in the block and
// we query for this triple.
return true;
};

// modify the `block` according to the `limitOffset`. Also modify the
// `limitOffset` to reflect the parts of the LIMIT and OFFSET that have been
// performed by pruning this `block`.
Expand Down Expand Up @@ -1111,6 +1141,11 @@ auto CompressedRelationReader::getFirstAndLastTriple(
return {row[0], row[1], row[2], row[ADDITIONAL_COLUMN_GRAPH_ID]};
};

if (tripleInSpec(scanSpec, relevantBlocks.front().firstTriple_) &&
tripleInSpec(scanSpec, relevantBlocks.back().lastTriple_)) {
return ScanSpecAndBlocksAndBounds::FirstAndLastTriple{
relevantBlocks.front().firstTriple_, relevantBlocks.back().lastTriple_};
}
auto firstBlock = scanBlock(relevantBlocks.front());
auto lastBlock = scanBlock(relevantBlocks.back());
if (firstBlock.empty()) {
Expand Down

0 comments on commit 1136073

Please sign in to comment.