@firebase/firestore 3.4.7 → 3.4.8-canary.19e31a231
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/firestore/src/core/query.d.ts +2 -4
- package/dist/firestore/src/core/target.d.ts +6 -4
- package/dist/firestore/src/local/index_manager.d.ts +27 -5
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +15 -10
- package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +9 -0
- package/dist/firestore/src/local/indexeddb_schema.d.ts +8 -2
- package/dist/firestore/src/local/indexeddb_sentinels.d.ts +9 -2
- package/dist/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/firestore/src/local/memory_index_manager.d.ts +6 -4
- package/dist/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/firestore/src/local/simple_db.d.ts +2 -0
- package/dist/firestore/src/model/collections.d.ts +1 -1
- package/dist/firestore/src/model/field_index.d.ts +6 -0
- package/dist/firestore/src/model/values.d.ts +14 -2
- package/dist/firestore/src/util/misc.d.ts +3 -0
- package/dist/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/firestore/test/unit/local/test_index_manager.d.ts +5 -4
- package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +0 -4
- package/dist/index.esm2017.js +4649 -4498
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +4941 -4800
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1764 -1577
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +1764 -1577
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +4495 -4344
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +26 -4
- package/dist/lite/firestore/src/core/query.d.ts +2 -4
- package/dist/lite/firestore/src/core/target.d.ts +6 -4
- package/dist/lite/firestore/src/local/index_manager.d.ts +27 -5
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +15 -10
- package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +9 -0
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +8 -2
- package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +9 -2
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +6 -4
- package/dist/lite/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/firestore/src/local/simple_db.d.ts +2 -0
- package/dist/lite/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/firestore/src/model/field_index.d.ts +6 -0
- package/dist/lite/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +5 -4
- package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +0 -4
- package/dist/lite/index.browser.esm2017.js +123 -117
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +203 -197
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +24 -10
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +24 -10
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1155 -1149
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/src/core/query.d.ts +2 -4
- package/dist/lite/packages/firestore/src/core/target.d.ts +6 -4
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +27 -5
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +15 -10
- package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +9 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +8 -2
- package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +9 -2
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +6 -4
- package/dist/lite/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/packages/firestore/src/local/simple_db.d.ts +2 -0
- package/dist/lite/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/packages/firestore/src/model/field_index.d.ts +6 -0
- package/dist/lite/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +5 -4
- package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +0 -4
- package/dist/packages/firestore/dist/index.esm2017.d.ts +171 -171
- package/dist/packages/firestore/src/core/query.d.ts +2 -4
- package/dist/packages/firestore/src/core/target.d.ts +6 -4
- package/dist/packages/firestore/src/local/index_manager.d.ts +27 -5
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +15 -10
- package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +9 -0
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +8 -2
- package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +9 -2
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +6 -4
- package/dist/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/packages/firestore/src/local/simple_db.d.ts +2 -0
- package/dist/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/packages/firestore/src/model/field_index.d.ts +6 -0
- package/dist/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +5 -4
- package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +0 -4
- package/dist/private.d.ts +26 -4
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @firebase/firestore
|
|
2
2
|
|
|
3
|
+
## 3.4.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`05dc9d6a0`](https://github.com/firebase/firebase-js-sdk/commit/05dc9d6a0db3058611dd7a2dc34daa726f9ba20d) [#6128](https://github.com/firebase/firebase-js-sdk/pull/6128) (fixes [#6110](https://github.com/firebase/firebase-js-sdk/issues/6110)) - Fixes an issue during multi-document lookup that resulted in the IndexedDB error "The parameter is less than or equal to this cursor's".
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`e9e5f6b3c`](https://github.com/firebase/firebase-js-sdk/commit/e9e5f6b3ca9d61323b22f87986d9959f5297ec59)]:
|
|
10
|
+
- @firebase/util@1.5.2
|
|
11
|
+
- @firebase/component@0.5.13
|
|
12
|
+
|
|
3
13
|
## 3.4.7
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -76,9 +76,7 @@ export declare function asCollectionQueryAtPath(query: Query, path: ResourcePath
|
|
|
76
76
|
* Returns true if this query does not specify any query constraints that
|
|
77
77
|
* could remove results.
|
|
78
78
|
*/
|
|
79
|
-
export declare function
|
|
80
|
-
export declare function hasLimitToFirst(query: Query): boolean;
|
|
81
|
-
export declare function hasLimitToLast(query: Query): boolean;
|
|
79
|
+
export declare function queryMatchesAllDocuments(query: Query): boolean;
|
|
82
80
|
export declare function getFirstOrderByField(query: Query): FieldPath | null;
|
|
83
81
|
export declare function getInequalityFilterField(query: Query): FieldPath | null;
|
|
84
82
|
/**
|
|
@@ -113,7 +111,7 @@ export declare function queryOrderBy(query: Query): OrderBy[];
|
|
|
113
111
|
export declare function queryToTarget(query: Query): Target;
|
|
114
112
|
export declare function queryWithAddedFilter(query: Query, filter: Filter): Query;
|
|
115
113
|
export declare function queryWithAddedOrderBy(query: Query, orderBy: OrderBy): Query;
|
|
116
|
-
export declare function queryWithLimit(query: Query, limit: number, limitType: LimitType): Query;
|
|
114
|
+
export declare function queryWithLimit(query: Query, limit: number | null, limitType: LimitType): Query;
|
|
117
115
|
export declare function queryWithStartAt(query: Query, bound: Bound): Query;
|
|
118
116
|
export declare function queryWithEndAt(query: Query, bound: Bound): Query;
|
|
119
117
|
export declare function queryEquals(left: Query, right: Query): boolean;
|
|
@@ -72,16 +72,18 @@ export declare function targetGetArrayValues(target: Target, fieldIndex: FieldIn
|
|
|
72
72
|
export declare function targetGetNotInValues(target: Target, fieldIndex: FieldIndex): ProtoValue[] | null;
|
|
73
73
|
/**
|
|
74
74
|
* Returns a lower bound of field values that can be used as a starting point to
|
|
75
|
-
* scan the index defined by `fieldIndex`. Returns `
|
|
75
|
+
* scan the index defined by `fieldIndex`. Returns `MIN_VALUE` if no lower bound
|
|
76
76
|
* exists.
|
|
77
77
|
*/
|
|
78
|
-
export declare function targetGetLowerBound(target: Target, fieldIndex: FieldIndex): Bound
|
|
78
|
+
export declare function targetGetLowerBound(target: Target, fieldIndex: FieldIndex): Bound;
|
|
79
79
|
/**
|
|
80
80
|
* Returns an upper bound of field values that can be used as an ending point
|
|
81
|
-
* when scanning the index defined by `fieldIndex`. Returns `
|
|
81
|
+
* when scanning the index defined by `fieldIndex`. Returns `MAX_VALUE` if no
|
|
82
82
|
* upper bound exists.
|
|
83
83
|
*/
|
|
84
|
-
export declare function targetGetUpperBound(target: Target, fieldIndex: FieldIndex): Bound
|
|
84
|
+
export declare function targetGetUpperBound(target: Target, fieldIndex: FieldIndex): Bound;
|
|
85
|
+
/** Returns the number of segments of a perfect index for this target. */
|
|
86
|
+
export declare function targetGetSegmentCount(target: Target): number;
|
|
85
87
|
export declare abstract class Filter {
|
|
86
88
|
abstract matches(doc: Document): boolean;
|
|
87
89
|
}
|
|
@@ -15,11 +15,28 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { Target } from '../core/target';
|
|
18
|
-
import {
|
|
18
|
+
import { DocumentMap } from '../model/collections';
|
|
19
|
+
import { DocumentKey } from '../model/document_key';
|
|
19
20
|
import { FieldIndex, IndexOffset } from '../model/field_index';
|
|
20
21
|
import { ResourcePath } from '../model/path';
|
|
21
22
|
import { PersistencePromise } from './persistence_promise';
|
|
22
23
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
24
|
+
/** Represents the index state as it relates to a particular target. */
|
|
25
|
+
export declare const enum IndexType {
|
|
26
|
+
/** Indicates that no index could be found for serving the target. */
|
|
27
|
+
NONE = 0,
|
|
28
|
+
/**
|
|
29
|
+
* Indicates that only a "partial index" could be found for serving the
|
|
30
|
+
* target. A partial index is one which does not have a segment for every
|
|
31
|
+
* filter/orderBy in the target.
|
|
32
|
+
*/
|
|
33
|
+
PARTIAL = 1,
|
|
34
|
+
/**
|
|
35
|
+
* Indicates that a "full index" could be found for serving the target. A full
|
|
36
|
+
* index is one which has a segment for every filter/orderBy in the target.
|
|
37
|
+
*/
|
|
38
|
+
FULL = 2
|
|
39
|
+
}
|
|
23
40
|
/**
|
|
24
41
|
* Represents a set of indexes that are used to execute queries efficiently.
|
|
25
42
|
*
|
|
@@ -67,15 +84,15 @@ export interface IndexManager {
|
|
|
67
84
|
/** Returns all configured field indexes. */
|
|
68
85
|
getFieldIndexes(transaction: PersistenceTransaction): PersistencePromise<FieldIndex[]>;
|
|
69
86
|
/**
|
|
70
|
-
* Returns
|
|
71
|
-
*
|
|
87
|
+
* Returns the type of index (if any) that can be used to serve the given
|
|
88
|
+
* target.
|
|
72
89
|
*/
|
|
73
|
-
|
|
90
|
+
getIndexType(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexType>;
|
|
74
91
|
/**
|
|
75
92
|
* Returns the documents that match the given target based on the provided
|
|
76
93
|
* index or `null` if the target does not have a matching index.
|
|
77
94
|
*/
|
|
78
|
-
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<
|
|
95
|
+
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKey[] | null>;
|
|
79
96
|
/**
|
|
80
97
|
* Returns the next collection group to update. Returns `null` if no group
|
|
81
98
|
* exists.
|
|
@@ -92,4 +109,9 @@ export interface IndexManager {
|
|
|
92
109
|
updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
|
|
93
110
|
/** Updates the index entries for the provided documents. */
|
|
94
111
|
updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Iterates over all field indexes that are used to serve the given target,
|
|
114
|
+
* and returns the minimum offset of them all.
|
|
115
|
+
*/
|
|
116
|
+
getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>;
|
|
95
117
|
}
|
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { User } from '../auth/user';
|
|
18
|
+
import { DatabaseId } from '../core/database_info';
|
|
18
19
|
import { Target } from '../core/target';
|
|
19
|
-
import {
|
|
20
|
+
import { DocumentMap } from '../model/collections';
|
|
21
|
+
import { DocumentKey } from '../model/document_key';
|
|
20
22
|
import { FieldIndex, IndexOffset } from '../model/field_index';
|
|
21
23
|
import { ResourcePath } from '../model/path';
|
|
22
|
-
import { IndexManager } from './index_manager';
|
|
24
|
+
import { IndexManager, IndexType } from './index_manager';
|
|
23
25
|
import { PersistencePromise } from './persistence_promise';
|
|
24
26
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
25
27
|
/**
|
|
@@ -30,6 +32,7 @@ import { PersistenceTransaction } from './persistence_transaction';
|
|
|
30
32
|
*/
|
|
31
33
|
export declare class IndexedDbIndexManager implements IndexManager {
|
|
32
34
|
private user;
|
|
35
|
+
private readonly databaseId;
|
|
33
36
|
/**
|
|
34
37
|
* An in-memory copy of the index entries we've already written since the SDK
|
|
35
38
|
* launched. Used to avoid re-writing the same entry repeatedly.
|
|
@@ -44,7 +47,7 @@ export declare class IndexedDbIndexManager implements IndexManager {
|
|
|
44
47
|
* contains only one term from the target's disjunctive normal form (DNF).
|
|
45
48
|
*/
|
|
46
49
|
private targetToDnfSubTargets;
|
|
47
|
-
constructor(user: User);
|
|
50
|
+
constructor(user: User, databaseId: DatabaseId);
|
|
48
51
|
/**
|
|
49
52
|
* Adds a new entry to the collection parent index.
|
|
50
53
|
*
|
|
@@ -56,7 +59,7 @@ export declare class IndexedDbIndexManager implements IndexManager {
|
|
|
56
59
|
getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>;
|
|
57
60
|
addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
|
|
58
61
|
deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
|
|
59
|
-
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<
|
|
62
|
+
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKey[] | null>;
|
|
60
63
|
private getSubTargets;
|
|
61
64
|
/**
|
|
62
65
|
* Constructs a key range query on `DbIndexEntryStore` that unions all
|
|
@@ -67,12 +70,8 @@ export declare class IndexedDbIndexManager implements IndexManager {
|
|
|
67
70
|
private generateLowerBound;
|
|
68
71
|
/** Generates the upper bound for `arrayValue` and `directionalValue`. */
|
|
69
72
|
private generateUpperBound;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* and user.
|
|
73
|
-
*/
|
|
74
|
-
private generateEmptyBound;
|
|
75
|
-
getFieldIndex(transaction: PersistenceTransaction, target: Target): PersistencePromise<FieldIndex | null>;
|
|
73
|
+
private getFieldIndex;
|
|
74
|
+
getIndexType(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexType>;
|
|
76
75
|
/**
|
|
77
76
|
* Returns the byte encoded form of the directional values in the field index.
|
|
78
77
|
* Returns `null` if the document does not have all fields specified in the
|
|
@@ -81,6 +80,11 @@ export declare class IndexedDbIndexManager implements IndexManager {
|
|
|
81
80
|
private encodeDirectionalElements;
|
|
82
81
|
/** Encodes a single value to the ascending index format. */
|
|
83
82
|
private encodeSingleElement;
|
|
83
|
+
/**
|
|
84
|
+
* Returns an encoded form of the document key that sorts based on the key
|
|
85
|
+
* ordering of the field index.
|
|
86
|
+
*/
|
|
87
|
+
private encodeDirectionalKey;
|
|
84
88
|
/**
|
|
85
89
|
* Encodes the given field values according to the specification in `target`.
|
|
86
90
|
* For IN queries, a list of possible values is returned.
|
|
@@ -124,4 +128,5 @@ export declare class IndexedDbIndexManager implements IndexManager {
|
|
|
124
128
|
* '[foo > 2 && foo != 3]` becomes `[foo > 2 && < 3, foo > 3]`.
|
|
125
129
|
*/
|
|
126
130
|
private createRange;
|
|
131
|
+
getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>;
|
|
127
132
|
}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { MutableDocument } from '../model/document';
|
|
18
|
+
import { DocumentKey } from '../model/document_key';
|
|
18
19
|
import { LocalSerializer } from './local_serializer';
|
|
19
20
|
import { RemoteDocumentCache } from './remote_document_cache';
|
|
20
21
|
export interface DocumentSizeEntry {
|
|
@@ -25,3 +26,11 @@ export interface IndexedDbRemoteDocumentCache extends RemoteDocumentCache {
|
|
|
25
26
|
}
|
|
26
27
|
/** Creates a new IndexedDbRemoteDocumentCache. */
|
|
27
28
|
export declare function newIndexedDbRemoteDocumentCache(serializer: LocalSerializer): IndexedDbRemoteDocumentCache;
|
|
29
|
+
/**
|
|
30
|
+
* Comparator that compares document keys according to the primary key sorting
|
|
31
|
+
* used by the `DbRemoteDocumentDocument` store (by prefix path, collection id
|
|
32
|
+
* and then document ID).
|
|
33
|
+
*
|
|
34
|
+
* Visible for testing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function dbKeyComparator(l: DocumentKey, r: DocumentKey): number;
|
|
@@ -20,6 +20,7 @@ import { BundledQuery } from '../protos/firestore_bundle_proto';
|
|
|
20
20
|
import { Document as ProtoDocument, DocumentsTarget as ProtoDocumentsTarget, QueryTarget as ProtoQueryTarget, Write as ProtoWrite } from '../protos/firestore_proto_api';
|
|
21
21
|
import { EncodedResourcePath } from './encoded_resource_path';
|
|
22
22
|
import { DbTimestampKey } from './indexeddb_sentinels';
|
|
23
|
+
export declare const INDEXING_ENABLED = false;
|
|
23
24
|
export declare const INDEXING_SCHEMA_VERSION = 14;
|
|
24
25
|
/**
|
|
25
26
|
* Schema Version for the Web client:
|
|
@@ -470,8 +471,13 @@ export interface DbIndexEntry {
|
|
|
470
471
|
arrayValue: Uint8Array;
|
|
471
472
|
/** The encoded directional value for equality and inequality filters. */
|
|
472
473
|
directionalValue: Uint8Array;
|
|
473
|
-
/**
|
|
474
|
-
|
|
474
|
+
/**
|
|
475
|
+
* The document key this entry points to. This entry is encoded by an ordered
|
|
476
|
+
* encoder to match the key order of the index.
|
|
477
|
+
*/
|
|
478
|
+
orderedDocumentKey: Uint8Array;
|
|
479
|
+
/** The segments of the document key this entry points to. */
|
|
480
|
+
documentKey: string[];
|
|
475
481
|
}
|
|
476
482
|
/**
|
|
477
483
|
* An object representing a document overlay.
|
|
@@ -204,9 +204,16 @@ export declare const DbIndexStateSequenceNumberIndexPath: string[];
|
|
|
204
204
|
/**
|
|
205
205
|
* The key for each index entry consists of the index id and its user id,
|
|
206
206
|
* the encoded array and directional value for the indexed fields as well as
|
|
207
|
-
*
|
|
207
|
+
* an ordered and an encoded document path for the indexed document.
|
|
208
208
|
*/
|
|
209
|
-
export declare type DbIndexEntryKey = [
|
|
209
|
+
export declare type DbIndexEntryKey = [
|
|
210
|
+
number,
|
|
211
|
+
string,
|
|
212
|
+
Uint8Array,
|
|
213
|
+
Uint8Array,
|
|
214
|
+
Uint8Array,
|
|
215
|
+
string[]
|
|
216
|
+
];
|
|
210
217
|
/** Name of the IndexedDb object store. */
|
|
211
218
|
export declare const DbIndexEntryStore = "indexEntries";
|
|
212
219
|
export declare const DbIndexEntryKeyPath: string[];
|
|
@@ -33,7 +33,7 @@ import { RemoteDocumentCache } from './remote_document_cache';
|
|
|
33
33
|
export declare class LocalDocumentsView {
|
|
34
34
|
readonly remoteDocumentCache: RemoteDocumentCache;
|
|
35
35
|
readonly mutationQueue: MutationQueue;
|
|
36
|
-
readonly indexManager
|
|
36
|
+
private readonly indexManager;
|
|
37
37
|
constructor(remoteDocumentCache: RemoteDocumentCache, mutationQueue: MutationQueue, indexManager: IndexManager);
|
|
38
38
|
/**
|
|
39
39
|
* Get the local view of the document identified by `key`.
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { Target } from '../core/target';
|
|
18
|
-
import {
|
|
18
|
+
import { DocumentMap } from '../model/collections';
|
|
19
|
+
import { DocumentKey } from '../model/document_key';
|
|
19
20
|
import { FieldIndex, IndexOffset } from '../model/field_index';
|
|
20
21
|
import { ResourcePath } from '../model/path';
|
|
21
|
-
import { IndexManager } from './index_manager';
|
|
22
|
+
import { IndexManager, IndexType } from './index_manager';
|
|
22
23
|
import { PersistencePromise } from './persistence_promise';
|
|
23
24
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
24
25
|
/**
|
|
@@ -30,10 +31,11 @@ export declare class MemoryIndexManager implements IndexManager {
|
|
|
30
31
|
getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<ResourcePath[]>;
|
|
31
32
|
addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
|
|
32
33
|
deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
|
|
33
|
-
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<
|
|
34
|
-
|
|
34
|
+
getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKey[] | null>;
|
|
35
|
+
getIndexType(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexType>;
|
|
35
36
|
getFieldIndexes(transaction: PersistenceTransaction, collectionGroup?: string): PersistencePromise<FieldIndex[]>;
|
|
36
37
|
getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
|
|
38
|
+
getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>;
|
|
37
39
|
updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
|
|
38
40
|
updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
|
|
39
41
|
}
|
|
@@ -17,14 +17,35 @@
|
|
|
17
17
|
import { Query } from '../core/query';
|
|
18
18
|
import { SnapshotVersion } from '../core/snapshot_version';
|
|
19
19
|
import { DocumentKeySet, DocumentMap } from '../model/collections';
|
|
20
|
+
import { IndexManager } from './index_manager';
|
|
20
21
|
import { LocalDocumentsView } from './local_documents_view';
|
|
21
22
|
import { PersistencePromise } from './persistence_promise';
|
|
22
23
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* The Firestore query engine.
|
|
26
|
+
*
|
|
27
|
+
* Firestore queries can be executed in three modes. The Query Engine determines
|
|
28
|
+
* what mode to use based on what data is persisted. The mode only determines
|
|
29
|
+
* the runtime complexity of the query - the result set is equivalent across all
|
|
30
|
+
* implementations.
|
|
31
|
+
*
|
|
32
|
+
* The Query engine will use indexed-based execution if a user has configured
|
|
33
|
+
* any index that can be used to execute query (via `setIndexConfiguration()`).
|
|
34
|
+
* Otherwise, the engine will try to optimize the query by re-using a previously
|
|
35
|
+
* persisted query result. If that is not possible, the query will be executed
|
|
36
|
+
* via a full collection scan.
|
|
37
|
+
*
|
|
38
|
+
* Index-based execution is the default when available. The query engine
|
|
39
|
+
* supports partial indexed execution and merges the result from the index
|
|
40
|
+
* lookup with documents that have not yet been indexed. The index evaluation
|
|
41
|
+
* matches the backend's format and as such, the SDK can use indexing for all
|
|
42
|
+
* queries that the backend supports.
|
|
43
|
+
*
|
|
44
|
+
* If no index exists, the query engine tries to take advantage of the target
|
|
45
|
+
* document mapping in the TargetCache. These mappings exists for all queries
|
|
46
|
+
* that have been synced with the backend at least once and allow the query
|
|
47
|
+
* engine to only read documents that previously matched a query plus any
|
|
48
|
+
* documents that were edited after the query was last listened to.
|
|
28
49
|
*
|
|
29
50
|
* There are some cases when this optimization is not guaranteed to produce
|
|
30
51
|
* the same results as full collection scans. In these cases, query
|
|
@@ -40,16 +61,29 @@ import { PersistenceTransaction } from './persistence_transaction';
|
|
|
40
61
|
*/
|
|
41
62
|
export declare class QueryEngine {
|
|
42
63
|
private localDocumentsView;
|
|
64
|
+
private indexManager;
|
|
65
|
+
private initialized;
|
|
43
66
|
/** Sets the document view to query against. */
|
|
44
|
-
|
|
67
|
+
initialize(localDocuments: LocalDocumentsView, indexManager: IndexManager): void;
|
|
45
68
|
/** Returns all local documents matching the specified query. */
|
|
46
69
|
getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, lastLimboFreeSnapshotVersion: SnapshotVersion, remoteKeys: DocumentKeySet): PersistencePromise<DocumentMap>;
|
|
70
|
+
/**
|
|
71
|
+
* Performs an indexed query that evaluates the query based on a collection's
|
|
72
|
+
* persisted index values. Returns `null` if an index is not available.
|
|
73
|
+
*/
|
|
74
|
+
private performQueryUsingIndex;
|
|
75
|
+
/**
|
|
76
|
+
* Performs a query based on the target's persisted query mapping. Returns
|
|
77
|
+
* `null` if the mapping is not available or cannot be used.
|
|
78
|
+
*/
|
|
79
|
+
private performQueryUsingRemoteKeys;
|
|
47
80
|
/** Applies the query filter and sorting to the provided documents. */
|
|
48
81
|
private applyQuery;
|
|
49
82
|
/**
|
|
50
83
|
* Determines if a limit query needs to be refilled from cache, making it
|
|
51
84
|
* ineligible for index-free execution.
|
|
52
85
|
*
|
|
86
|
+
* @param query The query.
|
|
53
87
|
* @param sortedPreviousResults - The documents that matched the query when it
|
|
54
88
|
* was last synchronized, sorted by the query's comparator.
|
|
55
89
|
* @param remoteKeys - The document keys that matched the query at the last
|
|
@@ -59,4 +93,9 @@ export declare class QueryEngine {
|
|
|
59
93
|
*/
|
|
60
94
|
private needsRefill;
|
|
61
95
|
private executeFullCollectionScan;
|
|
96
|
+
/**
|
|
97
|
+
* Combines the results from an indexed execution with the remaining documents
|
|
98
|
+
* that have not yet been indexed.
|
|
99
|
+
*/
|
|
100
|
+
private appendRemainingResults;
|
|
62
101
|
}
|
|
@@ -186,6 +186,8 @@ export declare class SimpleDbStore<KeyType extends IDBValidKey, ValueType extend
|
|
|
186
186
|
loadAll(): PersistencePromise<ValueType[]>;
|
|
187
187
|
/** Loads all elements for the index range from the object store. */
|
|
188
188
|
loadAll(range: IDBKeyRange): PersistencePromise<ValueType[]>;
|
|
189
|
+
/** Loads all elements ordered by the given index. */
|
|
190
|
+
loadAll(index: string): PersistencePromise<ValueType[]>;
|
|
189
191
|
/**
|
|
190
192
|
* Loads all elements from the object store that fall into the provided in the
|
|
191
193
|
* index range for the given index.
|
|
@@ -31,7 +31,7 @@ export interface DocumentSizeEntries {
|
|
|
31
31
|
sizeMap: SortedMap<DocumentKey, number>;
|
|
32
32
|
}
|
|
33
33
|
export declare type DocumentMap = SortedMap<DocumentKey, Document>;
|
|
34
|
-
export declare function documentMap(): DocumentMap;
|
|
34
|
+
export declare function documentMap(...docs: Document[]): DocumentMap;
|
|
35
35
|
export declare type OverlayMap = ObjectMap<DocumentKey, Overlay>;
|
|
36
36
|
export declare function newOverlayMap(): OverlayMap;
|
|
37
37
|
export declare type MutationMap = ObjectMap<DocumentKey, Mutation>;
|
|
@@ -70,6 +70,12 @@ export declare class FieldIndex {
|
|
|
70
70
|
export declare function fieldIndexGetArraySegment(fieldIndex: FieldIndex): IndexSegment | undefined;
|
|
71
71
|
/** Returns all directional (ascending/descending) segments for this index. */
|
|
72
72
|
export declare function fieldIndexGetDirectionalSegments(fieldIndex: FieldIndex): IndexSegment[];
|
|
73
|
+
/**
|
|
74
|
+
* Returns the order of the document key component for the given index.
|
|
75
|
+
*
|
|
76
|
+
* PORTING NOTE: This is only used in the Web IndexedDb implementation.
|
|
77
|
+
*/
|
|
78
|
+
export declare function fieldIndexGetKeyOrder(fieldIndex: FieldIndex): IndexKind;
|
|
73
79
|
/**
|
|
74
80
|
* Compares indexes by collection group and segments. Ignores update time and
|
|
75
81
|
* index ID.
|
|
@@ -81,5 +81,17 @@ export declare function isMaxValue(value: Value): boolean;
|
|
|
81
81
|
export declare function valuesGetLowerBound(value: Value): Value;
|
|
82
82
|
/** Returns the largest value for the given value type (exclusive). */
|
|
83
83
|
export declare function valuesGetUpperBound(value: Value): Value;
|
|
84
|
-
export declare function
|
|
85
|
-
|
|
84
|
+
export declare function lowerBoundCompare(left: {
|
|
85
|
+
value: Value;
|
|
86
|
+
inclusive: boolean;
|
|
87
|
+
}, right: {
|
|
88
|
+
value: Value;
|
|
89
|
+
inclusive: boolean;
|
|
90
|
+
}): number;
|
|
91
|
+
export declare function upperBoundCompare(left: {
|
|
92
|
+
value: Value;
|
|
93
|
+
inclusive: boolean;
|
|
94
|
+
}, right: {
|
|
95
|
+
value: Value;
|
|
96
|
+
inclusive: boolean;
|
|
97
|
+
}): number;
|
|
@@ -25,6 +25,9 @@ export declare function primitiveComparator<T>(left: T, right: T): number;
|
|
|
25
25
|
export interface Equatable<T> {
|
|
26
26
|
isEqual(other: T): boolean;
|
|
27
27
|
}
|
|
28
|
+
export interface Iterable<V> {
|
|
29
|
+
forEach: (cb: (v: V) => void) => void;
|
|
30
|
+
}
|
|
28
31
|
/** Helper to compare arrays using isEqual(). */
|
|
29
32
|
export declare function arrayEquals<T>(left: T[], right: T[], comparator: (l: T, r: T) => boolean): boolean;
|
|
30
33
|
/**
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Query } from '../../../src/core/query';
|
|
18
18
|
import { SnapshotVersion } from '../../../src/core/snapshot_version';
|
|
19
|
+
import { IndexManager } from '../../../src/local/index_manager';
|
|
19
20
|
import { LocalDocumentsView } from '../../../src/local/local_documents_view';
|
|
20
21
|
import { PersistencePromise } from '../../../src/local/persistence_promise';
|
|
21
22
|
import { PersistenceTransaction } from '../../../src/local/persistence_transaction';
|
|
@@ -51,7 +52,7 @@ export declare class CountingQueryEngine extends QueryEngine {
|
|
|
51
52
|
documentsReadByKey: number;
|
|
52
53
|
resetCounts(): void;
|
|
53
54
|
getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, lastLimboFreeSnapshotVersion: SnapshotVersion, remoteKeys: DocumentKeySet): PersistencePromise<DocumentMap>;
|
|
54
|
-
|
|
55
|
+
initialize(localDocuments: LocalDocumentsView, indexManager: IndexManager): void;
|
|
55
56
|
private wrapRemoteDocumentCache;
|
|
56
57
|
private wrapMutationQueue;
|
|
57
58
|
}
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { Target } from '../../../src/core/target';
|
|
18
|
-
import { IndexManager } from '../../../src/local/index_manager';
|
|
18
|
+
import { IndexManager, IndexType } from '../../../src/local/index_manager';
|
|
19
19
|
import { Persistence } from '../../../src/local/persistence';
|
|
20
|
-
import {
|
|
20
|
+
import { DocumentMap } from '../../../src/model/collections';
|
|
21
|
+
import { DocumentKey } from '../../../src/model/document_key';
|
|
21
22
|
import { FieldIndex, IndexOffset } from '../../../src/model/field_index';
|
|
22
23
|
import { ResourcePath } from '../../../src/model/path';
|
|
23
24
|
/**
|
|
@@ -33,8 +34,8 @@ export declare class TestIndexManager {
|
|
|
33
34
|
addFieldIndex(index: FieldIndex): Promise<void>;
|
|
34
35
|
deleteFieldIndex(index: FieldIndex): Promise<void>;
|
|
35
36
|
getFieldIndexes(collectionGroup?: string): Promise<FieldIndex[]>;
|
|
36
|
-
|
|
37
|
-
getDocumentsMatchingTarget(target: Target): Promise<
|
|
37
|
+
getIndexType(target: Target): Promise<IndexType>;
|
|
38
|
+
getDocumentsMatchingTarget(target: Target): Promise<DocumentKey[] | null>;
|
|
38
39
|
getNextCollectionGroupToUpdate(): Promise<string | null>;
|
|
39
40
|
updateCollectionGroup(collectionGroup: string, offset: IndexOffset): Promise<void>;
|
|
40
41
|
updateIndexEntries(documents: DocumentMap): Promise<void>;
|
|
@@ -47,10 +47,6 @@ export declare class TestRemoteDocumentCache {
|
|
|
47
47
|
getEntries(documentKeys: DocumentKeySet): Promise<MutableDocumentMap>;
|
|
48
48
|
getAllFromCollection(collection: ResourcePath, offset: IndexOffset): Promise<MutableDocumentMap>;
|
|
49
49
|
getAllFromCollectionGroup(collectionGroup: string, offset: IndexOffset, limit: number): Promise<MutableDocumentMap>;
|
|
50
|
-
getNewDocumentChanges(sinceReadTime: SnapshotVersion): Promise<{
|
|
51
|
-
changedDocs: MutableDocumentMap;
|
|
52
|
-
readTime: SnapshotVersion;
|
|
53
|
-
}>;
|
|
54
50
|
getSize(): Promise<number>;
|
|
55
51
|
newChangeBuffer(options?: {
|
|
56
52
|
trackRemovals: boolean;
|