summaryrefslogtreecommitdiffstats
path: root/common/storage/entitystore.cpp
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2018-08-22 10:36:29 +0200
committerMinijackson <minijackson@riseup.net>2018-08-22 10:36:29 +0200
commit3559ec6e6e698f20e600dfbbdff0d56d66576c0d (patch)
tree0e44c41f0436520aac2f78c8a20b05ddb0b3beab /common/storage/entitystore.cpp
parentfc00461a517db33ca641e09a6987ed2d855729b3 (diff)
downloadsink-3559ec6e6e698f20e600dfbbdff0d56d66576c0d.tar.gz
sink-3559ec6e6e698f20e600dfbbdff0d56d66576c0d.zip
Re-do fullScan function and test it
Diffstat (limited to 'common/storage/entitystore.cpp')
-rw-r--r--common/storage/entitystore.cpp26
1 files changed, 4 insertions, 22 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp
index 7776bfc..250f01d 100644
--- a/common/storage/entitystore.cpp
+++ b/common/storage/entitystore.cpp
@@ -440,30 +440,12 @@ QVector<Identifier> EntityStore::fullScan(const QByteArray &type)
440 SinkTraceCtx(d->logCtx) << "Database is not existing: " << type; 440 SinkTraceCtx(d->logCtx) << "Database is not existing: " << type;
441 return {}; 441 return {};
442 } 442 }
443 //The scan can return duplicate results if we have multiple revisions, so we use a set to deduplicate.
444 QSet<Identifier> keys;
445 DataStore::mainDatabase(d->getTransaction(), type)
446 .scan(QByteArray(),
447 [&](const QByteArray &key, const QByteArray &data) -> bool {
448 EntityBuffer buffer(const_cast<const char *>(data.data()), data.size());
449 if (!buffer.isValid()) {
450 SinkWarningCtx(d->logCtx) << "Read invalid buffer from disk";
451 return true;
452 }
453 443
454 size_t revision = byteArrayToSizeT(key); 444 QSet<Identifier> keys;
455 445
456 const auto metadata = flatbuffers::GetRoot<Metadata>(buffer.metadataBuffer()); 446 DataStore::getUids(type, d->getTransaction(), [&keys] (const QByteArray &uid) {
457 const QByteArray uid = DataStore::getUidFromRevision(d->getTransaction(), revision); 447 keys << Identifier::fromDisplayByteArray(uid);
458 const auto identifier = Sink::Storage::Identifier::fromDisplayByteArray(uid); 448 });
459 if (keys.contains(identifier)) {
460 //Not something that should persist if the replay works, so we keep a message for now.
461 SinkTraceCtx(d->logCtx) << "Multiple revisions for uid: " << Sink::Storage::Key::fromInternalByteArray(key) << ". This is normal if changereplay has not completed yet.";
462 }
463 keys << identifier;
464 return true;
465 },
466 [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Error during fullScan query: " << error.message; });
467 449
468 SinkTraceCtx(d->logCtx) << "Full scan retrieved " << keys.size() << " results."; 450 SinkTraceCtx(d->logCtx) << "Full scan retrieved " << keys.size() << " results.";
469 return keys.toList().toVector(); 451 return keys.toList().toVector();