2020#include < string>
2121#include < vector>
2222
23+ #include " Firestore/core/src/model/model_fwd.h"
24+
2325namespace firebase {
2426namespace firestore {
2527
28+ namespace core {
29+ class Target ;
30+ class SortedMap ;
31+ } // namespace core
32+
2633namespace model {
34+ class DocumentKey ;
35+ class FieldIndex ;
36+ class IndexOffset ;
2737class ResourcePath ;
2838} // namespace model
2939
@@ -39,6 +49,9 @@ class IndexManager {
3949 public:
4050 virtual ~IndexManager () = default ;
4151
52+ /* * Initializes the IndexManager. */
53+ virtual void Start () = 0;
54+
4255 /* *
4356 * Creates an index entry mapping the collection_id (last segment of the path)
4457 * to the parent path (either the containing document location or the empty
@@ -58,6 +71,65 @@ class IndexManager {
5871 */
5972 virtual std::vector<model::ResourcePath> GetCollectionParents (
6073 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;
61133};
62134
63135} // namespace local
0 commit comments