Skip to content
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

Port IndexValueWriter #5826

Merged
merged 2 commits into from Dec 23, 2021
Merged

Port IndexValueWriter #5826

merged 2 commits into from Dec 23, 2021

Conversation

@changeset-bot
Copy link

@changeset-bot changeset-bot bot commented Dec 20, 2021

⚠️ No Changeset found

Latest commit: a56a8aa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

@google-oss-bot google-oss-bot commented Dec 20, 2021

Binary Size Report

Affected SDKs

  • @firebase/firestore

    Type Base (9295bb0) Head (c47c9c9) Diff
    browser 227 kB 227 kB +36 B (+0.0%)
    esm5 284 kB 284 kB +36 B (+0.0%)
    main 426 kB 426 kB +55 B (+0.0%)
    module 227 kB 227 kB +36 B (+0.0%)
    react-native 228 kB 228 kB +36 B (+0.0%)
  • @firebase/firestore-lite

    Type Base (9295bb0) Head (c47c9c9) Diff
    browser 72.4 kB 72.5 kB +36 B (+0.0%)
    esm5 85.7 kB 85.7 kB +36 B (+0.0%)
    main 125 kB 125 kB +55 B (+0.0%)
    module 72.4 kB 72.5 kB +36 B (+0.0%)
    react-native 72.6 kB 72.7 kB +36 B (+0.0%)
  • bundle

    Click to show 12 binary size changes.
    Type Base (9295bb0) Head (c47c9c9) Diff
    firestore (Persistence) 229 kB 229 kB +36 B (+0.0%)
    firestore (Query Cursors) 189 kB 189 kB +36 B (+0.0%)
    firestore (Query) 190 kB 190 kB +36 B (+0.0%)
    firestore (Read data once) 178 kB 178 kB +36 B (+0.0%)
    firestore (Realtime updates) 180 kB 180 kB +36 B (+0.0%)
    firestore (Transaction) 163 kB 163 kB +36 B (+0.0%)
    firestore (Write data) 162 kB 162 kB +36 B (+0.0%)
    firestore-lite (Query Cursors) 56.3 kB 56.3 kB +18 B (+0.0%)
    firestore-lite (Query) 59.4 kB 59.4 kB +36 B (+0.1%)
    firestore-lite (Read data once) 43.9 kB 43.9 kB +18 B (+0.0%)
    firestore-lite (Transaction) 61.2 kB 61.2 kB +18 B (+0.0%)
    firestore-lite (Write data) 46.8 kB 46.8 kB +18 B (+0.0%)
  • firebase

    Type Base (9295bb0) Head (c47c9c9) Diff
    firebase-compat.js 753 kB 753 kB +36 B (+0.0%)
    firebase-firestore-compat.js 280 kB 280 kB +36 B (+0.0%)
    firebase-firestore-lite.js 245 kB 245 kB +131 B (+0.1%)
    firebase-firestore.js 766 kB 766 kB +55 B (+0.0%)

Test Logs

@google-oss-bot
Copy link
Contributor

@google-oss-bot google-oss-bot commented Dec 20, 2021

Size Analysis Report

Affected Products

  • @firebase/firestore

    • Transaction

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      41.5 kB
      41.5 kB
      +18 B (+0.0%)
      size-with-ext-deps
      88.9 kB
      89.0 kB
      +18 B (+0.0%)
    • WriteBatch

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      38.3 kB
      38.3 kB
      +18 B (+0.0%)
      size-with-ext-deps
      85.7 kB
      85.8 kB
      +18 B (+0.0%)
    • addDoc

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      105 kB
      105 kB
      +36 B (+0.0%)
      size-with-ext-deps
      154 kB
      154 kB
      +36 B (+0.0%)
    • deleteDoc

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      96.4 kB
      96.5 kB
      +36 B (+0.0%)
      size-with-ext-deps
      145 kB
      145 kB
      +36 B (+0.0%)
    • disableNetwork

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      85.1 kB
      85.1 kB
      +36 B (+0.0%)
      size-with-ext-deps
      134 kB
      134 kB
      +36 B (+0.0%)
    • enableIndexedDbPersistence

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      141 kB
      141 kB
      +36 B (+0.0%)
      size-with-ext-deps
      190 kB
      190 kB
      +36 B (+0.0%)
    • enableMultiTabIndexedDbPersistence

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      173 kB
      173 kB
      +36 B (+0.0%)
      size-with-ext-deps
      222 kB
      222 kB
      +36 B (+0.0%)
    • enableNetwork

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      85.1 kB
      85.1 kB
      +36 B (+0.0%)
      size-with-ext-deps
      134 kB
      134 kB
      +36 B (+0.0%)
    • executeWrite

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      95.6 kB
      95.6 kB
      +36 B (+0.0%)
      size-with-ext-deps
      144 kB
      144 kB
      +36 B (+0.0%)
    • getDoc

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      121 kB
      121 kB
      +36 B (+0.0%)
      size-with-ext-deps
      170 kB
      170 kB
      +36 B (+0.0%)
    • getDocFromCache

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      78.3 kB
      78.3 kB
      +36 B (+0.0%)
      size-with-ext-deps
      126 kB
      126 kB
      +36 B (+0.0%)
    • getDocFromServer

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      121 kB
      121 kB
      +36 B (+0.0%)
      size-with-ext-deps
      170 kB
      170 kB
      +36 B (+0.0%)
    • getDocs

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      123 kB
      123 kB
      +36 B (+0.0%)
      size-with-ext-deps
      171 kB
      171 kB
      +36 B (+0.0%)
    • getDocsFromCache

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      85.5 kB
      85.5 kB
      +36 B (+0.0%)
      size-with-ext-deps
      133 kB
      133 kB
      +36 B (+0.0%)
    • getDocsFromServer

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      123 kB
      123 kB
      +36 B (+0.0%)
      size-with-ext-deps
      171 kB
      171 kB
      +36 B (+0.0%)
    • loadBundle

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      93.9 kB
      94.0 kB
      +36 B (+0.0%)
      size-with-ext-deps
      142 kB
      143 kB
      +36 B (+0.0%)
    • namedQuery

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      71.7 kB
      71.8 kB
      +36 B (+0.1%)
      size-with-ext-deps
      119 kB
      119 kB
      +36 B (+0.0%)
    • onSnapshot

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      123 kB
      123 kB
      +36 B (+0.0%)
      size-with-ext-deps
      172 kB
      172 kB
      +36 B (+0.0%)
    • onSnapshotsInSync

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      113 kB
      113 kB
      +36 B (+0.0%)
      size-with-ext-deps
      162 kB
      162 kB
      +36 B (+0.0%)
    • queryEqual

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      25.2 kB
      25.2 kB
      +18 B (+0.1%)
      size-with-ext-deps
      72.5 kB
      72.6 kB
      +18 B (+0.0%)
    • runTransaction

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      106 kB
      106 kB
      +36 B (+0.0%)
      size-with-ext-deps
      155 kB
      155 kB
      +36 B (+0.0%)
    • setDoc

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      105 kB
      105 kB
      +36 B (+0.0%)
      size-with-ext-deps
      153 kB
      153 kB
      +36 B (+0.0%)
    • snapshotEqual

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      31.7 kB
      31.8 kB
      +18 B (+0.1%)
      size-with-ext-deps
      79.1 kB
      79.1 kB
      +18 B (+0.0%)
    • updateDoc

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      105 kB
      105 kB
      +36 B (+0.0%)
      size-with-ext-deps
      154 kB
      154 kB
      +36 B (+0.0%)
    • waitForPendingWrites

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      85.5 kB
      85.5 kB
      +36 B (+0.0%)
      size-with-ext-deps
      134 kB
      134 kB
      +36 B (+0.0%)
    • where

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      39.8 kB
      39.8 kB
      +36 B (+0.1%)
      size-with-ext-deps
      87.2 kB
      87.3 kB
      +36 B (+0.0%)
    • writeBatch

      Size Table

      TypeBase (9295bb0)Head (c47c9c9)Diff
      size
      107 kB
      107 kB
      +36 B (+0.0%)
      size-with-ext-deps
      156 kB
      156 kB
      +36 B (+0.0%)

Copy link

@thebrianchen thebrianchen left a comment

lgtm with some questions and optional suggestions

indexValue: Value,
encoder: DirectionalIndexByteEncoder
): void {
if ('nullValue' in indexValue) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: use switch here, since every if-condition is a single statement.

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, switch does not work here since we are not doing an equals comparison on a value.

): void {
this.writeValueTypeLabel(encoder, INDEX_TYPE_REFERENCE);
const path = DocumentKey.fromName(referenceValue).path;
for (let i = 0; i < path.length; ++i) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional:

DocumentKey.fromName(referenceValue).path.forEach(segment => {
      this.writeValueTypeLabel(encoder, INDEX_TYPE_REFERENCE_SEGMENT);
      this.writeUnlabeledIndexString(segment, encoder); 
    });

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept "path" but used forEach.

import { fail } from '../util/assert';
import { ByteString } from '../util/byte_string';

export class OrderedCodeWriter {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: copy comment over and add a TODO that this section will be implemented in the future, rather than intentionally not implemented.

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is already in review: #5821

@@ -73,6 +81,10 @@ export function typeOrder(value: Value): TypeOrder {

/** Tests `left` and `right` for equality based on the backend semantics. */
export function valueEquals(left: Value, right: Value): boolean {
if (left === right) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully follow here, were we always able to do this direct comparison, or does this PR now allow us to do this direct comparison?

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were always able to do this. I added this now to make it more performant to do an equals check on MAX_VALUE.

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian left a comment

Thanks!

indexValue: Value,
encoder: DirectionalIndexByteEncoder
): void {
if ('nullValue' in indexValue) {
Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, switch does not work here since we are not doing an equals comparison on a value.

): void {
this.writeValueTypeLabel(encoder, INDEX_TYPE_REFERENCE);
const path = DocumentKey.fromName(referenceValue).path;
for (let i = 0; i < path.length; ++i) {
Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept "path" but used forEach.

import { fail } from '../util/assert';
import { ByteString } from '../util/byte_string';

export class OrderedCodeWriter {
Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is already in review: #5821

@@ -73,6 +81,10 @@ export function typeOrder(value: Value): TypeOrder {

/** Tests `left` and `right` for equality based on the backend semantics. */
export function valueEquals(left: Value, right: Value): boolean {
if (left === right) {
Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were always able to do this. I added this now to make it more performant to do an equals check on MAX_VALUE.

@schmidt-sebastian schmidt-sebastian merged commit 3d8109c into master Dec 23, 2021
18 checks passed
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/indexwriter branch Dec 23, 2021
@firebase firebase locked and limited conversation to collaborators Jan 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants