diff options
-rw-r--r-- | common/CMakeLists.txt | 1 | ||||
-rw-r--r-- | common/sample.fbs | 9 | ||||
-rw-r--r-- | common/typeindex.cpp | 32 |
3 files changed, 7 insertions, 35 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index aa400e1..970990f 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -109,7 +109,6 @@ generate_flatbuffers( | |||
109 | domain/folder | 109 | domain/folder |
110 | domain/dummy | 110 | domain/dummy |
111 | entity | 111 | entity |
112 | sample | ||
113 | metadata | 112 | metadata |
114 | queuedcommand | 113 | queuedcommand |
115 | ) | 114 | ) |
diff --git a/common/sample.fbs b/common/sample.fbs deleted file mode 100644 index dbd0e03..0000000 --- a/common/sample.fbs +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | namespace Sink; | ||
2 | |||
3 | table Sample { | ||
4 | periodStart: string; | ||
5 | periodEnd: string; | ||
6 | reference: string; | ||
7 | } | ||
8 | |||
9 | root_type Sample; | ||
diff --git a/common/typeindex.cpp b/common/typeindex.cpp index e056b36..15030de 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "index.h" | 22 | #include "index.h" |
23 | #include "fulltextindex.h" | 23 | #include "fulltextindex.h" |
24 | 24 | ||
25 | #include "sample_generated.h" | ||
26 | |||
27 | #include <QDateTime> | 25 | #include <QDateTime> |
28 | #include <QDataStream> | 26 | #include <QDataStream> |
29 | 27 | ||
@@ -243,24 +241,15 @@ void TypeIndex::addSampledPeriodIndex<QDateTime, QDateTime>( | |||
243 | return; | 241 | return; |
244 | } | 242 | } |
245 | 243 | ||
246 | auto beginBA = toSortableByteArray(beginDate); | ||
247 | auto endBA = toSortableByteArray(endDate); | ||
248 | |||
249 | flatbuffers::FlatBufferBuilder fbb; | ||
250 | auto sample = CreateSampleDirect(fbb, beginBA.constData(), endBA.constData(), identifier.constData()); | ||
251 | fbb.Finish(sample); | ||
252 | const auto buffer = QByteArray::fromRawData( | ||
253 | reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | ||
254 | |||
255 | Index index(sampledPeriodIndexName(beginProperty, endProperty), transaction); | 244 | Index index(sampledPeriodIndexName(beginProperty, endProperty), transaction); |
256 | for (auto bucket = beginBucket; bucket <= endBucket; ++bucket) { | 245 | for (auto bucket = beginBucket; bucket <= endBucket; ++bucket) { |
257 | QByteArray bucketKey = padNumber(bucket); | 246 | QByteArray bucketKey = padNumber(bucket); |
258 | if (add) { | 247 | if (add) { |
259 | SinkTraceCtx(mLogCtx) << "Adding entity to bucket:" << bucketKey; | 248 | SinkTraceCtx(mLogCtx) << "Adding entity to bucket:" << bucketKey; |
260 | index.add(bucketKey, buffer); | 249 | index.add(bucketKey, identifier); |
261 | } else { | 250 | } else { |
262 | SinkTraceCtx(mLogCtx) << "Removing entity from bucket:" << bucketKey; | 251 | SinkTraceCtx(mLogCtx) << "Removing entity from bucket:" << bucketKey; |
263 | index.remove(bucketKey, buffer); | 252 | index.remove(bucketKey, identifier); |
264 | } | 253 | } |
265 | } | 254 | } |
266 | }; | 255 | }; |
@@ -406,17 +395,7 @@ static QVector<QByteArray> sampledIndexLookup(Index &index, QueryBase::Comparato | |||
406 | 395 | ||
407 | index.rangeLookup(lowerBucket, upperBucket, | 396 | index.rangeLookup(lowerBucket, upperBucket, |
408 | [&](const QByteArray &value) { | 397 | [&](const QByteArray &value) { |
409 | auto sample = GetSample(value.data()); | 398 | keys << value.data(); |
410 | |||
411 | QByteArray periodStart = QString::fromStdString(sample->periodStart()->str()).toUtf8(); | ||
412 | QByteArray periodEnd = QString::fromStdString(sample->periodEnd()->str()).toUtf8(); | ||
413 | |||
414 | // Inverse comparison since descending order | ||
415 | if (periodStart >= upperBound && lowerBound >= periodEnd) { | ||
416 | QByteArray key = QString::fromStdString(sample->reference()->str()).toUtf8(); | ||
417 | SinkTrace() << "Keeping:" << key; | ||
418 | keys << key; | ||
419 | } | ||
420 | }, | 399 | }, |
421 | [bounds](const Index::Error &error) { | 400 | [bounds](const Index::Error &error) { |
422 | SinkWarning() << "Lookup error in index:" << error.message | 401 | SinkWarning() << "Lookup error in index:" << error.message |
@@ -444,7 +423,10 @@ QVector<QByteArray> TypeIndex::query(const Sink::QueryBase &query, QSet<QByteArr | |||
444 | if (mSampledPeriodProperties.contains({it.key()[0], it.key()[1]})) { | 423 | if (mSampledPeriodProperties.contains({it.key()[0], it.key()[1]})) { |
445 | Index index(sampledPeriodIndexName(it.key()[0], it.key()[1]), transaction); | 424 | Index index(sampledPeriodIndexName(it.key()[0], it.key()[1]), transaction); |
446 | const auto keys = sampledIndexLookup(index, query.getFilter(it.key())); | 425 | const auto keys = sampledIndexLookup(index, query.getFilter(it.key())); |
447 | appliedFilters << it.key(); | 426 | // The filter is not completely applied, we need post-filtering |
427 | // in the case the overlap period is not completely aligned | ||
428 | // with a week starting on monday | ||
429 | //appliedFilters << it.key(); | ||
448 | SinkTraceCtx(mLogCtx) << "Sampled period index lookup on" << it.key() << "found" << keys.size() << "keys."; | 430 | SinkTraceCtx(mLogCtx) << "Sampled period index lookup on" << it.key() << "found" << keys.size() << "keys."; |
449 | return keys; | 431 | return keys; |
450 | } else { | 432 | } else { |