Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/merge-located-triples' into merg…
Browse files Browse the repository at this point in the history
…e-located-triples

# Conflicts:
#	src/engine/Join.cpp
  • Loading branch information
joka921 committed Nov 13, 2024
2 parents b1ba5a2 + d29b1af commit d3bc26e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
6 changes: 2 additions & 4 deletions src/engine/Join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,19 +567,17 @@ void updateRuntimeInfoForLazyScan(
rti.addDetail("num-blocks-all", metadata.numBlocksAll_);
rti.addDetail("num-elements-read", metadata.numElementsRead_);

// Add the pair of `(key, value)` to the runtime info, but only if `value >
// 0`.
// Add more details, but only if the respective value is non-zero.
auto updateIfPositive = [&rti](const auto& value, const std::string& key) {
if (value > 0) {
rti.addDetail(key, value);
}
};

updateIfPositive(metadata.numBlocksSkippedBecauseOfGraph_,
"num-blocks-skipped-graph");
updateIfPositive(metadata.numBlocksPostprocessed_,
"num-blocks-postprocessed");
updateIfPositive(metadata.numBlocksWithUpdate_, "num-blocks-with-updateu");
updateIfPositive(metadata.numBlocksWithUpdate_, "num-blocks-with-update");
}
} // namespace

Expand Down
6 changes: 3 additions & 3 deletions src/index/CompressedRelation.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ class CompressedRelationReader {
size_t numElementsYielded_ = 0;
std::chrono::milliseconds blockingTime_ = std::chrono::milliseconds::zero();

// Update `*this` s.t. it contains the metadata from `blockAndMetadata`.
// This function currently updates `numBlocksPostprocessed_`,
// `numBlokcsWithUpdate_`, `numElementsRead_`, and `numBlocksRead_`.
// Update this metadata, given the metadata from `blockAndMetadata`.
// Currently updates: `numBlocksPostprocessed_`, `numBlocksWithUpdate_`,
// `numElementsRead_`, and `numBlocksRead_`.
void update(const DecompressedBlockAndMetadata& blockAndMetadata);
// `nullopt` means the block was skipped because of the graph filters, else
// call the overload directly above.
Expand Down
8 changes: 4 additions & 4 deletions src/index/LocatedTriples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ std::ostream& operator<<(std::ostream& os, const std::vector<IdTriple<0>>& v) {
}

// ____________________________________________________________________________
bool LocatedTriplesPerBlock::containsTriple(const IdTriple<0>& triple,
bool shouldExist) const {
auto blockContains = [&triple, shouldExist](const LocatedTriples& lt,
bool LocatedTriplesPerBlock::isLocatedTriple(const IdTriple<0>& triple,
bool isInsertion) const {
auto blockContains = [&triple, isInsertion](const LocatedTriples& lt,
size_t blockIndex) {
LocatedTriple locatedTriple{blockIndex, triple, shouldExist};
LocatedTriple locatedTriple{blockIndex, triple, isInsertion};
locatedTriple.blockIndex_ = blockIndex;
return ad_utility::contains(lt, locatedTriple);
};
Expand Down
8 changes: 5 additions & 3 deletions src/index/LocatedTriples.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ class LocatedTriplesPerBlock {
augmentedMetadata_ = originalMetadata_;
}

// Only used for testing. Return `true` iff a `LocatedTriple` with the given
// value for `shouldExist` is contained in any block.
bool containsTriple(const IdTriple<0>& triple, bool shouldExist) const;
// Return `true` iff the given triple is one of the located triples with the
// given status (inserted or deleted).
//
// NOTE: Only used for testing.
bool isLocatedTriple(const IdTriple<0>& triple, bool isInsertion) const;

// This operator is only for debugging and testing. It returns a
// human-readable representation.
Expand Down
21 changes: 12 additions & 9 deletions test/DeltaTriplesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,15 @@ TEST_F(DeltaTriplesTest, DeltaTriplesManager) {
// or deleted (`false`).
const auto& locatedSPO =
beforeUpdate->getLocatedTriplesForPermutation(Permutation::SPO);
EXPECT_FALSE(locatedSPO.containsTriple(triplesToInsert.at(1), true));
EXPECT_FALSE(locatedSPO.containsTriple(triplesToInsert.at(1), false));
EXPECT_FALSE(locatedSPO.containsTriple(triplesToInsert.at(2), true));
EXPECT_FALSE(locatedSPO.containsTriple(triplesToInsert.at(2), false));
EXPECT_FALSE(locatedSPO.containsTriple(triplesToDelete.at(2), true));
EXPECT_FALSE(locatedSPO.containsTriple(triplesToDelete.at(2), false));
EXPECT_FALSE(locatedSPO.isLocatedTriple(triplesToInsert.at(1), true));
EXPECT_FALSE(
locatedSPO.isLocatedTriple(triplesToInsert.at(1), false));
EXPECT_FALSE(locatedSPO.isLocatedTriple(triplesToInsert.at(2), true));
EXPECT_FALSE(
locatedSPO.isLocatedTriple(triplesToInsert.at(2), false));
EXPECT_FALSE(locatedSPO.isLocatedTriple(triplesToDelete.at(2), true));
EXPECT_FALSE(
locatedSPO.isLocatedTriple(triplesToDelete.at(2), false));
}
{
// Check for several of the thread-exclusive triples that they are
Expand All @@ -385,13 +388,13 @@ TEST_F(DeltaTriplesTest, DeltaTriplesManager) {
auto p = deltaTriplesManager.getCurrentSnapshot();
const auto& locatedSPO =
p->getLocatedTriplesForPermutation(Permutation::SPO);
EXPECT_TRUE(locatedSPO.containsTriple(triplesToInsert.at(1), true));
EXPECT_TRUE(locatedSPO.isLocatedTriple(triplesToInsert.at(1), true));
// This triple is exclusive to the thread and is inserted and then
// immediately deleted again. The `DeltaTriples` thus only store it
// as deleted. It might be contained in the original input, hence we
// cannot simply drop it.
EXPECT_TRUE(locatedSPO.containsTriple(triplesToInsert.at(2), false));
EXPECT_TRUE(locatedSPO.containsTriple(triplesToDelete.at(2), false));
EXPECT_TRUE(locatedSPO.isLocatedTriple(triplesToInsert.at(2), false));
EXPECT_TRUE(locatedSPO.isLocatedTriple(triplesToDelete.at(2), false));
}
}
}
Expand Down

0 comments on commit d3bc26e

Please sign in to comment.