From 016fea734d09df707be9a16a4ad6a1107f41549f Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 27 Jun 2018 11:12:38 +0200 Subject: Fix pipelinetest + remove useless commented lines --- common/changereplay.cpp | 1 - common/storage.h | 4 ---- common/storage/entitystore.cpp | 16 ++++++---------- common/storage_common.cpp | 24 ------------------------ common/synchronizer.cpp | 2 +- common/utils.cpp | 1 - 6 files changed, 7 insertions(+), 41 deletions(-) (limited to 'common') diff --git a/common/changereplay.cpp b/common/changereplay.cpp index e94ed80..5817e8d 100644 --- a/common/changereplay.cpp +++ b/common/changereplay.cpp @@ -114,7 +114,6 @@ KAsync::Job ChangeReplay::replayNextRevision() if (uid.isEmpty() || type.isEmpty()) { SinkErrorCtx(mLogCtx) << "Failed to read uid or type for revison: " << revision << uid << type; } else { - //const auto key = DataStore::assembleKey(uid, revision); // TODO: should not use internal representations const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision).toInternalByteArray(); QByteArray entityBuffer; diff --git a/common/storage.h b/common/storage.h index 25d0fa6..8904148 100644 --- a/common/storage.h +++ b/common/storage.h @@ -239,10 +239,6 @@ public: static bool isInternalKey(void *key, int keySize); static bool isInternalKey(const QByteArray &key); - //static QByteArray assembleKey(const QByteArray &key, qint64 revision); - //static Identifier uidFromKey(const QByteArray &key); - //static qint64 revisionFromKey(const QByteArray &key); - static NamedDatabase mainDatabase(const Transaction &, const QByteArray &type); static QByteArray generateUid(); diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index efafe8a..d3420e4 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp @@ -371,8 +371,9 @@ void EntityStore::cleanupEntityRevisionsUntil(qint64 revision) return; } SinkTraceCtx(d->logCtx) << "Cleaning up revision " << revision << uid << bufferType; + const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); DataStore::mainDatabase(d->transaction, bufferType) - .scan(uid, + .scan(internalUid, [&](const QByteArray &key, const QByteArray &data) -> bool { EntityBuffer buffer(const_cast(data.data()), data.size()); if (!buffer.isValid()) { @@ -530,7 +531,6 @@ ApplicationDomain::ApplicationDomainType EntityStore::readLatest(const QByteArra return dt; } -// TODO: check every usage void EntityStore::readEntity(const QByteArray &type, const QByteArray &displayKey, const std::function callback) { const auto key = Key::fromDisplayByteArray(displayKey); @@ -598,7 +598,6 @@ void EntityStore::readPrevious(const QByteArray &type, const QByteArray &uid, qi const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); db.scan(internalUid, [&latestRevision, revision](const QByteArray &key, const QByteArray &) -> bool { - //const auto foundRevision = DataStore::revisionFromKey(key); const auto foundRevision = Key::fromInternalByteArray(key).revision().toQint64(); if (foundRevision < revision && foundRevision > latestRevision) { latestRevision = foundRevision; @@ -633,11 +632,7 @@ void EntityStore::readAllUids(const QByteArray &type, const std::functiongetTransaction(), type).contains(internalUid); } @@ -675,10 +670,11 @@ void EntityStore::readRevisions(const QByteArray &type, const QByteArray &uid, q { Q_ASSERT(d); Q_ASSERT(!uid.isEmpty()); + const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); DataStore::mainDatabase(d->transaction, type) - .scan(uid, + .scan(internalUid, [&](const QByteArray &key, const QByteArray &value) -> bool { - const auto parsedKey = Key::fromDisplayByteArray(key); + const auto parsedKey = Key::fromInternalByteArray(key); const auto revision = parsedKey.revision().toQint64(); if (revision >= startingRevision) { callback(parsedKey.identifier().toDisplayByteArray(), revision, Sink::EntityBuffer(value.data(), value.size())); diff --git a/common/storage_common.cpp b/common/storage_common.cpp index c922d9d..f96097a 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp @@ -24,8 +24,6 @@ #include "log.h" #include "utils.h" -#include - QDebug& operator<<(QDebug &dbg, const Sink::Storage::DataStore::Error &error) { dbg << error.message << "Code: " << error.code << "Db: " << error.store; @@ -38,8 +36,6 @@ namespace Storage { static const char *s_internalPrefix = "__internal"; static const int s_internalPrefixSize = strlen(s_internalPrefix); static const int s_lengthOfUid = 38; -// RFC 4122 Section 4.1.2 says 128 bits -> 16 bytes -//static const int s_lengthOfUid = 16; DbLayout::DbLayout() { @@ -198,26 +194,6 @@ bool DataStore::isInternalKey(const QByteArray &key) return key.startsWith(s_internalPrefix); } -/* -QByteArray DataStore::assembleKey(const QByteArray &key, qint64 revision) -{ - Q_ASSERT(revision <= 9223372036854775807); - Q_ASSERT(key.size() == s_lengthOfUid); - return key + QByteArray::number(revision).rightJustified(19, '0', false); -} - -//QByteArray DataStore::uidFromKey(const QByteArray &key) -Identifier DataStore::uidFromKey(const QByteArray &key) -{ - return Identifier::fromByteArray(key.mid(0, s_lengthOfUid)); -} - -qint64 DataStore::revisionFromKey(const QByteArray &key) -{ - return key.mid(s_lengthOfUid + 1).toLongLong(); -} -*/ - QByteArray DataStore::generateUid() { return createUuid(); diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index f19c08a..ffc7020 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -616,7 +616,7 @@ KAsync::Job Synchronizer::replay(const QByteArray &type, const QByteArray Q_ASSERT(mEntityStore->hasTransaction()); const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; - //const auto uid = Sink::Storage::DataStore::uidFromKey(key); + // TODO: should not use internal representations const auto uid = Sink::Storage::Key::fromDisplayByteArray(key).identifier().toDisplayByteArray(); const auto modifiedProperties = metadataBuffer->modifiedProperties() ? BufferUtils::fromVector(*metadataBuffer->modifiedProperties()) : QByteArrayList(); QByteArray oldRemoteId; diff --git a/common/utils.cpp b/common/utils.cpp index e98365c..3c54db4 100644 --- a/common/utils.cpp +++ b/common/utils.cpp @@ -22,5 +22,4 @@ QByteArray Sink::createUuid() { return QUuid::createUuid().toByteArray(); - //return QUuid::createUuid().toRfc4122(); } -- cgit v1.2.3