diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-09 11:04:54 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-09 11:04:54 +0100 |
commit | c60eecd3d0e9a04678b1a4e74402b9cb0f478afe (patch) | |
tree | acc5bd2703dddc0ee7f6fea4484d69adcdbd6f15 | |
parent | c3c18722912a39fceac9e8bc59987f3174d0ebef (diff) | |
download | sink-c60eecd3d0e9a04678b1a4e74402b9cb0f478afe.tar.gz sink-c60eecd3d0e9a04678b1a4e74402b9cb0f478afe.zip |
Better debug output
-rw-r--r-- | common/datastorequery.cpp | 35 | ||||
-rw-r--r-- | common/datastorequery.h | 5 |
2 files changed, 27 insertions, 13 deletions
diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index aa0056c..41d962c 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp | |||
@@ -24,8 +24,18 @@ | |||
24 | using namespace Sink; | 24 | using namespace Sink; |
25 | using namespace Sink::Storage; | 25 | using namespace Sink::Storage; |
26 | 26 | ||
27 | 27 | static QByteArray operationName(const Sink::Operation op) | |
28 | SINK_DEBUG_AREA("datastorequery") | 28 | { |
29 | switch(op) { | ||
30 | case Sink::Operation_Creation: | ||
31 | return "Creation"; | ||
32 | case Sink::Operation_Modification: | ||
33 | return "Modification"; | ||
34 | case Sink::Operation_Removal: | ||
35 | return "Removal"; | ||
36 | } | ||
37 | return ""; | ||
38 | } | ||
29 | 39 | ||
30 | class Source : public FilterBase { | 40 | class Source : public FilterBase { |
31 | public: | 41 | public: |
@@ -63,6 +73,7 @@ class Source : public FilterBase { | |||
63 | return false; | 73 | return false; |
64 | } | 74 | } |
65 | readEntity(*mIt, [callback](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { | 75 | readEntity(*mIt, [callback](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { |
76 | SinkTraceCtx(mDatastore->mLogCtx) << "Source: Read entity: " << entity.identifier() << operationName(operation); | ||
66 | callback({entity, operation}); | 77 | callback({entity, operation}); |
67 | }); | 78 | }); |
68 | mIt++; | 79 | mIt++; |
@@ -104,20 +115,20 @@ public: | |||
104 | virtual bool next(const std::function<void(const ResultSet::Result &result)> &callback) Q_DECL_OVERRIDE { | 115 | virtual bool next(const std::function<void(const ResultSet::Result &result)> &callback) Q_DECL_OVERRIDE { |
105 | bool foundValue = false; | 116 | bool foundValue = false; |
106 | while(!foundValue && mSource->next([this, callback, &foundValue](const ResultSet::Result &result) { | 117 | while(!foundValue && mSource->next([this, callback, &foundValue](const ResultSet::Result &result) { |
107 | SinkTrace() << "Filter: " << result.entity.identifier() << result.operation; | 118 | SinkTraceCtx(mDatastore->mLogCtx) << "Filter: " << result.entity.identifier() << result.operation; |
108 | 119 | ||
109 | //Always accept removals. They can't match the filter since the data is gone. | 120 | //Always accept removals. They can't match the filter since the data is gone. |
110 | if (result.operation == Sink::Operation_Removal) { | 121 | if (result.operation == Sink::Operation_Removal) { |
111 | SinkTrace() << "Removal: " << result.entity.identifier() << result.operation; | 122 | SinkTraceCtx(mDatastore->mLogCtx) << "Removal: " << result.entity.identifier() << operationName(result.operation); |
112 | callback(result); | 123 | callback(result); |
113 | foundValue = true; | 124 | foundValue = true; |
114 | } else if (matchesFilter(result.entity)) { | 125 | } else if (matchesFilter(result.entity)) { |
115 | SinkTrace() << "Accepted: " << result.entity.identifier() << result.operation; | 126 | SinkTraceCtx(mDatastore->mLogCtx) << "Accepted: " << result.entity.identifier() << operationName(result.operation); |
116 | callback(result); | 127 | callback(result); |
117 | foundValue = true; | 128 | foundValue = true; |
118 | //TODO if something did not match the filter so far but does now, turn into an add operation. | 129 | //TODO if something did not match the filter so far but does now, turn into an add operation. |
119 | } else { | 130 | } else { |
120 | SinkTrace() << "Rejected: " << result.entity.identifier() << result.operation; | 131 | SinkTraceCtx(mDatastore->mLogCtx) << "Rejected: " << result.entity.identifier() << operationName(result.operation); |
121 | //TODO emit a removal if we had the uid in the result set and this is a modification. | 132 | //TODO emit a removal if we had the uid in the result set and this is a modification. |
122 | //We don't know if this results in a removal from the dataset, so we emit a removal notification anyways | 133 | //We don't know if this results in a removal from the dataset, so we emit a removal notification anyways |
123 | callback({result.entity, Sink::Operation_Removal, result.aggregateValues}); | 134 | callback({result.entity, Sink::Operation_Removal, result.aggregateValues}); |
@@ -133,7 +144,7 @@ public: | |||
133 | const auto property = entity.getProperty(filterProperty); | 144 | const auto property = entity.getProperty(filterProperty); |
134 | const auto comparator = propertyFilter.value(filterProperty); | 145 | const auto comparator = propertyFilter.value(filterProperty); |
135 | if (!comparator.matches(property)) { | 146 | if (!comparator.matches(property)) { |
136 | SinkTrace() << "Filtering entity due to property mismatch on filter: " << filterProperty << property << ":" << comparator.value; | 147 | SinkTraceCtx(mDatastore->mLogCtx) << "Filtering entity due to property mismatch on filter: " << filterProperty << property << ":" << comparator.value; |
137 | return false; | 148 | return false; |
138 | } | 149 | } |
139 | } | 150 | } |
@@ -299,6 +310,7 @@ public: | |||
299 | for (const auto &r : results) { | 310 | for (const auto &r : results) { |
300 | readEntity(r, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { | 311 | readEntity(r, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { |
301 | callback({entity, Sink::Operation_Creation}); | 312 | callback({entity, Sink::Operation_Creation}); |
313 | SinkTraceCtx(mDatastore->mLogCtx) << "Bloom result: " << entity.identifier() << operationName(operation); | ||
302 | foundValue = true; | 314 | foundValue = true; |
303 | }); | 315 | }); |
304 | } | 316 | } |
@@ -500,25 +512,22 @@ void DataStoreQuery::setupQuery() | |||
500 | 512 | ||
501 | QVector<QByteArray> DataStoreQuery::loadIncrementalResultSet(qint64 baseRevision) | 513 | QVector<QByteArray> DataStoreQuery::loadIncrementalResultSet(qint64 baseRevision) |
502 | { | 514 | { |
503 | auto revisionCounter = QSharedPointer<qint64>::create(baseRevision); | ||
504 | QVector<QByteArray> changedKeys; | 515 | QVector<QByteArray> changedKeys; |
505 | mStore.readRevisions(baseRevision, mType, [&](const QByteArray &key) { | 516 | mStore.readRevisions(baseRevision, mType, [&](const QByteArray &key) { |
506 | changedKeys << key; | 517 | changedKeys << key; |
507 | }); | 518 | }); |
508 | SinkTraceCtx(mLogCtx) << "Finished reading incremental result set:" << *revisionCounter; | ||
509 | return changedKeys; | 519 | return changedKeys; |
510 | } | 520 | } |
511 | 521 | ||
512 | |||
513 | ResultSet DataStoreQuery::update(qint64 baseRevision) | 522 | ResultSet DataStoreQuery::update(qint64 baseRevision) |
514 | { | 523 | { |
515 | SinkTraceCtx(mLogCtx) << "Executing query update"; | 524 | SinkTraceCtx(mLogCtx) << "Executing query update to revision " << baseRevision; |
516 | auto incrementalResultSet = loadIncrementalResultSet(baseRevision); | 525 | auto incrementalResultSet = loadIncrementalResultSet(baseRevision); |
517 | SinkTraceCtx(mLogCtx) << "Changed: " << incrementalResultSet; | 526 | SinkTraceCtx(mLogCtx) << "Incremental changes: " << incrementalResultSet; |
518 | mSource->add(incrementalResultSet); | 527 | mSource->add(incrementalResultSet); |
519 | ResultSet::ValueGenerator generator = [this](const ResultSet::Callback &callback) -> bool { | 528 | ResultSet::ValueGenerator generator = [this](const ResultSet::Callback &callback) -> bool { |
520 | if (mCollector->next([this, callback](const ResultSet::Result &result) { | 529 | if (mCollector->next([this, callback](const ResultSet::Result &result) { |
521 | SinkTraceCtx(mLogCtx) << "Got incremental result: " << result.entity.identifier() << result.operation; | 530 | SinkTraceCtx(mLogCtx) << "Got incremental result: " << result.entity.identifier() << operationName(result.operation); |
522 | callback(result); | 531 | callback(result); |
523 | })) | 532 | })) |
524 | { | 533 | { |
diff --git a/common/datastorequery.h b/common/datastorequery.h index 4ac0e2d..5a47685 100644 --- a/common/datastorequery.h +++ b/common/datastorequery.h | |||
@@ -25,10 +25,15 @@ | |||
25 | 25 | ||
26 | 26 | ||
27 | class Source; | 27 | class Source; |
28 | class Bloom; | ||
29 | class Filter; | ||
28 | class FilterBase; | 30 | class FilterBase; |
29 | 31 | ||
30 | class DataStoreQuery { | 32 | class DataStoreQuery { |
31 | friend class FilterBase; | 33 | friend class FilterBase; |
34 | friend class Source; | ||
35 | friend class Bloom; | ||
36 | friend class Filter; | ||
32 | public: | 37 | public: |
33 | typedef QSharedPointer<DataStoreQuery> Ptr; | 38 | typedef QSharedPointer<DataStoreQuery> Ptr; |
34 | 39 | ||