Skip to content

Commit af17b59

Browse files
committed
fix formatting
1 parent 9c866eb commit af17b59

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

packages/firestore/src/remote/bloom_filter.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ export class BloomFilter {
7979

8080
// Calculate the ith hash value based on the hashed 64bit integers,
8181
// and calculate its corresponding bit index in the bitmap to be checked.
82-
private getBitIndex(num1: Integer, num2: Integer, index: number): number {
82+
private getBitIndex(num1: Integer, num2: Integer, hashIndex: number): number {
8383
// Calculate hashed value h(i) = h1 + (i * h2).
84-
let hashValue = num1.add(num2.multiply(Integer.fromNumber(index)));
84+
let hashValue = num1.add(num2.multiply(Integer.fromNumber(hashIndex)));
8585
// Wrap if hash value overflow 64bit.
8686
if (hashValue.compare(MAX_64_BIT_UNSIGNED_INTEGER) === 1) {
8787
hashValue = new Integer([hashValue.getBits(0), hashValue.getBits(1)], 0);
@@ -127,10 +127,6 @@ export class BloomFilter {
127127
}
128128

129129
private insert(value: string): void {
130-
if (value === '') {
131-
throw new Error('Cannot insert empty string to a bloom filter.');
132-
}
133-
134130
if (this.bitCount === 0) {
135131
return;
136132
}

packages/firestore/src/remote/watch_change.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ export class WatchChangeAggregator {
431431
}
432432
}
433433

434-
/** Returns wheather a bloom filter removed the deleted documents successfully. */
434+
/** Returns whether a bloom filter removed the deleted documents successfully. */
435435
private applyBloomFilter(
436436
existenceFilter: ExistenceFilter,
437437
targetId: number,
@@ -481,7 +481,7 @@ export class WatchChangeAggregator {
481481
targetId
482482
);
483483

484-
return currentCount - removedDocumentCount === expectedCount;
484+
return expectedCount === currentCount - removedDocumentCount;
485485
}
486486

487487
private isValidBase64String(value: string): boolean {

packages/firestore/test/unit/remote/bloom_filter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('BloomFilter', () => {
9090
expect(bloomFilter.mightContain('abc')).to.be.false;
9191
});
9292

93-
it('mightContain on empty string might return false positive result ', () => {
93+
it('mightContain on empty string might return false positive result', () => {
9494
const bloomFilter1 = new BloomFilter(new Uint8Array([1]), 1, 1);
9595
const bloomFilter2 = new BloomFilter(new Uint8Array([255]), 0, 16);
9696
expect(bloomFilter1.mightContain('')).to.be.false;

packages/firestore/test/unit/specs/existence_filter_spec.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ describeSpec('Existence Filters:', [], () => {
274274
// BloomFilter identify docB is deleted, skip full query and put docB
275275
// into limbo directly.
276276
.expectEvents(query1, { fromCache: true })
277-
.expectLimboDocs(docB.key) // docB is now in limbo.
277+
.expectLimboDocs(docB.key) // DocB is now in limbo.
278278
.ackLimbo(2000, deletedDoc('collection/b', 2000))
279-
.expectLimboDocs() // docB is no longer in limbo
279+
.expectLimboDocs() // DocB is no longer in limbo.
280280
.expectEvents(query1, {
281281
removed: [docB]
282282
})
@@ -312,7 +312,7 @@ describeSpec('Existence Filters:', [], () => {
312312
.expectActiveTargets({ query: query1, resumeToken: '' })
313313
.watchRemoves(query1) // Acks removal of query.
314314
.watchAcksFull(query1, 2000, docA)
315-
.expectLimboDocs(docB.key, docC.key) // docB, docC are now in limbo.
315+
.expectLimboDocs(docB.key, docC.key) // DocB, docC are now in limbo.
316316
.ackLimbo(2001, deletedDoc('collection/b', 2001))
317317
.expectEvents(query1, {
318318
removed: [docB],
@@ -349,16 +349,16 @@ describeSpec('Existence Filters:', [], () => {
349349
// DocB is deleted in the next sync.
350350
.watchFilters([query1], [docA.key], bloomFilterProto)
351351
.watchSnapshots(2000)
352-
// BloomFilter identify docB is deleted, skip full query and put docB
353-
// into limbo directly.
352+
// BloomFilter identifies docB is deleted, skip full query and put
353+
// docB into limbo directly.
354354
.expectEvents(query1, { fromCache: true })
355-
.expectLimboDocs(docB.key) // docB is now in limbo.
355+
.expectLimboDocs(docB.key) // DocB is now in limbo.
356356
);
357357
}
358358
);
359359

360360
specTest(
361-
'Bloom filter will fill in default value 0 for padding and hashCount',
361+
'Bloom filter fills in default values for undefined padding and hashCount',
362362
[],
363363
() => {
364364
const query1 = query('collection');
@@ -458,7 +458,7 @@ describeSpec('Existence Filters:', [], () => {
458458
);
459459
});
460460

461-
specTest('Same docs can have different bloom filters', [], () => {
461+
specTest('Same documents can have different bloom filters', [], () => {
462462
const query1 = query('collection', filter('v', '<=', 2));
463463
const query2 = query('collection', filter('v', '>=', 2));
464464

@@ -493,18 +493,18 @@ describeSpec('Existence Filters:', [], () => {
493493
.watchSnapshots(2000)
494494
// BloomFilter identify docA is deleted, skip full query.
495495
.expectEvents(query1, { fromCache: true })
496-
.expectLimboDocs(docA.key) // docA is now in limbo.
496+
.expectLimboDocs(docA.key) // DocA is now in limbo.
497497

498498
// DocC is deleted in the next sync for query2.
499499
.watchFilters([query2], [docB.key], bloomFilterProto2)
500500
.watchSnapshots(3000)
501501
// BloomFilter identify docC is deleted, skip full query.
502502
.expectEvents(query2, { fromCache: true })
503-
.expectLimboDocs(docA.key, docC.key) // docC is now in limbo.
503+
.expectLimboDocs(docA.key, docC.key) // DocC is now in limbo.
504504
);
505505
});
506506

507-
specTest('Bloom filter handled at global snapshot', [], () => {
507+
specTest('Bloom filter is handled at global snapshot', [], () => {
508508
const query1 = query('collection');
509509
const docA = doc('collection/a', 1000, { v: 1 });
510510
const docB = doc('collection/b', 2000, { v: 2 });
@@ -529,7 +529,7 @@ describeSpec('Existence Filters:', [], () => {
529529
.watchSends({ affects: [query1] }, docC)
530530
.watchSnapshots(2000)
531531
.expectEvents(query1, { added: [docC], fromCache: true })
532-
// re-run of the query1 is skipped, docB is in limbo.
532+
// Re-run of the query1 is skipped, docB is in limbo.
533533
.expectLimboDocs(docB.key)
534534
);
535535
});
@@ -551,12 +551,12 @@ describeSpec('Existence Filters:', [], () => {
551551
.watchFilters([query1], [docA.key], bloomFilterProto)
552552
.watchSnapshots(2000)
553553
.expectEvents(query1, { fromCache: true })
554-
.expectLimboDocs(docB.key) // docB is now in limbo.
554+
.expectLimboDocs(docB.key) // DocB is now in limbo.
555555
.watchRemoves(
556556
newQueryForPath(docB.key.path),
557557
new RpcError(Code.PERMISSION_DENIED, 'no')
558558
)
559-
.expectLimboDocs() // docB is no longer in limbo.
559+
.expectLimboDocs() // DocB is no longer in limbo.
560560
.expectEvents(query1, {
561561
removed: [docB]
562562
});

0 commit comments

Comments
 (0)