@powersync/service-module-mongodb-storage 0.15.4 → 0.16.0
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 +35 -0
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.js +1 -1
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.js.map +1 -1
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js +2 -2
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js.map +1 -1
- package/dist/storage/MongoBucketStorage.d.ts +2 -2
- package/dist/storage/MongoBucketStorage.js +47 -34
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/implementation/BucketDefinitionMapping.d.ts +17 -0
- package/dist/storage/implementation/BucketDefinitionMapping.js +58 -0
- package/dist/storage/implementation/BucketDefinitionMapping.js.map +1 -0
- package/dist/storage/implementation/MongoBucketBatch.d.ts +16 -14
- package/dist/storage/implementation/MongoBucketBatch.js +80 -115
- package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
- package/dist/storage/implementation/MongoBucketBatchShared.d.ts +5 -0
- package/dist/storage/implementation/MongoBucketBatchShared.js +8 -0
- package/dist/storage/implementation/MongoBucketBatchShared.js.map +1 -0
- package/dist/storage/implementation/MongoChecksums.d.ts +28 -17
- package/dist/storage/implementation/MongoChecksums.js +13 -72
- package/dist/storage/implementation/MongoChecksums.js.map +1 -1
- package/dist/storage/implementation/MongoCompactor.d.ts +98 -58
- package/dist/storage/implementation/MongoCompactor.js +229 -296
- package/dist/storage/implementation/MongoCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoParameterCompactor.d.ts +11 -6
- package/dist/storage/implementation/MongoParameterCompactor.js +11 -8
- package/dist/storage/implementation/MongoParameterCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoPersistedSyncRules.d.ts +14 -0
- package/dist/storage/implementation/MongoPersistedSyncRules.js +64 -0
- package/dist/storage/implementation/MongoPersistedSyncRules.js.map +1 -0
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.d.ts +3 -0
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.js +9 -0
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.js.map +1 -1
- package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +47 -29
- package/dist/storage/implementation/MongoSyncBucketStorage.js +94 -387
- package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/implementation/MongoSyncRulesLock.d.ts +5 -3
- package/dist/storage/implementation/MongoSyncRulesLock.js +12 -10
- package/dist/storage/implementation/MongoSyncRulesLock.js.map +1 -1
- package/dist/storage/implementation/MongoWriteCheckpointAPI.js +1 -1
- package/dist/storage/implementation/MongoWriteCheckpointAPI.js.map +1 -1
- package/dist/storage/implementation/OperationBatch.js +1 -1
- package/dist/storage/implementation/common/BucketDataDoc.d.ts +35 -0
- package/dist/storage/implementation/common/BucketDataDoc.js +2 -0
- package/dist/storage/implementation/common/BucketDataDoc.js.map +1 -0
- package/dist/storage/implementation/common/MongoSyncBucketStorageContext.d.ts +13 -0
- package/dist/storage/implementation/common/MongoSyncBucketStorageContext.js +2 -0
- package/dist/storage/implementation/common/MongoSyncBucketStorageContext.js.map +1 -0
- package/dist/storage/implementation/common/PersistedBatch.d.ts +108 -0
- package/dist/storage/implementation/common/PersistedBatch.js +237 -0
- package/dist/storage/implementation/common/PersistedBatch.js.map +1 -0
- package/dist/storage/implementation/common/SingleBucketStore.d.ts +54 -0
- package/dist/storage/implementation/common/SingleBucketStore.js +3 -0
- package/dist/storage/implementation/common/SingleBucketStore.js.map +1 -0
- package/dist/storage/implementation/common/SourceRecordStore.d.ts +36 -0
- package/dist/storage/implementation/common/SourceRecordStore.js +2 -0
- package/dist/storage/implementation/common/SourceRecordStore.js.map +1 -0
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.d.ts +27 -0
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js +57 -0
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js.map +1 -0
- package/dist/storage/implementation/createMongoSyncBucketStorage.d.ts +7 -0
- package/dist/storage/implementation/createMongoSyncBucketStorage.js +9 -0
- package/dist/storage/implementation/createMongoSyncBucketStorage.js.map +1 -0
- package/dist/storage/implementation/db.d.ts +32 -35
- package/dist/storage/implementation/db.js +77 -99
- package/dist/storage/implementation/db.js.map +1 -1
- package/dist/storage/implementation/models.d.ts +62 -33
- package/dist/storage/implementation/models.js +20 -1
- package/dist/storage/implementation/models.js.map +1 -1
- package/dist/storage/implementation/v1/MongoBucketBatchV1.d.ts +13 -0
- package/dist/storage/implementation/v1/MongoBucketBatchV1.js +22 -0
- package/dist/storage/implementation/v1/MongoBucketBatchV1.js.map +1 -0
- package/dist/storage/implementation/v1/MongoChecksumsV1.d.ts +12 -0
- package/dist/storage/implementation/v1/MongoChecksumsV1.js +56 -0
- package/dist/storage/implementation/v1/MongoChecksumsV1.js.map +1 -0
- package/dist/storage/implementation/v1/MongoCompactorV1.d.ts +23 -0
- package/dist/storage/implementation/v1/MongoCompactorV1.js +52 -0
- package/dist/storage/implementation/v1/MongoCompactorV1.js.map +1 -0
- package/dist/storage/implementation/v1/MongoParameterCompactorV1.d.ts +9 -0
- package/dist/storage/implementation/v1/MongoParameterCompactorV1.js +20 -0
- package/dist/storage/implementation/v1/MongoParameterCompactorV1.js.map +1 -0
- package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.d.ts +41 -0
- package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js +283 -0
- package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js.map +1 -0
- package/dist/storage/implementation/v1/PersistedBatchV1.d.ts +26 -0
- package/dist/storage/implementation/v1/PersistedBatchV1.js +183 -0
- package/dist/storage/implementation/v1/PersistedBatchV1.js.map +1 -0
- package/dist/storage/implementation/v1/SingleBucketStoreV1.d.ts +18 -0
- package/dist/storage/implementation/v1/SingleBucketStoreV1.js +57 -0
- package/dist/storage/implementation/v1/SingleBucketStoreV1.js.map +1 -0
- package/dist/storage/implementation/v1/SourceRecordStoreV1.d.ts +19 -0
- package/dist/storage/implementation/v1/SourceRecordStoreV1.js +105 -0
- package/dist/storage/implementation/v1/SourceRecordStoreV1.js.map +1 -0
- package/dist/storage/implementation/v1/VersionedPowerSyncMongoV1.d.ts +12 -0
- package/dist/storage/implementation/v1/VersionedPowerSyncMongoV1.js +20 -0
- package/dist/storage/implementation/v1/VersionedPowerSyncMongoV1.js.map +1 -0
- package/dist/storage/implementation/v1/models.d.ts +34 -0
- package/dist/storage/implementation/v1/models.js +37 -0
- package/dist/storage/implementation/v1/models.js.map +1 -0
- package/dist/storage/implementation/v3/MongoBucketBatchV3.d.ts +13 -0
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js +34 -0
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoChecksumsV3.d.ts +15 -0
- package/dist/storage/implementation/v3/MongoChecksumsV3.js +84 -0
- package/dist/storage/implementation/v3/MongoChecksumsV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoCompactorV3.d.ts +23 -0
- package/dist/storage/implementation/v3/MongoCompactorV3.js +68 -0
- package/dist/storage/implementation/v3/MongoCompactorV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoParameterCompactorV3.d.ts +9 -0
- package/dist/storage/implementation/v3/MongoParameterCompactorV3.js +18 -0
- package/dist/storage/implementation/v3/MongoParameterCompactorV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoParameterLookupV3.d.ts +5 -0
- package/dist/storage/implementation/v3/MongoParameterLookupV3.js +9 -0
- package/dist/storage/implementation/v3/MongoParameterLookupV3.js.map +1 -0
- package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.d.ts +41 -0
- package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js +407 -0
- package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js.map +1 -0
- package/dist/storage/implementation/v3/PersistedBatchV3.d.ts +29 -0
- package/dist/storage/implementation/v3/PersistedBatchV3.js +259 -0
- package/dist/storage/implementation/v3/PersistedBatchV3.js.map +1 -0
- package/dist/storage/implementation/v3/SingleBucketStoreV3.d.ts +18 -0
- package/dist/storage/implementation/v3/SingleBucketStoreV3.js +48 -0
- package/dist/storage/implementation/v3/SingleBucketStoreV3.js.map +1 -0
- package/dist/storage/implementation/v3/SourceRecordStoreV3.d.ts +22 -0
- package/dist/storage/implementation/v3/SourceRecordStoreV3.js +164 -0
- package/dist/storage/implementation/v3/SourceRecordStoreV3.js.map +1 -0
- package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.d.ts +21 -0
- package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.js +71 -0
- package/dist/storage/implementation/v3/VersionedPowerSyncMongoV3.js.map +1 -0
- package/dist/storage/implementation/v3/models.d.ts +43 -0
- package/dist/storage/implementation/v3/models.js +34 -0
- package/dist/storage/implementation/v3/models.js.map +1 -0
- package/dist/storage/storage-index.d.ts +6 -3
- package/dist/storage/storage-index.js +6 -3
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/utils/util.d.ts +10 -3
- package/dist/utils/util.js +24 -3
- package/dist/utils/util.js.map +1 -1
- package/package.json +9 -9
- package/src/migrations/db/migrations/1688556755264-initial-sync-rules.ts +1 -1
- package/src/migrations/db/migrations/1702295701188-sync-rule-state.ts +6 -6
- package/src/storage/MongoBucketStorage.ts +92 -59
- package/src/storage/implementation/BucketDefinitionMapping.ts +72 -0
- package/src/storage/implementation/MongoBucketBatch.ts +110 -144
- package/src/storage/implementation/MongoBucketBatchShared.ts +11 -0
- package/src/storage/implementation/MongoChecksums.ts +52 -75
- package/src/storage/implementation/MongoCompactor.ts +374 -404
- package/src/storage/implementation/MongoParameterCompactor.ts +37 -24
- package/src/storage/implementation/MongoPersistedSyncRules.ts +76 -0
- package/src/storage/implementation/MongoPersistedSyncRulesContent.ts +17 -0
- package/src/storage/implementation/MongoSyncBucketStorage.ts +181 -455
- package/src/storage/implementation/MongoSyncRulesLock.ts +11 -13
- package/src/storage/implementation/MongoWriteCheckpointAPI.ts +3 -1
- package/src/storage/implementation/OperationBatch.ts +1 -1
- package/src/storage/implementation/common/BucketDataDoc.ts +37 -0
- package/src/storage/implementation/common/MongoSyncBucketStorageContext.ts +15 -0
- package/src/storage/implementation/common/PersistedBatch.ts +364 -0
- package/src/storage/implementation/common/SingleBucketStore.ts +63 -0
- package/src/storage/implementation/common/SourceRecordStore.ts +49 -0
- package/src/storage/implementation/common/VersionedPowerSyncMongoBase.ts +80 -0
- package/src/storage/implementation/createMongoSyncBucketStorage.ts +25 -0
- package/src/storage/implementation/db.ts +105 -129
- package/src/storage/implementation/models.ts +82 -36
- package/src/storage/implementation/v1/MongoBucketBatchV1.ts +32 -0
- package/src/storage/implementation/v1/MongoChecksumsV1.ts +75 -0
- package/src/storage/implementation/v1/MongoCompactorV1.ts +93 -0
- package/src/storage/implementation/v1/MongoParameterCompactorV1.ts +26 -0
- package/src/storage/implementation/v1/MongoSyncBucketStorageV1.ts +448 -0
- package/src/storage/implementation/v1/PersistedBatchV1.ts +230 -0
- package/src/storage/implementation/v1/SingleBucketStoreV1.ts +74 -0
- package/src/storage/implementation/v1/SourceRecordStoreV1.ts +156 -0
- package/src/storage/implementation/v1/VersionedPowerSyncMongoV1.ts +28 -0
- package/src/storage/implementation/v1/models.ts +84 -0
- package/src/storage/implementation/v3/MongoBucketBatchV3.ts +44 -0
- package/src/storage/implementation/v3/MongoChecksumsV3.ts +120 -0
- package/src/storage/implementation/v3/MongoCompactorV3.ts +107 -0
- package/src/storage/implementation/v3/MongoParameterCompactorV3.ts +24 -0
- package/src/storage/implementation/v3/MongoParameterLookupV3.ts +12 -0
- package/src/storage/implementation/v3/MongoSyncBucketStorageV3.ts +550 -0
- package/src/storage/implementation/v3/PersistedBatchV3.ts +318 -0
- package/src/storage/implementation/v3/SingleBucketStoreV3.ts +68 -0
- package/src/storage/implementation/v3/SourceRecordStoreV3.ts +226 -0
- package/src/storage/implementation/v3/VersionedPowerSyncMongoV3.ts +112 -0
- package/src/storage/implementation/v3/models.ts +96 -0
- package/src/storage/storage-index.ts +6 -3
- package/src/utils/util.ts +34 -5
- package/test/src/storage_compacting.test.ts +57 -29
- package/test/src/storage_sync.test.ts +351 -5
- package/test/tsconfig.json +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/storage/implementation/PersistedBatch.d.ts +0 -71
- package/dist/storage/implementation/PersistedBatch.js +0 -354
- package/dist/storage/implementation/PersistedBatch.js.map +0 -1
- package/src/storage/implementation/PersistedBatch.ts +0 -432
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as lib_mongo from '@powersync/lib-service-mongodb';
|
|
2
1
|
import {
|
|
3
2
|
addPartialChecksums,
|
|
4
3
|
bson,
|
|
@@ -13,8 +12,24 @@ import {
|
|
|
13
12
|
PartialChecksumMap,
|
|
14
13
|
PartialOrFullChecksum
|
|
15
14
|
} from '@powersync/service-core';
|
|
16
|
-
import { VersionedPowerSyncMongo } from './db.js';
|
|
17
|
-
|
|
15
|
+
import type { VersionedPowerSyncMongo } from './db.js';
|
|
16
|
+
|
|
17
|
+
import * as lib_mongo from '@powersync/lib-service-mongodb';
|
|
18
|
+
import { BucketDefinitionId, BucketDefinitionMapping } from './BucketDefinitionMapping.js';
|
|
19
|
+
import { BucketDataDocumentBase, StorageConfig } from './models.js';
|
|
20
|
+
|
|
21
|
+
export interface FetchPartialBucketChecksumV3 {
|
|
22
|
+
bucket: string;
|
|
23
|
+
definitionId: BucketDefinitionId;
|
|
24
|
+
start?: InternalOpId;
|
|
25
|
+
end: InternalOpId;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FetchPartialBucketChecksumByBucket {
|
|
29
|
+
bucket: string;
|
|
30
|
+
start?: InternalOpId;
|
|
31
|
+
end: InternalOpId;
|
|
32
|
+
}
|
|
18
33
|
|
|
19
34
|
/**
|
|
20
35
|
* Checksum calculation options, primarily for tests.
|
|
@@ -31,28 +46,20 @@ export interface MongoChecksumOptions {
|
|
|
31
46
|
operationBatchLimit?: number;
|
|
32
47
|
|
|
33
48
|
storageConfig: StorageConfig;
|
|
49
|
+
mapping?: BucketDefinitionMapping;
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
const DEFAULT_BUCKET_BATCH_LIMIT = 200;
|
|
37
53
|
const DEFAULT_OPERATION_BATCH_LIMIT = 50_000;
|
|
38
54
|
|
|
39
|
-
|
|
40
|
-
* Checksum query implementation.
|
|
41
|
-
*
|
|
42
|
-
* General implementation flow is:
|
|
43
|
-
* 1. getChecksums() -> check cache for (partial) matches. If not found or partial match, query the remainder using computePartialChecksums().
|
|
44
|
-
* 2. computePartialChecksums() -> query bucket_state for partial matches. Query the remainder using computePartialChecksumsDirect().
|
|
45
|
-
* 3. computePartialChecksumsDirect() -> split into batches of 200 buckets at a time -> computePartialChecksumsInternal()
|
|
46
|
-
* 4. computePartialChecksumsInternal() -> aggregate over 50_000 operations in bucket_data at a time
|
|
47
|
-
*/
|
|
48
|
-
export class MongoChecksums {
|
|
55
|
+
export abstract class MongoChecksums {
|
|
49
56
|
private _cache: ChecksumCache | undefined;
|
|
50
57
|
private readonly storageConfig: StorageConfig;
|
|
51
58
|
|
|
52
59
|
constructor(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
protected readonly db: VersionedPowerSyncMongo,
|
|
61
|
+
protected readonly group_id: number,
|
|
62
|
+
protected readonly options: MongoChecksumOptions
|
|
56
63
|
) {
|
|
57
64
|
this.storageConfig = options.storageConfig;
|
|
58
65
|
}
|
|
@@ -96,41 +103,7 @@ export class MongoChecksums {
|
|
|
96
103
|
if (batch.length == 0) {
|
|
97
104
|
return new Map();
|
|
98
105
|
}
|
|
99
|
-
|
|
100
|
-
const preFilters: any[] = [];
|
|
101
|
-
for (let request of batch) {
|
|
102
|
-
if (request.start == null) {
|
|
103
|
-
preFilters.push({
|
|
104
|
-
_id: {
|
|
105
|
-
g: this.group_id,
|
|
106
|
-
b: request.bucket
|
|
107
|
-
},
|
|
108
|
-
'compacted_state.op_id': { $exists: true, $lte: request.end }
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const preStates = new Map<string, { opId: InternalOpId; checksum: BucketChecksum }>();
|
|
114
|
-
|
|
115
|
-
if (preFilters.length > 0) {
|
|
116
|
-
// For un-cached bucket checksums, attempt to use the compacted state first.
|
|
117
|
-
const states = await this.db.bucket_state
|
|
118
|
-
.find({
|
|
119
|
-
$or: preFilters
|
|
120
|
-
})
|
|
121
|
-
.toArray();
|
|
122
|
-
for (let state of states) {
|
|
123
|
-
const compactedState = state.compacted_state!;
|
|
124
|
-
preStates.set(state._id.b, {
|
|
125
|
-
opId: compactedState.op_id,
|
|
126
|
-
checksum: {
|
|
127
|
-
bucket: state._id.b,
|
|
128
|
-
checksum: Number(compactedState.checksum),
|
|
129
|
-
count: compactedState.count
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
106
|
+
const preStates = await this.fetchPreStates(batch);
|
|
134
107
|
|
|
135
108
|
const mappedRequests = batch.map((request) => {
|
|
136
109
|
let start = request.start;
|
|
@@ -199,11 +172,24 @@ export class MongoChecksums {
|
|
|
199
172
|
*
|
|
200
173
|
* `batch` must be limited to DEFAULT_BUCKET_BATCH_LIMIT buckets before calling this.
|
|
201
174
|
*/
|
|
202
|
-
|
|
175
|
+
protected abstract computePartialChecksumsInternal(batch: FetchPartialBucketChecksum[]): Promise<PartialChecksumMap>;
|
|
176
|
+
|
|
177
|
+
protected abstract fetchPreStates(
|
|
178
|
+
batch: FetchPartialBucketChecksum[]
|
|
179
|
+
): Promise<Map<string, { opId: InternalOpId; checksum: BucketChecksum }>>;
|
|
180
|
+
|
|
181
|
+
protected async computePartialChecksumsForCollection<
|
|
182
|
+
TRequest extends FetchPartialBucketChecksumByBucket,
|
|
183
|
+
TBucketDataDocument extends BucketDataDocumentBase
|
|
184
|
+
>(
|
|
185
|
+
batch: TRequest[],
|
|
186
|
+
collection: lib_mongo.mongo.Collection<TBucketDataDocument>,
|
|
187
|
+
createFilter: (request: TRequest) => any
|
|
188
|
+
): Promise<PartialChecksumMap> {
|
|
203
189
|
const batchLimit = this.options?.operationBatchLimit ?? DEFAULT_OPERATION_BATCH_LIMIT;
|
|
204
190
|
|
|
205
191
|
// Map requests by bucket. We adjust this as we get partial results.
|
|
206
|
-
let requests = new Map<string,
|
|
192
|
+
let requests = new Map<string, TRequest>();
|
|
207
193
|
for (let request of batch) {
|
|
208
194
|
requests.set(request.bucket, request);
|
|
209
195
|
}
|
|
@@ -211,23 +197,7 @@ export class MongoChecksums {
|
|
|
211
197
|
const partialChecksums = new Map<string, PartialOrFullChecksum>();
|
|
212
198
|
|
|
213
199
|
while (requests.size > 0) {
|
|
214
|
-
const filters
|
|
215
|
-
for (let request of requests.values()) {
|
|
216
|
-
filters.push({
|
|
217
|
-
_id: {
|
|
218
|
-
$gt: {
|
|
219
|
-
g: this.group_id,
|
|
220
|
-
b: request.bucket,
|
|
221
|
-
o: request.start ?? new bson.MinKey()
|
|
222
|
-
},
|
|
223
|
-
$lte: {
|
|
224
|
-
g: this.group_id,
|
|
225
|
-
b: request.bucket,
|
|
226
|
-
o: request.end
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
200
|
+
const filters = Array.from(requests.values(), createFilter);
|
|
231
201
|
|
|
232
202
|
// Historically, checksum may be stored as 'int' or 'double'.
|
|
233
203
|
// More recently, this should be a 'long'.
|
|
@@ -243,7 +213,7 @@ export class MongoChecksums {
|
|
|
243
213
|
// Returns: B[3-10], C[1-4]
|
|
244
214
|
// 3. Query: C[5-end]
|
|
245
215
|
// Returns: C[5-10]
|
|
246
|
-
const aggregate = await
|
|
216
|
+
const aggregate = await collection
|
|
247
217
|
.aggregate(
|
|
248
218
|
[
|
|
249
219
|
{
|
|
@@ -298,10 +268,8 @@ export class MongoChecksums {
|
|
|
298
268
|
limitReached = true;
|
|
299
269
|
const req = requests.get(bucket);
|
|
300
270
|
requests.set(bucket, {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
start: doc.last_op,
|
|
304
|
-
end: req!.end
|
|
271
|
+
...req!,
|
|
272
|
+
start: doc.last_op
|
|
305
273
|
});
|
|
306
274
|
} else {
|
|
307
275
|
// All done for this bucket
|
|
@@ -339,6 +307,15 @@ export class MongoChecksums {
|
|
|
339
307
|
}
|
|
340
308
|
}
|
|
341
309
|
|
|
310
|
+
export function emptyChecksumForRequest(
|
|
311
|
+
request: Pick<FetchPartialBucketChecksum | FetchPartialBucketChecksumV3, 'bucket' | 'start'>
|
|
312
|
+
): PartialOrFullChecksum {
|
|
313
|
+
if (request.start == null) {
|
|
314
|
+
return { bucket: request.bucket, count: 0, checksum: 0 };
|
|
315
|
+
}
|
|
316
|
+
return { bucket: request.bucket, partialCount: 0, partialChecksum: 0 };
|
|
317
|
+
}
|
|
318
|
+
|
|
342
319
|
/**
|
|
343
320
|
* Convert output of the $group stage into a checksum.
|
|
344
321
|
*/
|