20
20
#include < string>
21
21
#include < vector>
22
22
23
+ #include " Firestore/core/src/model/model_fwd.h"
24
+
23
25
namespace firebase {
24
26
namespace firestore {
25
27
28
+ namespace core {
29
+ class Target ;
30
+ class SortedMap ;
31
+ } // namespace core
32
+
26
33
namespace model {
34
+ class DocumentKey ;
35
+ class FieldIndex ;
36
+ class IndexOffset ;
27
37
class ResourcePath ;
28
38
} // namespace model
29
39
@@ -39,6 +49,9 @@ class IndexManager {
39
49
public:
40
50
virtual ~IndexManager () = default ;
41
51
52
+ /* * Initializes the IndexManager. */
53
+ virtual void Start () = 0;
54
+
42
55
/* *
43
56
* Creates an index entry mapping the collection_id (last segment of the path)
44
57
* to the parent path (either the containing document location or the empty
@@ -58,6 +71,65 @@ class IndexManager {
58
71
*/
59
72
virtual std::vector<model::ResourcePath> GetCollectionParents (
60
73
const std::string& collection_id) = 0;
74
+
75
+ /* *
76
+ * Adds a field path index.
77
+ *
78
+ * The actual entries for this index will be created and persisted in the
79
+ * background by the SDK, and the index will be used for query execution once
80
+ * values are persisted.
81
+ */
82
+ virtual void AddFieldIndex (const model::FieldIndex& index) = 0;
83
+
84
+ /* * Removes the given field index and deletes all index values. */
85
+ virtual void DeleteFieldIndex (const model::FieldIndex& index) = 0;
86
+
87
+ /* *
88
+ * Returns a list of field indexes that correspond to the specified collection
89
+ * group.
90
+ */
91
+ virtual std::vector<model::FieldIndex> GetFieldIndexes (
92
+ const std::string& collection_group) = 0;
93
+
94
+ /* * Returns all configured field indexes. */
95
+ virtual std::vector<model::FieldIndex> GetFieldIndexes () = 0;
96
+
97
+ /* *
98
+ * Returns an index that can be used to serve the provided target. Returns
99
+ * `nullopt` if no index is configured.
100
+ */
101
+ virtual absl::optional<model::FieldIndex> GetFieldIndex (
102
+ core::Target target) = 0;
103
+
104
+ /* *
105
+ * Returns the documents that match the given target based on the provided
106
+ * index, or `nullopt` if the query cannot be served from an index.
107
+ */
108
+ virtual absl::optional<std::vector<model::DocumentKey>>
109
+ GetDocumentsMatchingTarget (model::FieldIndex fieldIndex,
110
+ core::Target target) = 0 ;
111
+
112
+ /* *
113
+ * Returns the next collection group to update. Returns `nullopt` if no
114
+ * group exists.
115
+ */
116
+ virtual absl::optional<std::string> GetNextCollectionGroupToUpdate () = 0;
117
+
118
+ /* *
119
+ * Sets the collection group's latest read time.
120
+ *
121
+ * This method updates the index offset for all field indices for the
122
+ * collection group and increments their sequence number.
123
+ *
124
+ * Subsequent calls to `GetNextCollectionGroupToUpdate()` will return a
125
+ * different collection group (unless only one collection group is
126
+ * configured).
127
+ */
128
+ virtual void UpdateCollectionGroup (const std::string& collection_group,
129
+ model::IndexOffset offset) = 0;
130
+
131
+ /* * Updates the index entries for the provided documents. */
132
+ virtual void UpdateIndexEntries (const model::DocumentMap& documents) = 0;
61
133
};
62
134
63
135
} // namespace local
0 commit comments