-
Notifications
You must be signed in to change notification settings - Fork 985
Update the integration test to verify that bloom filter averted full requery #7095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dconeybe
merged 32 commits into
mila/BloomFilter
from
dconeybe/BloomFilterComplexIntegrationTest
Mar 10, 2023
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
86870f9
update the test case to verify that the existence filter contains a b…
dconeybe f75534f
add retry
dconeybe dc42228
fix lint errors
dconeybe c1bff43
Update API reports
dconeybe 1753549
testing_hooks.ts: add @internal tag to TestingHooks class so it doesn…
dconeybe 50418ef
Add docs
dconeybe 01b3bf0
fix lint errors
dconeybe 384608c
cleanup
dconeybe 67305ea
add a reference to b/271949433 in a comment
dconeybe f9e0707
get rid of unnecssary 'type IterationResult' declaration
dconeybe 9bfdcc2
integration/firestore/gulpfile.js: add testing_hooks_util.ts to the l…
dconeybe 15d47bc
testing_hooks_util.ts: REVERT ME: add _logWarn() to existenceFilterMi…
dconeybe 739f13d
fix mangling of the property names of the argument to 'onExistenceFil…
dconeybe af53f1a
testing_hooks.ts: add @internal tag to ExistenceFilterMismatchInfo
dconeybe 85ed7ab
avoid using objects for parameters since their names can get mangled …
dconeybe 0b9aaf1
try hand-creating the ExistenceFilterMismatchInfo to see if it surviv…
dconeybe 266a722
testing_hooks_util.ts: fix lint error
dconeybe c1437bc
firestore-compat: fix typing error in fields.test.ts: TS2339: Propert…
dconeybe 24fbb79
Revert "firestore-compat: fix typing error in fields.test.ts: TS2339:…
dconeybe f9adb54
firestore-compat: *really* fix typing error in fields.test.ts: TS2339…
dconeybe def79d1
minor cleanups from self code review
dconeybe 6d4e3dd
Merge remote-tracking branch 'origin/mila/BloomFilter' into BloomFilt…
dconeybe f5415f5
yarn prettier
dconeybe 6bc7b3b
watch_change.ts minor cleanup
dconeybe bad0ca9
query.test.ts: remove it.only()
dconeybe 9871614
refactor the test a bit
dconeybe 61a9cd7
query.test.ts: it.only -> it (oops)
dconeybe 2acf945
rename actualCount/expectedCount to localCacheCount/existenceFilterCo…
dconeybe daf049c
disable the annoying 'check changeset' check, which is broken when ta…
dconeybe 74607ac
Merge remote-tracking branch 'origin/mila/BloomFilter' into BloomFilt…
dconeybe 677b9e7
address review feedback
dconeybe acff0f4
yarn prettier
dconeybe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2023 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| /** | ||
| * Manages "testing hooks", hooks into the internals of the SDK to verify | ||
| * internal state and events during integration tests. Do not use this class | ||
| * except for testing purposes. | ||
| * | ||
| * There are two ways to retrieve the global singleton instance of this class: | ||
| * 1. The `instance` property, which returns null if the global singleton | ||
| * instance has not been created. Use this property if the caller should | ||
| * "do nothing" if there are no testing hooks registered, such as when | ||
| * delivering an event to notify registered callbacks. | ||
| * 2. The `getOrCreateInstance()` method, which creates the global singleton | ||
| * instance if it has not been created. Use this method if the instance is | ||
| * needed to, for example, register a callback. | ||
| * | ||
| * @internal | ||
| */ | ||
| export class TestingHooks { | ||
| private readonly onExistenceFilterMismatchCallbacks = new Map< | ||
| Symbol, | ||
| ExistenceFilterMismatchCallback | ||
| >(); | ||
|
|
||
| private constructor() {} | ||
|
|
||
| /** | ||
| * Returns the singleton instance of this class, or null if it has not been | ||
| * initialized. | ||
| */ | ||
| static get instance(): TestingHooks | null { | ||
| return gTestingHooksSingletonInstance; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the singleton instance of this class, creating it if is has never | ||
| * been created before. | ||
| */ | ||
| static getOrCreateInstance(): TestingHooks { | ||
| if (gTestingHooksSingletonInstance === null) { | ||
| gTestingHooksSingletonInstance = new TestingHooks(); | ||
| } | ||
| return gTestingHooksSingletonInstance; | ||
| } | ||
|
|
||
| /** | ||
| * Registers a callback to be notified when an existence filter mismatch | ||
| * occurs in the Watch listen stream. | ||
| * | ||
| * The relative order in which callbacks are notified is unspecified; do not | ||
| * rely on any particular ordering. If a given callback is registered multiple | ||
| * times then it will be notified multiple times, once per registration. | ||
| * | ||
| * @param callback the callback to invoke upon existence filter mismatch. | ||
| * | ||
| * @return a function that, when called, unregisters the given callback; only | ||
| * the first invocation of the returned function does anything; all subsequent | ||
| * invocations do nothing. | ||
| */ | ||
| onExistenceFilterMismatch( | ||
| callback: ExistenceFilterMismatchCallback | ||
| ): () => void { | ||
| const key = Symbol(); | ||
| this.onExistenceFilterMismatchCallbacks.set(key, callback); | ||
| return () => this.onExistenceFilterMismatchCallbacks.delete(key); | ||
| } | ||
|
|
||
| /** | ||
| * Invokes all currently-registered `onExistenceFilterMismatch` callbacks. | ||
| * @param info Information about the existence filter mismatch. | ||
| */ | ||
| notifyOnExistenceFilterMismatch(info: ExistenceFilterMismatchInfo): void { | ||
| this.onExistenceFilterMismatchCallbacks.forEach(callback => callback(info)); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Information about an existence filter mismatch, as specified to callbacks | ||
| * registered with `TestingUtils.onExistenceFilterMismatch()`. | ||
| */ | ||
| export interface ExistenceFilterMismatchInfo { | ||
| /** The number of documents that matched the query in the local cache. */ | ||
| localCacheCount: number; | ||
|
|
||
| /** | ||
| * The number of documents that matched the query on the server, as specified | ||
| * in the ExistenceFilter message's `count` field. | ||
| */ | ||
| existenceFilterCount: number; | ||
|
|
||
| /** | ||
| * Information about the bloom filter provided by Watch in the ExistenceFilter | ||
| * message's `unchangedNames` field. If this property is omitted or undefined | ||
| * then that means that Watch did _not_ provide a bloom filter. | ||
| */ | ||
| bloomFilter?: { | ||
| /** | ||
| * Whether a full requery was averted by using the bloom filter. If false, | ||
| * then something happened, such as a false positive, to prevent using the | ||
| * bloom filter to avoid a full requery. | ||
| */ | ||
| applied: boolean; | ||
|
|
||
| /** The number of hash functions used in the bloom filter. */ | ||
| hashCount: number; | ||
|
|
||
| /** The number of bytes in the bloom filter's bitmask. */ | ||
| bitmapLength: number; | ||
|
|
||
| /** The number of bits of padding in the last byte of the bloom filter. */ | ||
| padding: number; | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * The signature of callbacks registered with | ||
| * `TestingUtils.onExistenceFilterMismatch()`. | ||
| */ | ||
| export type ExistenceFilterMismatchCallback = ( | ||
| info: ExistenceFilterMismatchInfo | ||
| ) => void; | ||
|
|
||
| /** The global singleton instance of `TestingHooks`. */ | ||
| let gTestingHooksSingletonInstance: TestingHooks | null = null; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.