From 3559ec6e6e698f20e600dfbbdff0d56d66576c0d Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 22 Aug 2018 10:36:29 +0200 Subject: Re-do fullScan function and test it --- common/storage/entitystore.cpp | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'common/storage') 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 EntityStore::fullScan(const QByteArray &type) SinkTraceCtx(d->logCtx) << "Database is not existing: " << type; return {}; } - //The scan can return duplicate results if we have multiple revisions, so we use a set to deduplicate. - QSet keys; - DataStore::mainDatabase(d->getTransaction(), type) - .scan(QByteArray(), - [&](const QByteArray &key, const QByteArray &data) -> bool { - EntityBuffer buffer(const_cast(data.data()), data.size()); - if (!buffer.isValid()) { - SinkWarningCtx(d->logCtx) << "Read invalid buffer from disk"; - return true; - } - size_t revision = byteArrayToSizeT(key); + QSet keys; - const auto metadata = flatbuffers::GetRoot(buffer.metadataBuffer()); - const QByteArray uid = DataStore::getUidFromRevision(d->getTransaction(), revision); - const auto identifier = Sink::Storage::Identifier::fromDisplayByteArray(uid); - if (keys.contains(identifier)) { - //Not something that should persist if the replay works, so we keep a message for now. - SinkTraceCtx(d->logCtx) << "Multiple revisions for uid: " << Sink::Storage::Key::fromInternalByteArray(key) << ". This is normal if changereplay has not completed yet."; - } - keys << identifier; - return true; - }, - [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Error during fullScan query: " << error.message; }); + DataStore::getUids(type, d->getTransaction(), [&keys] (const QByteArray &uid) { + keys << Identifier::fromDisplayByteArray(uid); + }); SinkTraceCtx(d->logCtx) << "Full scan retrieved " << keys.size() << " results."; return keys.toList().toVector(); -- cgit v1.2.3