diff options
Diffstat (limited to 'common/typeindex.cpp')
-rw-r--r-- | common/typeindex.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/common/typeindex.cpp b/common/typeindex.cpp index 05bbf5c..78195d3 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp | |||
@@ -22,8 +22,7 @@ | |||
22 | #include "index.h" | 22 | #include "index.h" |
23 | #include <QDateTime> | 23 | #include <QDateTime> |
24 | 24 | ||
25 | #undef DEBUG_AREA | 25 | SINK_DEBUG_AREA("typeindex") |
26 | #define DEBUG_AREA "common.typeindex" | ||
27 | 26 | ||
28 | static QByteArray getByteArray(const QVariant &value) | 27 | static QByteArray getByteArray(const QVariant &value) |
29 | { | 28 | { |
@@ -63,7 +62,7 @@ template <> | |||
63 | void TypeIndex::addProperty<QByteArray>(const QByteArray &property) | 62 | void TypeIndex::addProperty<QByteArray>(const QByteArray &property) |
64 | { | 63 | { |
65 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { | 64 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { |
66 | // Trace() << "Indexing " << mType + ".index." + property << value.toByteArray(); | 65 | // SinkTrace() << "Indexing " << mType + ".index." + property << value.toByteArray(); |
67 | Index(indexName(property), transaction).add(getByteArray(value), identifier); | 66 | Index(indexName(property), transaction).add(getByteArray(value), identifier); |
68 | }; | 67 | }; |
69 | mIndexer.insert(property, indexer); | 68 | mIndexer.insert(property, indexer); |
@@ -74,7 +73,7 @@ template <> | |||
74 | void TypeIndex::addProperty<QString>(const QByteArray &property) | 73 | void TypeIndex::addProperty<QString>(const QByteArray &property) |
75 | { | 74 | { |
76 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { | 75 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { |
77 | // Trace() << "Indexing " << mType + ".index." + property << value.toByteArray(); | 76 | // SinkTrace() << "Indexing " << mType + ".index." + property << value.toByteArray(); |
78 | Index(indexName(property), transaction).add(getByteArray(value), identifier); | 77 | Index(indexName(property), transaction).add(getByteArray(value), identifier); |
79 | }; | 78 | }; |
80 | mIndexer.insert(property, indexer); | 79 | mIndexer.insert(property, indexer); |
@@ -85,7 +84,7 @@ template <> | |||
85 | void TypeIndex::addProperty<QDateTime>(const QByteArray &property) | 84 | void TypeIndex::addProperty<QDateTime>(const QByteArray &property) |
86 | { | 85 | { |
87 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { | 86 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { |
88 | // Trace() << "Indexing " << mType + ".index." + property << date.toString(); | 87 | // SinkTrace() << "Indexing " << mType + ".index." + property << date.toString(); |
89 | Index(indexName(property), transaction).add(getByteArray(value), identifier); | 88 | Index(indexName(property), transaction).add(getByteArray(value), identifier); |
90 | }; | 89 | }; |
91 | mIndexer.insert(property, indexer); | 90 | mIndexer.insert(property, indexer); |
@@ -143,12 +142,12 @@ ResultSet TypeIndex::query(const Sink::Query &query, QSet<QByteArray> &appliedFi | |||
143 | if (query.propertyFilter.contains(it.key()) && query.sortProperty == it.value()) { | 142 | if (query.propertyFilter.contains(it.key()) && query.sortProperty == it.value()) { |
144 | Index index(indexName(it.key(), it.value()), transaction); | 143 | Index index(indexName(it.key(), it.value()), transaction); |
145 | const auto lookupKey = getByteArray(query.propertyFilter.value(it.key()).value); | 144 | const auto lookupKey = getByteArray(query.propertyFilter.value(it.key()).value); |
146 | Trace() << "looking for " << lookupKey; | 145 | SinkTrace() << "looking for " << lookupKey; |
147 | index.lookup(lookupKey, [&](const QByteArray &value) { keys << value; }, | 146 | index.lookup(lookupKey, [&](const QByteArray &value) { keys << value; }, |
148 | [it](const Index::Error &error) { Warning() << "Error in index: " << error.message << it.key() << it.value(); }, true); | 147 | [it](const Index::Error &error) { SinkWarning() << "Error in index: " << error.message << it.key() << it.value(); }, true); |
149 | appliedFilters << it.key(); | 148 | appliedFilters << it.key(); |
150 | appliedSorting = it.value(); | 149 | appliedSorting = it.value(); |
151 | Trace() << "Index lookup on " << it.key() << it.value() << " found " << keys.size() << " keys."; | 150 | SinkTrace() << "Index lookup on " << it.key() << it.value() << " found " << keys.size() << " keys."; |
152 | return ResultSet(keys); | 151 | return ResultSet(keys); |
153 | } | 152 | } |
154 | } | 153 | } |
@@ -157,12 +156,12 @@ ResultSet TypeIndex::query(const Sink::Query &query, QSet<QByteArray> &appliedFi | |||
157 | Index index(indexName(property), transaction); | 156 | Index index(indexName(property), transaction); |
158 | const auto lookupKey = getByteArray(query.propertyFilter.value(property).value); | 157 | const auto lookupKey = getByteArray(query.propertyFilter.value(property).value); |
159 | index.lookup( | 158 | index.lookup( |
160 | lookupKey, [&](const QByteArray &value) { keys << value; }, [property](const Index::Error &error) { Warning() << "Error in index: " << error.message << property; }); | 159 | lookupKey, [&](const QByteArray &value) { keys << value; }, [property](const Index::Error &error) { SinkWarning() << "Error in index: " << error.message << property; }); |
161 | appliedFilters << property; | 160 | appliedFilters << property; |
162 | Trace() << "Index lookup on " << property << " found " << keys.size() << " keys."; | 161 | SinkTrace() << "Index lookup on " << property << " found " << keys.size() << " keys."; |
163 | return ResultSet(keys); | 162 | return ResultSet(keys); |
164 | } | 163 | } |
165 | } | 164 | } |
166 | Trace() << "No matching index"; | 165 | SinkTrace() << "No matching index"; |
167 | return ResultSet(keys); | 166 | return ResultSet(keys); |
168 | } | 167 | } |