Changeset View
Changeset View
Standalone View
Standalone View
common/datastorequery.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 113 | { | |||
---|---|---|---|---|---|
114 | return mSource->next(callback); | 114 | return mSource->next(callback); | ||
115 | } | 115 | } | ||
116 | }; | 116 | }; | ||
117 | 117 | | |||
118 | class Filter : public FilterBase { | 118 | class Filter : public FilterBase { | ||
119 | public: | 119 | public: | ||
120 | typedef QSharedPointer<Filter> Ptr; | 120 | typedef QSharedPointer<Filter> Ptr; | ||
121 | 121 | | |||
122 | QHash<QByteArray, Sink::QueryBase::Comparator> propertyFilter; | 122 | QHash<QByteArrayList, Sink::QueryBase::Comparator> propertyFilter; | ||
123 | 123 | | |||
124 | Filter(FilterBase::Ptr source, DataStoreQuery *store) | 124 | Filter(FilterBase::Ptr source, DataStoreQuery *store) | ||
125 | : FilterBase(source, store) | 125 | : FilterBase(source, store) | ||
126 | { | 126 | { | ||
127 | 127 | | |||
128 | } | 128 | } | ||
129 | 129 | | |||
130 | virtual ~Filter(){} | 130 | virtual ~Filter(){} | ||
Show All 22 Lines | 134 | while(!foundValue && mSource->next([this, callback, &foundValue](const ResultSet::Result &result) { | |||
153 | return false; | 153 | return false; | ||
154 | })) | 154 | })) | ||
155 | {} | 155 | {} | ||
156 | return foundValue; | 156 | return foundValue; | ||
157 | } | 157 | } | ||
158 | 158 | | |||
159 | bool matchesFilter(const ApplicationDomain::ApplicationDomainType &entity) { | 159 | bool matchesFilter(const ApplicationDomain::ApplicationDomainType &entity) { | ||
160 | for (const auto &filterProperty : propertyFilter.keys()) { | 160 | for (const auto &filterProperty : propertyFilter.keys()) { | ||
161 | const auto property = entity.getProperty(filterProperty); | 161 | QVariant property; | ||
162 | if (filterProperty.size() == 1) { | ||||
163 | property = entity.getProperty(filterProperty[0]); | ||||
164 | } else { | ||||
165 | QVariantList propList; | ||||
166 | for (const auto &propName : filterProperty) { | ||||
167 | propList.push_back(entity.getProperty(propName)); | ||||
168 | } | ||||
169 | property = propList; | ||||
170 | } | ||||
162 | const auto comparator = propertyFilter.value(filterProperty); | 171 | const auto comparator = propertyFilter.value(filterProperty); | ||
163 | //We can't deal with a fulltext filter | 172 | //We can't deal with a fulltext filter | ||
164 | if (comparator.comparator == QueryBase::Comparator::Fulltext) { | 173 | if (comparator.comparator == QueryBase::Comparator::Fulltext) { | ||
165 | continue; | 174 | continue; | ||
166 | } | 175 | } | ||
167 | if (!comparator.matches(property)) { | 176 | if (!comparator.matches(property)) { | ||
168 | SinkTraceCtx(mDatastore->mLogCtx) << "Filtering entity due to property mismatch on filter: " << entity.identifier() << "Property: " << filterProperty << property << " Filter:" << comparator.value; | 177 | SinkTraceCtx(mDatastore->mLogCtx) << "Filtering entity due to property mismatch on filter: " << entity.identifier() << "Property: " << filterProperty << property << " Filter:" << comparator.value; | ||
169 | return false; | 178 | return false; | ||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | 422 | readEntity(r, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { | |||
415 | SinkTraceCtx(mDatastore->mLogCtx) << "Bloom result: " << entity.identifier() << operationName(operation); | 424 | SinkTraceCtx(mDatastore->mLogCtx) << "Bloom result: " << entity.identifier() << operationName(operation); | ||
416 | foundValue = true; | 425 | foundValue = true; | ||
417 | }); | 426 | }); | ||
418 | } | 427 | } | ||
419 | return false; | 428 | return false; | ||
420 | })) | 429 | })) | ||
421 | {} | 430 | {} | ||
422 | mBloomed = true; | 431 | mBloomed = true; | ||
423 | propertyFilter.insert(mBloomProperty, mBloomValue); | 432 | propertyFilter.insert({mBloomProperty}, mBloomValue); | ||
424 | return foundValue; | 433 | return foundValue; | ||
425 | } else { | 434 | } else { | ||
426 | //Filter on bloom value | 435 | //Filter on bloom value | ||
427 | return Filter::next(callback); | 436 | return Filter::next(callback); | ||
428 | } | 437 | } | ||
429 | } | 438 | } | ||
430 | QVariant mBloomValue; | 439 | QVariant mBloomValue; | ||
431 | bool mBloomed = false; | 440 | bool mBloomed = false; | ||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | 588 | { | |||
593 | QByteArray appliedSorting; | 602 | QByteArray appliedSorting; | ||
594 | 603 | | |||
595 | //Determine initial set | 604 | //Determine initial set | ||
596 | mSource = [&]() { | 605 | mSource = [&]() { | ||
597 | if (!query.ids().isEmpty()) { | 606 | if (!query.ids().isEmpty()) { | ||
598 | //We have a set of ids as a starting point | 607 | //We have a set of ids as a starting point | ||
599 | return Source::Ptr::create(query.ids().toVector(), this); | 608 | return Source::Ptr::create(query.ids().toVector(), this); | ||
600 | } else { | 609 | } else { | ||
601 | QSet<QByteArray> appliedFilters; | 610 | QSet<QByteArrayList> appliedFilters; | ||
602 | auto resultSet = mStore.indexLookup(mType, query, appliedFilters, appliedSorting); | 611 | auto resultSet = mStore.indexLookup(mType, query, appliedFilters, appliedSorting); | ||
603 | if (!appliedFilters.isEmpty()) { | 612 | if (!appliedFilters.isEmpty()) { | ||
604 | //We have an index lookup as starting point | 613 | //We have an index lookup as starting point | ||
605 | return Source::Ptr::create(resultSet, this); | 614 | return Source::Ptr::create(resultSet, this); | ||
606 | } | 615 | } | ||
607 | // We do a full scan if there were no indexes available to create the initial set (this is going to be expensive for large sets). | 616 | // We do a full scan if there were no indexes available to create the initial set (this is going to be expensive for large sets). | ||
608 | return Source::Ptr::create(mStore.fullScan(mType), this); | 617 | return Source::Ptr::create(mStore.fullScan(mType), this); | ||
609 | } | 618 | } | ||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |