diff options
author | Minijackson <minijackson@riseup.net> | 2018-06-27 11:12:38 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-07-04 15:37:14 +0200 |
commit | 016fea734d09df707be9a16a4ad6a1107f41549f (patch) | |
tree | 60bf9767842713538505fca80515a8f5e59ca985 /common | |
parent | c90ba4a98292a39eb0b3df12fd7e2dec0300e58d (diff) | |
download | sink-016fea734d09df707be9a16a4ad6a1107f41549f.tar.gz sink-016fea734d09df707be9a16a4ad6a1107f41549f.zip |
Fix pipelinetest + remove useless commented lines
Diffstat (limited to 'common')
-rw-r--r-- | common/changereplay.cpp | 1 | ||||
-rw-r--r-- | common/storage.h | 4 | ||||
-rw-r--r-- | common/storage/entitystore.cpp | 16 | ||||
-rw-r--r-- | common/storage_common.cpp | 24 | ||||
-rw-r--r-- | common/synchronizer.cpp | 2 | ||||
-rw-r--r-- | common/utils.cpp | 1 |
6 files changed, 7 insertions, 41 deletions
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<void> ChangeReplay::replayNextRevision() | |||
114 | if (uid.isEmpty() || type.isEmpty()) { | 114 | if (uid.isEmpty() || type.isEmpty()) { |
115 | SinkErrorCtx(mLogCtx) << "Failed to read uid or type for revison: " << revision << uid << type; | 115 | SinkErrorCtx(mLogCtx) << "Failed to read uid or type for revison: " << revision << uid << type; |
116 | } else { | 116 | } else { |
117 | //const auto key = DataStore::assembleKey(uid, revision); | ||
118 | // TODO: should not use internal representations | 117 | // TODO: should not use internal representations |
119 | const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision).toInternalByteArray(); | 118 | const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision).toInternalByteArray(); |
120 | QByteArray entityBuffer; | 119 | 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: | |||
239 | static bool isInternalKey(void *key, int keySize); | 239 | static bool isInternalKey(void *key, int keySize); |
240 | static bool isInternalKey(const QByteArray &key); | 240 | static bool isInternalKey(const QByteArray &key); |
241 | 241 | ||
242 | //static QByteArray assembleKey(const QByteArray &key, qint64 revision); | ||
243 | //static Identifier uidFromKey(const QByteArray &key); | ||
244 | //static qint64 revisionFromKey(const QByteArray &key); | ||
245 | |||
246 | static NamedDatabase mainDatabase(const Transaction &, const QByteArray &type); | 242 | static NamedDatabase mainDatabase(const Transaction &, const QByteArray &type); |
247 | 243 | ||
248 | static QByteArray generateUid(); | 244 | 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) | |||
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | SinkTraceCtx(d->logCtx) << "Cleaning up revision " << revision << uid << bufferType; | 373 | SinkTraceCtx(d->logCtx) << "Cleaning up revision " << revision << uid << bufferType; |
374 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); | ||
374 | DataStore::mainDatabase(d->transaction, bufferType) | 375 | DataStore::mainDatabase(d->transaction, bufferType) |
375 | .scan(uid, | 376 | .scan(internalUid, |
376 | [&](const QByteArray &key, const QByteArray &data) -> bool { | 377 | [&](const QByteArray &key, const QByteArray &data) -> bool { |
377 | EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | 378 | EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); |
378 | if (!buffer.isValid()) { | 379 | if (!buffer.isValid()) { |
@@ -530,7 +531,6 @@ ApplicationDomain::ApplicationDomainType EntityStore::readLatest(const QByteArra | |||
530 | return dt; | 531 | return dt; |
531 | } | 532 | } |
532 | 533 | ||
533 | // TODO: check every usage | ||
534 | void EntityStore::readEntity(const QByteArray &type, const QByteArray &displayKey, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback) | 534 | void EntityStore::readEntity(const QByteArray &type, const QByteArray &displayKey, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback) |
535 | { | 535 | { |
536 | const auto key = Key::fromDisplayByteArray(displayKey); | 536 | const auto key = Key::fromDisplayByteArray(displayKey); |
@@ -598,7 +598,6 @@ void EntityStore::readPrevious(const QByteArray &type, const QByteArray &uid, qi | |||
598 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); | 598 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); |
599 | db.scan(internalUid, | 599 | db.scan(internalUid, |
600 | [&latestRevision, revision](const QByteArray &key, const QByteArray &) -> bool { | 600 | [&latestRevision, revision](const QByteArray &key, const QByteArray &) -> bool { |
601 | //const auto foundRevision = DataStore::revisionFromKey(key); | ||
602 | const auto foundRevision = Key::fromInternalByteArray(key).revision().toQint64(); | 601 | const auto foundRevision = Key::fromInternalByteArray(key).revision().toQint64(); |
603 | if (foundRevision < revision && foundRevision > latestRevision) { | 602 | if (foundRevision < revision && foundRevision > latestRevision) { |
604 | latestRevision = foundRevision; | 603 | latestRevision = foundRevision; |
@@ -633,11 +632,7 @@ void EntityStore::readAllUids(const QByteArray &type, const std::function<void(c | |||
633 | 632 | ||
634 | bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) | 633 | bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) |
635 | { | 634 | { |
636 | // Because of pipeline using this function with new entities | 635 | Q_ASSERT(!uid.isEmpty()); |
637 | // TODO: maybe modify pipeline instead? | ||
638 | if(uid.isEmpty()) { | ||
639 | return false; | ||
640 | } | ||
641 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); | 636 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); |
642 | return DataStore::mainDatabase(d->getTransaction(), type).contains(internalUid); | 637 | return DataStore::mainDatabase(d->getTransaction(), type).contains(internalUid); |
643 | } | 638 | } |
@@ -675,10 +670,11 @@ void EntityStore::readRevisions(const QByteArray &type, const QByteArray &uid, q | |||
675 | { | 670 | { |
676 | Q_ASSERT(d); | 671 | Q_ASSERT(d); |
677 | Q_ASSERT(!uid.isEmpty()); | 672 | Q_ASSERT(!uid.isEmpty()); |
673 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); | ||
678 | DataStore::mainDatabase(d->transaction, type) | 674 | DataStore::mainDatabase(d->transaction, type) |
679 | .scan(uid, | 675 | .scan(internalUid, |
680 | [&](const QByteArray &key, const QByteArray &value) -> bool { | 676 | [&](const QByteArray &key, const QByteArray &value) -> bool { |
681 | const auto parsedKey = Key::fromDisplayByteArray(key); | 677 | const auto parsedKey = Key::fromInternalByteArray(key); |
682 | const auto revision = parsedKey.revision().toQint64(); | 678 | const auto revision = parsedKey.revision().toQint64(); |
683 | if (revision >= startingRevision) { | 679 | if (revision >= startingRevision) { |
684 | callback(parsedKey.identifier().toDisplayByteArray(), revision, Sink::EntityBuffer(value.data(), value.size())); | 680 | 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 @@ | |||
24 | #include "log.h" | 24 | #include "log.h" |
25 | #include "utils.h" | 25 | #include "utils.h" |
26 | 26 | ||
27 | #include <QUuid> | ||
28 | |||
29 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::DataStore::Error &error) | 27 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::DataStore::Error &error) |
30 | { | 28 | { |
31 | dbg << error.message << "Code: " << error.code << "Db: " << error.store; | 29 | dbg << error.message << "Code: " << error.code << "Db: " << error.store; |
@@ -38,8 +36,6 @@ namespace Storage { | |||
38 | static const char *s_internalPrefix = "__internal"; | 36 | static const char *s_internalPrefix = "__internal"; |
39 | static const int s_internalPrefixSize = strlen(s_internalPrefix); | 37 | static const int s_internalPrefixSize = strlen(s_internalPrefix); |
40 | static const int s_lengthOfUid = 38; | 38 | static const int s_lengthOfUid = 38; |
41 | // RFC 4122 Section 4.1.2 says 128 bits -> 16 bytes | ||
42 | //static const int s_lengthOfUid = 16; | ||
43 | 39 | ||
44 | DbLayout::DbLayout() | 40 | DbLayout::DbLayout() |
45 | { | 41 | { |
@@ -198,26 +194,6 @@ bool DataStore::isInternalKey(const QByteArray &key) | |||
198 | return key.startsWith(s_internalPrefix); | 194 | return key.startsWith(s_internalPrefix); |
199 | } | 195 | } |
200 | 196 | ||
201 | /* | ||
202 | QByteArray DataStore::assembleKey(const QByteArray &key, qint64 revision) | ||
203 | { | ||
204 | Q_ASSERT(revision <= 9223372036854775807); | ||
205 | Q_ASSERT(key.size() == s_lengthOfUid); | ||
206 | return key + QByteArray::number(revision).rightJustified(19, '0', false); | ||
207 | } | ||
208 | |||
209 | //QByteArray DataStore::uidFromKey(const QByteArray &key) | ||
210 | Identifier DataStore::uidFromKey(const QByteArray &key) | ||
211 | { | ||
212 | return Identifier::fromByteArray(key.mid(0, s_lengthOfUid)); | ||
213 | } | ||
214 | |||
215 | qint64 DataStore::revisionFromKey(const QByteArray &key) | ||
216 | { | ||
217 | return key.mid(s_lengthOfUid + 1).toLongLong(); | ||
218 | } | ||
219 | */ | ||
220 | |||
221 | QByteArray DataStore::generateUid() | 197 | QByteArray DataStore::generateUid() |
222 | { | 198 | { |
223 | return createUuid(); | 199 | 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<void> Synchronizer::replay(const QByteArray &type, const QByteArray | |||
616 | Q_ASSERT(mEntityStore->hasTransaction()); | 616 | Q_ASSERT(mEntityStore->hasTransaction()); |
617 | 617 | ||
618 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; | 618 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; |
619 | //const auto uid = Sink::Storage::DataStore::uidFromKey(key); | 619 | // TODO: should not use internal representations |
620 | const auto uid = Sink::Storage::Key::fromDisplayByteArray(key).identifier().toDisplayByteArray(); | 620 | const auto uid = Sink::Storage::Key::fromDisplayByteArray(key).identifier().toDisplayByteArray(); |
621 | const auto modifiedProperties = metadataBuffer->modifiedProperties() ? BufferUtils::fromVector(*metadataBuffer->modifiedProperties()) : QByteArrayList(); | 621 | const auto modifiedProperties = metadataBuffer->modifiedProperties() ? BufferUtils::fromVector(*metadataBuffer->modifiedProperties()) : QByteArrayList(); |
622 | QByteArray oldRemoteId; | 622 | 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 @@ | |||
22 | QByteArray Sink::createUuid() | 22 | QByteArray Sink::createUuid() |
23 | { | 23 | { |
24 | return QUuid::createUuid().toByteArray(); | 24 | return QUuid::createUuid().toByteArray(); |
25 | //return QUuid::createUuid().toRfc4122(); | ||
26 | } | 25 | } |