@@ -70,10 +70,9 @@ export class BucketChecksumState {
70
70
const storage = this . bucketStorage ;
71
71
72
72
const update = await this . parameterState . getCheckpointUpdate ( next ) ;
73
- if ( update == null ) {
73
+ if ( update == null && this . lastWriteCheckpoint == writeCheckpoint ) {
74
74
return null ;
75
75
}
76
-
77
76
const { buckets : allBuckets , updatedBuckets } = update ;
78
77
79
78
let dataBucketsNew = new Map < string , BucketSyncState > ( ) ;
@@ -115,16 +114,19 @@ export class BucketChecksumState {
115
114
}
116
115
}
117
116
118
- let updatedChecksums = await storage . getChecksums ( base . checkpoint , checksumLookups ) ;
119
- for ( let [ bucket , value ] of updatedChecksums . entries ( ) ) {
120
- newChecksums . set ( bucket , value ) ;
117
+ if ( checksumLookups . length > 0 ) {
118
+ let updatedChecksums = await storage . getChecksums ( base . checkpoint , checksumLookups ) ;
119
+ for ( let [ bucket , value ] of updatedChecksums . entries ( ) ) {
120
+ newChecksums . set ( bucket , value ) ;
121
+ }
121
122
}
122
123
checksumMap = newChecksums ;
123
124
} else {
124
125
// Re-check all buckets
125
126
const bucketList = [ ...dataBucketsNew . keys ( ) ] ;
126
127
checksumMap = await storage . getChecksums ( base . checkpoint , bucketList ) ;
127
128
}
129
+
128
130
// Subset of buckets for which there may be new data in this batch.
129
131
let bucketsToFetch : BucketDescription [ ] ;
130
132
@@ -291,19 +293,15 @@ export class BucketParameterState {
291
293
this . lookups = new Set < string > ( this . querier . parameterQueryLookups . map ( ( l ) => JSONBig . stringify ( l . values ) ) ) ;
292
294
}
293
295
294
- async getCheckpointUpdate ( checkpoint : storage . StorageCheckpointUpdate ) : Promise < CheckpointUpdate | null > {
296
+ async getCheckpointUpdate ( checkpoint : storage . StorageCheckpointUpdate ) : Promise < CheckpointUpdate > {
295
297
const querier = this . querier ;
296
- let update : CheckpointUpdate | null ;
298
+ let update : CheckpointUpdate ;
297
299
if ( querier . hasDynamicBuckets ) {
298
300
update = await this . getCheckpointUpdateDynamic ( checkpoint ) ;
299
301
} else {
300
302
update = await this . getCheckpointUpdateStatic ( checkpoint ) ;
301
303
}
302
304
303
- if ( update == null ) {
304
- return null ;
305
- }
306
-
307
305
if ( update . buckets . length > this . context . maxParameterQueryResults ) {
308
306
// TODO: Limit number of results even before we get to this point
309
307
// This limit applies _before_ we get the unique set
@@ -325,9 +323,7 @@ export class BucketParameterState {
325
323
/**
326
324
* For static buckets, we can keep track of which buckets have been updated.
327
325
*/
328
- private async getCheckpointUpdateStatic (
329
- checkpoint : storage . StorageCheckpointUpdate
330
- ) : Promise < CheckpointUpdate | null > {
326
+ private async getCheckpointUpdateStatic ( checkpoint : storage . StorageCheckpointUpdate ) : Promise < CheckpointUpdate > {
331
327
const querier = this . querier ;
332
328
const update = checkpoint . update ;
333
329
@@ -339,12 +335,6 @@ export class BucketParameterState {
339
335
}
340
336
341
337
const updatedBuckets = new Set < string > ( getIntersection ( this . staticBuckets , update . updatedDataBuckets ) ) ;
342
-
343
- if ( updatedBuckets . size == 0 ) {
344
- // No change - skip this checkpoint
345
- return null ;
346
- }
347
-
348
338
return {
349
339
buckets : querier . staticBuckets ,
350
340
updatedBuckets
@@ -354,9 +344,7 @@ export class BucketParameterState {
354
344
/**
355
345
* For dynamic buckets, we need to re-query the list of buckets every time.
356
346
*/
357
- private async getCheckpointUpdateDynamic (
358
- checkpoint : storage . StorageCheckpointUpdate
359
- ) : Promise < CheckpointUpdate | null > {
347
+ private async getCheckpointUpdateDynamic ( checkpoint : storage . StorageCheckpointUpdate ) : Promise < CheckpointUpdate > {
360
348
const querier = this . querier ;
361
349
const storage = this . bucketStorage ;
362
350
const staticBuckets = querier . staticBuckets ;
0 commit comments