Skip to content

Commit d0fd838

Browse files
committed
resolve comments
1 parent 318787c commit d0fd838

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

packages/firestore/test/integration/api/query.test.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,18 @@ apiDescribe('Queries', persistence => {
22852285
addedDocumentIds.push(documentToAdd.id);
22862286
}
22872287

2288+
// Ensure the sets above are disjoint.
2289+
const mergedSet = new Set<string>();
2290+
[
2291+
deletedDocumentIds,
2292+
removedDocumentIds,
2293+
updatedDocumentIds,
2294+
addedDocumentIds
2295+
].forEach(set => {
2296+
set.forEach(documentId => mergedSet.add(documentId));
2297+
});
2298+
expect(mergedSet.size).to.equal(30);
2299+
22882300
await batch.commit();
22892301
});
22902302

@@ -2308,17 +2320,17 @@ apiDescribe('Queries', persistence => {
23082320
const actualDocumentIds = snapshot2.docs
23092321
.map(documentSnapshot => documentSnapshot.ref.id)
23102322
.sort();
2311-
expect(actualDocumentIds.length).to.equal(25);
2312-
23132323
const expectedDocumentIds = createdDocuments
23142324
.map(documentRef => documentRef.id)
23152325
.filter(documentId => !deletedDocumentIds.has(documentId))
23162326
.filter(documentId => !removedDocumentIds.has(documentId))
23172327
.concat(addedDocumentIds)
23182328
.sort();
2329+
23192330
expect(actualDocumentIds, 'snapshot2.docs').to.deep.equal(
23202331
expectedDocumentIds
23212332
);
2333+
expect(actualDocumentIds.length).to.equal(25);
23222334

23232335
// Verify that Watch sent an existence filter with the correct
23242336
// counts when the query was resumed.
@@ -2340,14 +2352,6 @@ apiDescribe('Queries', persistence => {
23402352
throw new Error('should never get here');
23412353
}
23422354

2343-
expect(bloomFilter.hashCount, 'bloomFilter.hashCount').to.be.above(0);
2344-
expect(
2345-
bloomFilter.bitmapLength,
2346-
'bloomFilter.bitmapLength'
2347-
).to.be.above(0);
2348-
expect(bloomFilter.padding, 'bloomFilterPadding').to.be.above(0);
2349-
expect(bloomFilter.padding, 'bloomFilterPadding').to.be.below(8);
2350-
23512355
// Verify that the bloom filter was successfully used to avert a
23522356
// full requery. If a false positive occurred then retry the entire
23532357
// test. Although statistically rare, false positives are expected

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ describeSpec('Existence Filters:', [], () => {
654654
.restoreListen(query1, 'resume-token-1000')
655655
.watchAcks(query1)
656656
// Nothing happened while this client was disconnected.
657-
// Bloom Filter includes the documents that match the query since the resume token.
657+
// Bloom Filter includes docA as there are no changes since the resume token.
658658
.watchFilters([query1], [docA.key], bloomFilterProto)
659659
// Expected count equals to documents in cache. Existence Filter matches.
660660
.watchCurrents(query1, 'resume-token-2000')
@@ -687,7 +687,8 @@ describeSpec('Existence Filters:', [], () => {
687687
.watchAcks(query1)
688688
// While this client was disconnected, another client added docB.
689689
.watchSends({ affects: [query1] }, docB)
690-
// Bloom Filter includes the documents that match the query since the resume token.
690+
// Bloom Filter includes all the documents that match the query, both
691+
// those that haven't changed since the resume token and those newly added.
691692
.watchFilters([query1], [docA.key, docB.key], bloomFilterProto)
692693
// Expected count equals to documents in cache. Existence Filter matches.
693694
.watchCurrents(query1, 'resume-token-2000')
@@ -701,7 +702,7 @@ describeSpec('Existence Filters:', [], () => {
701702
'Resume a query with bloom filter when existing docs are updated',
702703
[],
703704
() => {
704-
const query1 = query('collection');
705+
const query1 = query('collection', filter('v', '>=', 1));
705706
const docA = doc('collection/a', 1000, { v: 1 });
706707
const docB = doc('collection/b', 1000, { v: 1 });
707708
const updatedDocB = doc('collection/b', 1000, { v: 2 });
@@ -722,7 +723,8 @@ describeSpec('Existence Filters:', [], () => {
722723
.watchAcks(query1)
723724
// While this client was disconnected, another client updated fields in docB.
724725
.watchSends({ affects: [query1] }, updatedDocB)
725-
// Bloom Filter includes the documents that match the query since the resume token.
726+
// Bloom Filter includes all the documents that match the query, both
727+
// those that have changed since the resume token and those that have not.
726728
.watchFilters([query1], [docA.key, updatedDocB.key], bloomFilterProto)
727729
// Expected count equals to documents in cache. Existence Filter matches.
728730
.watchCurrents(query1, 'resume-token-2000')
@@ -743,7 +745,7 @@ describeSpec('Existence Filters:', [], () => {
743745

744746
const bloomFilterProto = generateBloomFilterProto({
745747
contains: [docA],
746-
notContains: []
748+
notContains: [docB]
747749
});
748750
return (
749751
spec()
@@ -795,7 +797,7 @@ describeSpec('Existence Filters:', [], () => {
795797
// While this client was disconnected, another client modified docB to no longer match the
796798
// query, deleted docC and added docD.
797799
.watchSends({ affects: [query1] }, docD)
798-
// Bloom Filter includes all documents that match the query since the resume token.
800+
// Bloom Filter includes all the documents that match the query.
799801
.watchFilters([query1], [docA.key, docD.key], bloomFilterProto)
800802
.watchCurrents(query1, 'resume-token-2000')
801803
.watchSnapshots(2000)

0 commit comments

Comments
 (0)