summaryrefslogtreecommitdiffstats
path: root/common/datastorequery.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-16 14:55:20 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-21 09:02:21 +0200
commit237b9ae4113e7a9f489632296941becb71afdb45 (patch)
tree01cde58f495944f01cad9d282391d4efd2897141 /common/datastorequery.h
parent95d11bf0be98a4e3c08502fe23417b800233ce14 (diff)
downloadsink-237b9ae4113e7a9f489632296941becb71afdb45.tar.gz
sink-237b9ae4113e7a9f489632296941becb71afdb45.zip
Refactor how the storage is used.
This is the initial refactoring to improve how we deal with the storage. It does a couple of things: * Rename Sink::Storage to Sink::Storage::DataStore to free up the Sink::Storage namespace * Introduce a Sink::ResourceContext to have a single object that can be passed around containing everything that is necessary to operate on a resource. This is a lot better than the multiple separate parameters that we used to pass around all over the place, while still allowing for dependency injection for tests. * Tie storage access together using the new EntityStore that directly works with ApplicationDomainTypes. This gives us a central place where main storage, indexes and buffer adaptors are tied together, which will also give us a place to implement external indexes, such as a fulltextindex using xapian. * Use ApplicationDomainTypes as the default way to pass around entities. Instead of using various ways to pass around entities (buffers, buffer adaptors, ApplicationDomainTypes), only use a single way. The old approach was confusing, and was only done as: * optimization; really shouldn't be necessary and otherwise I'm sure we can find better ways to optimize ApplicationDomainType itself. * a way to account for entities that have multiple buffers, a concept that I no longer deem relevant. While this commit does the bulk of the work to get there, the following commits will refactor more stuff to get things back to normal.
Diffstat (limited to 'common/datastorequery.h')
-rw-r--r--common/datastorequery.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/common/datastorequery.h b/common/datastorequery.h
index 164d721..4cf25b2 100644
--- a/common/datastorequery.h
+++ b/common/datastorequery.h
@@ -25,6 +25,7 @@
25#include "query.h" 25#include "query.h"
26#include "entitybuffer.h" 26#include "entitybuffer.h"
27#include "log.h" 27#include "log.h"
28#include "storage/entitystore.h"
28 29
29 30
30class Source; 31class Source;
@@ -35,11 +36,11 @@ class DataStoreQuery {
35public: 36public:
36 typedef QSharedPointer<DataStoreQuery> Ptr; 37 typedef QSharedPointer<DataStoreQuery> Ptr;
37 38
38 DataStoreQuery(const Sink::Query &query, const QByteArray &type, Sink::Storage::Transaction &transaction, TypeIndex &typeIndex, std::function<QVariant(const Sink::Entity &entity, const QByteArray &property)> getProperty); 39 DataStoreQuery(const Sink::Query &query, const QByteArray &type, Sink::Storage::EntityStore::Ptr store, TypeIndex &typeIndex, std::function<QVariant(const Sink::Entity &entity, const QByteArray &property)> getProperty);
39 ResultSet execute(); 40 ResultSet execute();
40 ResultSet update(qint64 baseRevision); 41 ResultSet update(qint64 baseRevision);
41 42
42protected: 43private:
43 44
44 typedef std::function<bool(const QByteArray &uid, const Sink::EntityBuffer &entityBuffer)> FilterFunction; 45 typedef std::function<bool(const QByteArray &uid, const Sink::EntityBuffer &entityBuffer)> FilterFunction;
45 typedef std::function<void(const QByteArray &uid, const Sink::EntityBuffer &entityBuffer)> BufferCallback; 46 typedef std::function<void(const QByteArray &uid, const Sink::EntityBuffer &entityBuffer)> BufferCallback;
@@ -56,15 +57,15 @@ protected:
56 QByteArrayList executeSubquery(const Sink::Query &subquery); 57 QByteArrayList executeSubquery(const Sink::Query &subquery);
57 58
58 Sink::Query mQuery; 59 Sink::Query mQuery;
59 Sink::Storage::Transaction &mTransaction;
60 const QByteArray mType; 60 const QByteArray mType;
61 TypeIndex &mTypeIndex; 61 TypeIndex &mTypeIndex;
62 Sink::Storage::NamedDatabase mDb;
63 std::function<QVariant(const Sink::Entity &entity, const QByteArray &property)> mGetProperty; 62 std::function<QVariant(const Sink::Entity &entity, const QByteArray &property)> mGetProperty;
64 bool mInitialQuery; 63 bool mInitialQuery;
65 QSharedPointer<FilterBase> mCollector; 64 QSharedPointer<FilterBase> mCollector;
66 QSharedPointer<Source> mSource; 65 QSharedPointer<Source> mSource;
67 66
67 QSharedPointer<Sink::Storage::EntityStore> mStore;
68
68 SINK_DEBUG_COMPONENT(mType) 69 SINK_DEBUG_COMPONENT(mType)
69}; 70};
70 71