diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-08-23 18:56:43 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-08-23 18:56:43 +0200 |
commit | 1acf9f3c486813df807ff6931e56cc13eb26eeaf (patch) | |
tree | 559ead2e95986515b4a5f93b6f143b8f1d429bd3 /common/pipeline.h | |
parent | 62e7084dcd6f53275fcb21ba17e880e41b40094d (diff) | |
download | sink-1acf9f3c486813df807ff6931e56cc13eb26eeaf.tar.gz sink-1acf9f3c486813df807ff6931e56cc13eb26eeaf.zip |
Store indexes as named databases in the same db.
Because we also keep using the same transactions this finally makes
the resource somewhat performant. On my system genericresourcebenchmark
now processes ~4200 messages per second instead of ~280.
Diffstat (limited to 'common/pipeline.h')
-rw-r--r-- | common/pipeline.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/common/pipeline.h b/common/pipeline.h index 496e037..fee6a5e 100644 --- a/common/pipeline.h +++ b/common/pipeline.h | |||
@@ -115,7 +115,7 @@ public: | |||
115 | virtual ~Preprocessor(); | 115 | virtual ~Preprocessor(); |
116 | 116 | ||
117 | //TODO pass actual command as well, for changerecording | 117 | //TODO pass actual command as well, for changerecording |
118 | virtual void process(const PipelineState &state, const Akonadi2::Entity &); | 118 | virtual void process(const PipelineState &state, Akonadi2::Storage::Transaction &transaction); |
119 | //TODO to record progress | 119 | //TODO to record progress |
120 | virtual QString id() const; | 120 | virtual QString id() const; |
121 | 121 | ||
@@ -133,17 +133,24 @@ private: | |||
133 | class AKONADI2COMMON_EXPORT SimpleProcessor : public Akonadi2::Preprocessor | 133 | class AKONADI2COMMON_EXPORT SimpleProcessor : public Akonadi2::Preprocessor |
134 | { | 134 | { |
135 | public: | 135 | public: |
136 | SimpleProcessor(const QString &id, const std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e)> &f) | 136 | SimpleProcessor(const QString &id, const std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e, Akonadi2::Storage::Transaction &transaction)> &f) |
137 | : Akonadi2::Preprocessor(), | 137 | : Akonadi2::Preprocessor(), |
138 | mFunction(f), | 138 | mFunction(f), |
139 | mId(id) | 139 | mId(id) |
140 | { | 140 | { |
141 | } | 141 | } |
142 | 142 | ||
143 | void process(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e) Q_DECL_OVERRIDE | 143 | void process(const PipelineState &state, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
144 | { | 144 | { |
145 | mFunction(state, e); | 145 | transaction.scan(state.key(), [this, &state, &transaction](const QByteArray &key, const QByteArray &value) -> bool { |
146 | processingCompleted(state); | 146 | auto entity = Akonadi2::GetEntity(value); |
147 | mFunction(state, *entity, transaction); | ||
148 | processingCompleted(state); | ||
149 | return false; | ||
150 | }, [this, state](const Akonadi2::Storage::Error &error) { | ||
151 | ErrorMsg() << "Failed to find value in pipeline: " << error.message; | ||
152 | processingCompleted(state); | ||
153 | }); | ||
147 | } | 154 | } |
148 | 155 | ||
149 | QString id() const | 156 | QString id() const |
@@ -152,7 +159,7 @@ public: | |||
152 | } | 159 | } |
153 | 160 | ||
154 | protected: | 161 | protected: |
155 | std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e)> mFunction; | 162 | std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e, Akonadi2::Storage::Transaction &transaction)> mFunction; |
156 | QString mId; | 163 | QString mId; |
157 | }; | 164 | }; |
158 | 165 | ||