-
Notifications
You must be signed in to change notification settings - Fork 626
Implement startAfter
for RTDB queries
#2277
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
Conversation
Coverage ReportAffected SDKs
Test Logs
NotesHTML coverage reports can be produced locally with Head commit (4219ab20) is created by Prow via merging commits: 4ffbf22 6c017d5. |
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
Binary Size ReportAffected SDKs
Test Logs
NotesHead commit (4219ab20) is created by Prow via merging commits: 4ffbf22 6c017d5. |
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/Query.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/Query.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/Query.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/Query.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/Query.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/Query.java
Outdated
Show resolved
Hide resolved
...database/src/main/java/com/google/firebase/database/connection/PersistentConnectionImpl.java
Outdated
Show resolved
Hide resolved
@schmidt-sebastian This is ready for another round of review. |
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
1 similar comment
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
ValueExpectationHelper helper = new ValueExpectationHelper(); | ||
helper.add( | ||
ref.startAfter("w").endAt("y"), | ||
new MapBuilder().put("d", 4L).put("b", 2L).put("c", 3L).build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why "d" is part of the result set when it has a priority of "w"?
@@ -1150,6 +1567,29 @@ public void startAtEndAtWithPriorityAndNameWorks2() | |||
helper.waitForEvents(); | |||
} | |||
|
|||
@Test | |||
public void startAfterEndAtWithPriorityAndNameWorks2() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a 2 here as a suffix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these didn't really add any value and were just blindly copy/pastes. I'm removed them.
@@ -1174,6 +1614,29 @@ public void startAtEndAtWithPriorityAndNameWorksWithServerData2() | |||
helper.waitForEvents(); | |||
} | |||
|
|||
@Test | |||
public void startAfterEndAtWithPriorityAndNameWorksWithServerData2() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a 2 as a suffix.
@@ -3054,6 +3661,45 @@ public void onCancelled(DatabaseError error) {} | |||
IntegrationTestHelpers.waitFor(done); | |||
} | |||
|
|||
@Test | |||
public void integerKeysBehaveNumericallyStartAfter1() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another strange suffix. If these are used to distinguish test cases, then we should come up with more specific names.
@@ -3142,6 +3788,46 @@ public void onCancelled(DatabaseError error) {} | |||
IntegrationTestHelpers.waitFor(done); | |||
} | |||
|
|||
@Test | |||
public void integerKeysBehaveNumerically3StartAfter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please come up with a more specific test name.
@@ -57,6 +65,38 @@ public static synchronized String generatePushChildName(long now) { | |||
return result.toString(); | |||
} | |||
|
|||
public static final String nextAfter(String key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This is usually called a successor.
...base-database/src/main/java/com/google/firebase/database/core/utilities/PushIdGenerator.java
Show resolved
Hide resolved
private static final char MAX_PUSH_CHAR = 'z'; | ||
|
||
private static final char MIN_PUSH_CHAR = '-'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Flip assignments for clarity.
You could also refer to PUSH_CHARS
and get the values from there (which will be slower and more code, so I am not sure it is actually worth it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sort of prefer having separate sentinel values for this since they trigger edge-cases in the successor
/predecessor
code.
@@ -273,4 +273,8 @@ public static boolean equals(@Nullable Object left, @Nullable Object right) { | |||
} | |||
return left.equals(right); | |||
} | |||
|
|||
public static String next(@Nullable String value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused.
@@ -56,11 +56,11 @@ public boolean isPriorityChildName() { | |||
return this.equals(PRIORITY_CHILD_KEY); | |||
} | |||
|
|||
protected boolean isInt() { | |||
public boolean isInt() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes don't seem to be needed.
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
The public api surface has changed for the subproject firebase-database: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
@schmidt-sebastian Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM(ish), depending on how we handle the "startAfter(null)" case.
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
...base-database/src/main/java/com/google/firebase/database/core/utilities/PushIdGenerator.java
Outdated
Show resolved
Hide resolved
...base-database/src/main/java/com/google/firebase/database/core/utilities/PushIdGenerator.java
Show resolved
Hide resolved
|
||
ValueExpectationHelper expectations = new ValueExpectationHelper(); | ||
|
||
expectations.add(ref.startAfter(null).limitToFirst(1), null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's talk about this offline. My gut feeling is that this should match all results, since they order past null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an explanation here: https://github.com/firebase/firebase-ios-sdk/pull/7209/files#r556060181.
I know this reads funny, but I think it is the intended behavior because we are indexing on priority.
@schmidt-sebastian The copyright check is failing for an unrelated file. The device-check-changed check runs
Which I ran locally on master and it failed in the same way it does here. I'm going to assume these CI checks are not needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please add changelog entry to https://github.com/firebase/firebase-android-sdk/blob/master/firebase-database/CHANGELOG.md
firebase-database/src/test/java/com/google/firebase/database/PushIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
* Implement `endBefore` for RTDB queries * cleanup * Fix bug in prevBefore * Handle endBefore(..., Integer.MIN_VALUE) * respect key ordering * Add more tests, check key order boundary conditions * Generate api text file * Unit tests for predecessor * cleanup
startAfter
for RTDB queriesstartAfter
and endBefore
for RTDB queries
@IanWyszynski: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
startAfter
and endBefore
for RTDB queriesstartAfter
for RTDB queries
go/rtdb-exclusive-query-filters
startAfter(value, key)
means:If
key == undefined or null
,startAt(value, MAX_NAME)
, else,startAt(value, key + 1)
, where+ 1
means either the next integer (if the key is parseable as an int), or the lexicographically next key.