Skip to content

Commit

Permalink
DeltaTriples
Browse files Browse the repository at this point in the history
  • Loading branch information
Qup42 committed Jun 21, 2024
1 parent 940f52a commit 8e86de6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions src/index/DeltaTriples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ void DeltaTriples::insertTriples(
std::erase_if(triples, [this](const IdTriple& triple) {
return triplesInserted_.contains(triple);
});
std::erase_if(triples, [this](const IdTriple triple) {
bool isPresent = triplesDeleted_.contains(triple);
if (isPresent) {
eraseTripleInAllPermutations(triplesDeleted_.at(triple));
std::ranges::for_each(triples, [this](const IdTriple& triple) {
auto handle = triplesDeleted_.find(triple);
if (handle != triplesDeleted_.end()) {
eraseTripleInAllPermutations(handle->second);
triplesDeleted_.erase(triple);
}
return isPresent;
});

LOG(INFO) << "Inserting " << triples.size() << " triples." << std::endl;
Expand All @@ -121,13 +120,12 @@ void DeltaTriples::deleteTriples(
std::erase_if(triples, [this](const IdTriple& triple) {
return triplesDeleted_.contains(triple);
});
std::erase_if(triples, [this](const IdTriple triple) {
bool isPresent = triplesInserted_.contains(triple);
if (isPresent) {
eraseTripleInAllPermutations(triplesInserted_.at(triple));
std::ranges::for_each(triples, [this](const IdTriple& triple) {
auto handle = triplesInserted_.find(triple);
if (handle != triplesInserted_.end()) {
eraseTripleInAllPermutations(handle->second);
triplesInserted_.erase(triple);
}
return isPresent;
});

LOG(INFO) << "Deleting " << triples.size() << " triples." << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/index/DeltaTriples.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ class DeltaTriples {
size_t numInserted() const { return triplesInserted_.size(); }
size_t numDeleted() const { return triplesDeleted_.size(); }

// Insert triple.
// Insert triple. Must not contain duplicates.
void insertTriples(ad_utility::SharedCancellationHandle cancellationHandle,
std::vector<IdTriple> triples);

// Delete triple.
// Delete triple. Must not contain duplicates.
void deleteTriples(ad_utility::SharedCancellationHandle cancellationHandle,
std::vector<IdTriple> triples);

Expand Down

0 comments on commit 8e86de6

Please sign in to comment.