Skip to content

apply bloomFilter while handling existence filter mismatch #6897

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
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/firestore/src/core/firestore_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import { Document } from '../model/document';
import { DocumentKey } from '../model/document_key';
import { Mutation } from '../model/mutation';
import { toByteStreamReader } from '../platform/byte_stream_reader';
import { newSerializer, newTextEncoder } from '../platform/serializer';
import { newSerializer } from '../platform/serializer';
import { newTextEncoder } from '../platform/text_reader';
import { Datastore } from '../remote/datastore';
import {
canUseNetwork,
Expand Down
4 changes: 4 additions & 0 deletions packages/firestore/src/model/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ abstract class BasePath<B extends BasePath<B>> {
return this.segments.slice(this.offset, this.limit());
}

toFullPath(): string {
return this.segments.join('/');
}

static comparator<T extends BasePath<T>>(
p1: BasePath<T>,
p2: BasePath<T>
Expand Down
14 changes: 0 additions & 14 deletions packages/firestore/src/platform/browser/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,3 @@ import { JsonProtoSerializer } from '../../remote/serializer';
export function newSerializer(databaseId: DatabaseId): JsonProtoSerializer {
return new JsonProtoSerializer(databaseId, /* useProto3Json= */ true);
}

/**
* An instance of the Platform's 'TextEncoder' implementation.
*/
export function newTextEncoder(): TextEncoder {
return new TextEncoder();
}

/**
* An instance of the Platform's 'TextDecoder' implementation.
*/
export function newTextDecoder(): TextDecoder {
return new TextDecoder('utf-8');
}
30 changes: 30 additions & 0 deletions packages/firestore/src/platform/browser/text_reader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @license
* Copyright 2022 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.
*/

/**
* An instance of the Platform's 'TextEncoder' implementation.
*/
export function newTextEncoder(): TextEncoder {
return new TextEncoder();
}

/**
* An instance of the Platform's 'TextDecoder' implementation.
*/
export function newTextDecoder(): TextDecoder {
return new TextDecoder('utf-8');
}
18 changes: 18 additions & 0 deletions packages/firestore/src/platform/browser_lite/text_reader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2022 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.
*/

export * from '../browser/text_reader';
16 changes: 0 additions & 16 deletions packages/firestore/src/platform/node/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,9 @@
*/

/** Return the Platform-specific serializer monitor. */
import { TextDecoder, TextEncoder } from 'util';

import { DatabaseId } from '../../core/database_info';
import { JsonProtoSerializer } from '../../remote/serializer';

export function newSerializer(databaseId: DatabaseId): JsonProtoSerializer {
return new JsonProtoSerializer(databaseId, /* useProto3Json= */ false);
}

/**
* An instance of the Platform's 'TextEncoder' implementation.
*/
export function newTextEncoder(): TextEncoder {
return new TextEncoder();
}

/**
* An instance of the Platform's 'TextDecoder' implementation.
*/
export function newTextDecoder(): TextDecoder {
return new TextDecoder('utf-8');
}
32 changes: 32 additions & 0 deletions packages/firestore/src/platform/node/text_reader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2022 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.
*/

import { TextDecoder, TextEncoder } from 'util';

/**
* An instance of the Platform's 'TextEncoder' implementation.
*/
export function newTextEncoder(): TextEncoder {
return new TextEncoder();
}

/**
* An instance of the Platform's 'TextDecoder' implementation.
*/
export function newTextDecoder(): TextDecoder {
return new TextDecoder('utf-8');
}
18 changes: 18 additions & 0 deletions packages/firestore/src/platform/node_lite/text_reader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2022 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.
*/

export * from '../browser_lite/text_reader';
6 changes: 1 addition & 5 deletions packages/firestore/src/platform/rn/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@
* limitations under the License.
*/

export {
newSerializer,
newTextEncoder,
newTextDecoder
} from '../browser/serializer';
export { newSerializer } from '../browser/serializer';
18 changes: 18 additions & 0 deletions packages/firestore/src/platform/rn/text_reader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2022 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.
*/

export { newTextEncoder, newTextDecoder } from '../browser/text_reader';
18 changes: 18 additions & 0 deletions packages/firestore/src/platform/rn_lite/text_reader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2022 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.
*/

export * from '../browser_lite/text_reader';
32 changes: 0 additions & 32 deletions packages/firestore/src/platform/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,13 @@
* limitations under the License.
*/

import { isNode, isReactNative } from '@firebase/util';

import { DatabaseId } from '../core/database_info';
import { JsonProtoSerializer } from '../remote/serializer';

import * as browser from './browser/serializer';
import * as node from './node/serializer';
import * as rn from './rn/serializer';

// This file is only used under ts-node.
// eslint-disable-next-line @typescript-eslint/no-require-imports
const platform = require(`./${process.env.TEST_PLATFORM ?? 'node'}/serializer`);

export function newSerializer(databaseId: DatabaseId): JsonProtoSerializer {
return platform.newSerializer(databaseId);
}

/**
* An instance of the Platform's 'TextEncoder' implementation.
*/
export function newTextEncoder(): TextEncoder {
if (isNode()) {
return node.newTextEncoder();
} else if (isReactNative()) {
return rn.newTextEncoder();
} else {
return browser.newTextEncoder();
}
}

/**
* An instance of the Platform's 'TextDecoder' implementation.
*/
export function newTextDecoder(): TextDecoder {
if (isNode()) {
return node.newTextDecoder() as TextDecoder;
} else if (isReactNative()) {
return rn.newTextDecoder();
} else {
return browser.newTextDecoder();
}
}
48 changes: 48 additions & 0 deletions packages/firestore/src/platform/text_reader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* @license
* Copyright 2022 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.
*/

import { isNode, isReactNative } from '@firebase/util';

import * as browser from './browser/text_reader';
import * as node from './node/text_reader';
import * as rn from './rn/text_reader';

/**
* An instance of the Platform's 'TextEncoder' implementation.
*/
export function newTextEncoder(): TextEncoder {
if (isNode()) {
return node.newTextEncoder();
} else if (isReactNative()) {
return rn.newTextEncoder();
} else {
return browser.newTextEncoder();
}
}

/**
* An instance of the Platform's 'TextDecoder' implementation.
*/
export function newTextDecoder(): TextDecoder {
if (isNode()) {
return node.newTextDecoder() as TextDecoder;
} else if (isReactNative()) {
return rn.newTextDecoder();
} else {
return browser.newTextDecoder();
}
}
2 changes: 1 addition & 1 deletion packages/firestore/src/remote/bloom_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import { Md5, Integer } from '@firebase/webchannel-wrapper';

import { newTextEncoder } from '../platform/serializer';
import { newTextEncoder } from '../platform/text_reader';
import { debugAssert } from '../util/assert';

const MAX_64_BIT_UNSIGNED_INTEGER = new Integer([0xffffffff, 0xffffffff], 0);
Expand Down
Loading