Skip to content

Commit 0b6e704

Browse files
Port IndexManager
1 parent 4cec423 commit 0b6e704

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

packages/firestore/src/local/index_manager.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { Target } from '../core/target';
19+
import { DocumentKeySet, DocumentMap } from '../model/collections';
20+
import { FieldIndex, IndexOffset } from '../model/field_index';
1821
import { ResourcePath } from '../model/path';
1922

2023
import { PersistencePromise } from './persistence_promise';
@@ -50,4 +53,84 @@ export interface IndexManager {
5053
transaction: PersistenceTransaction,
5154
collectionId: string
5255
): PersistencePromise<ResourcePath[]>;
56+
57+
/**
58+
* Adds a field path index.
59+
*
60+
* <p>Values for this index are persisted asynchronously. The index will only be used for query
61+
* execution once values are persisted.
62+
*/
63+
addFieldIndex(
64+
transaction: PersistenceTransaction,
65+
index: FieldIndex
66+
): PersistencePromise<void>;
67+
68+
/** Removes the given field index and deletes all index values. */
69+
deleteFieldIndex(
70+
transaction: PersistenceTransaction,
71+
index: FieldIndex
72+
): PersistencePromise<void>;
73+
74+
/**
75+
* Returns a list of field indexes that correspond to the specified collection group.
76+
*
77+
* @param collectionGroup The collection group to get matching field indexes for.
78+
* @return A collection of field indexes for the specified collection group.
79+
*/
80+
getFieldIndexes(
81+
transaction: PersistenceTransaction,
82+
collectionGroup: string
83+
): PersistencePromise<FieldIndex[]>;
84+
85+
/** Returns all configured field indexes. */
86+
getFieldIndexes(
87+
transaction: PersistenceTransaction
88+
): PersistencePromise<FieldIndex[]>;
89+
90+
/**
91+
* Returns an index that can be used to serve the provided target. Returns
92+
* `null` if no index is configured.
93+
*/
94+
getFieldIndex(
95+
transaction: PersistenceTransaction,
96+
target: Target
97+
): PersistencePromise<FieldIndex | null>;
98+
99+
/**
100+
* Returns the documents that match the given target based on the provided
101+
* index.
102+
*/
103+
getDocumentsMatchingTarget(
104+
transaction: PersistenceTransaction,
105+
fieldIndex: FieldIndex,
106+
target: Target
107+
): PersistencePromise<DocumentKeySet>;
108+
109+
/**
110+
* Returns the next collection group to update. Returns `null` if no group
111+
* exists.
112+
*/
113+
getNextCollectionGroupToUpdate(
114+
transaction: PersistenceTransaction
115+
): string | null;
116+
117+
/**
118+
* Sets the collection group's latest read time.
119+
*
120+
* This method updates the index offset for all field indices for the
121+
* collection group and increments their sequence number. Subsequent calls to
122+
* `getNextCollectionGroupToUpdate()` will return a different collection group
123+
* (unless only one collection group is configured).
124+
*/
125+
updateCollectionGroup(
126+
transaction: PersistenceTransaction,
127+
collectionGroup: string,
128+
offset: IndexOffset
129+
): PersistencePromise<void>;
130+
131+
/** Updates the index entries for the provided documents. */
132+
updateIndexEntries(
133+
transaction: PersistenceTransaction,
134+
documents: DocumentMap
135+
): PersistencePromise<void>;
53136
}

0 commit comments

Comments
 (0)