Skip to content

Port TargetIndexMatcher #5975

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
merged 6 commits into from
Feb 10, 2022
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

This is a straightforward port from Android.

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2022

⚠️ No Changeset found

Latest commit: dd8ac83

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 commented Feb 4, 2022

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (0482aa5)Merge (a031e10)Diff
    browser231 kB233 kB+2.16 kB (+0.9%)
    esm5288 kB291 kB+2.53 kB (+0.9%)
    main460 kB463 kB+3.65 kB (+0.8%)
    module231 kB233 kB+2.16 kB (+0.9%)
    react-native231 kB233 kB+2.16 kB (+0.9%)
  • bundle

    TypeBase (0482aa5)Merge (a031e10)Diff
    firestore (Persistence)232 kB234 kB+2.58 kB (+1.1%)
    firestore (Query Cursors)190 kB190 kB+91 B (+0.0%)
    firestore (Query)191 kB191 kB+91 B (+0.0%)
    firestore (Read data once)180 kB180 kB+91 B (+0.1%)
    firestore (Realtime updates)182 kB182 kB+91 B (+0.1%)
    firestore (Transaction)164 kB164 kB+85 B (+0.1%)
    firestore (Write data)163 kB163 kB+85 B (+0.1%)
  • firebase

    TypeBase (0482aa5)Merge (a031e10)Diff
    firebase-compat.js755 kB758 kB+2.52 kB (+0.3%)
    firebase-firestore-compat.js283 kB285 kB+2.52 kB (+0.9%)
    firebase-firestore.js780 kB784 kB+4.06 kB (+0.5%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/B7SOs4jE2U.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Feb 4, 2022

Size Analysis Report 1

This report is too large (445,136 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/SOSOOyq8ut.html

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2022

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

Copy link
Contributor

@ehsannas ehsannas left a comment

Choose a reason for hiding this comment

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

Looks good. Just a few nits

/**
* A light query planner for Firestore.
*
* This class matches a `FieldIndex`z against a Firestore Query `Target`. It
Copy link
Contributor

Choose a reason for hiding this comment

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

remove typo (z)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private readonly collectionId: string;
// The single inequality filter of the target (if it exists).
private readonly inequalityFilter?: FieldFilter;
// The list of equality filter of the target.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/filter/filters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


// Process all equalities first. Equalities can appear out of order.
for (; segmentIndex < segments.length; ++segmentIndex) {
// We attempt to greedily match all segments to equality filters. If a a
Copy link
Contributor

Choose a reason for hiding this comment

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

s/If a a/If a

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fun :)

// Process all equalities first. Equalities can appear out of order.
for (; segmentIndex < segments.length; ++segmentIndex) {
// We attempt to greedily match all segments to equality filters. If a a
// filter matches an index segments, we can mark the segment as used.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/an index segments/an index segment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...

for (; segmentIndex < segments.length; ++segmentIndex) {
// We attempt to greedily match all segments to equality filters. If a a
// filter matches an index segments, we can mark the segment as used.
// Since it is not possible to use the same filed path in both an equality
Copy link
Contributor

Choose a reason for hiding this comment

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

s/filed/field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...

++segmentIndex;
}

// All remaining segment need to represent the prefix of the target's
Copy link
Contributor

Choose a reason for hiding this comment

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

s/segment/segments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
});

it('inequalitiesWithDefaultOrder', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

inequalities with default order ?

Same for the next two tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

queryToTarget(query('collId'))
);
const index = fieldIndex('collId');
expect(() => targetIndexMatcher.servedByIndex(index)).to.not.throw;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any throw statements in target_index_matcher.ts. Similarly, I don't see any throw statements in TargetIndexMatcher.java.

does .to.throw and .to.not.throw apply to assertions (e.g. the debugAssert in the code)? The other examples of .to.throw that I found in other test files corresponded to a throw statement in the source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it applies to the assert.

}
});

it('array-contains is idempotent', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

ts:idempotent
java:independent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

independent it is

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Wheee... so many typos. Thanks for catching.

private readonly collectionId: string;
// The single inequality filter of the target (if it exists).
private readonly inequalityFilter?: FieldFilter;
// The list of equality filter of the target.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


// Process all equalities first. Equalities can appear out of order.
for (; segmentIndex < segments.length; ++segmentIndex) {
// We attempt to greedily match all segments to equality filters. If a a
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fun :)

// Process all equalities first. Equalities can appear out of order.
for (; segmentIndex < segments.length; ++segmentIndex) {
// We attempt to greedily match all segments to equality filters. If a a
// filter matches an index segments, we can mark the segment as used.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

...

for (; segmentIndex < segments.length; ++segmentIndex) {
// We attempt to greedily match all segments to equality filters. If a a
// filter matches an index segments, we can mark the segment as used.
// Since it is not possible to use the same filed path in both an equality
Copy link
Contributor Author

Choose a reason for hiding this comment

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

...

// We attempt to greedily match all segments to equality filters. If a a
// filter matches an index segments, we can mark the segment as used.
// Since it is not possible to use the same filed path in both an equality
// and inequality/oderBy cause, we do not have to consider the possibility
Copy link
Contributor Author

Choose a reason for hiding this comment

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

... sorry :/

++segmentIndex;
}

// All remaining segment need to represent the prefix of the target's
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

// All remaining segment need to represent the prefix of the target's
// orderBy
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
});

it('inequalitiesWithDefaultOrder', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

queryToTarget(query('collId'))
);
const index = fieldIndex('collId');
expect(() => targetIndexMatcher.servedByIndex(index)).to.not.throw;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it applies to the assert.

}
});

it('array-contains is idempotent', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

independent it is

@ehsannas
Copy link
Contributor

forgot to push your commit?

…rebase-js-sdk into mrschmidt/targetindexmatcher
@schmidt-sebastian
Copy link
Contributor Author

@ehsannas Yup, had to pull and then push!

@schmidt-sebastian schmidt-sebastian merged commit eaa5170 into master Feb 10, 2022
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/targetindexmatcher branch February 10, 2022 20:51
@firebase firebase locked and limited conversation to collaborators Mar 13, 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.

3 participants