-
Notifications
You must be signed in to change notification settings - Fork 946
Support descending queries #6075
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
|
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1This report is too large (746,042 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 |
f30d19a
to
c2ab3f5
Compare
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 are some index manager test failures.
} | ||
break; |
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.
We should port this change (adding a break
statement) to the Android SDK.
segmentValue = filterValue; | ||
segmentInclusive = filterInclusive; | ||
} | ||
function targetGetAscendingBound( |
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.
Add comments about what the function does.
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.
same for targetGetDescendingBound
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.
Done
}); | ||
}); | ||
} | ||
); | ||
}).next(() => result as DocumentKeySet | null); | ||
}).next(() => result as DocumentKey[] | 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.
is as DocumentKey[]
needed here? result
is already of type DocumentKey[]
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.
We are casting to DocumentKey[] | null
. This means that the function returns PersistencePromise<DocumentKey[] | null>
rather than PersistencePromise<DocumentKey[]> | PersistencePromise<null>
, which is unfortunately a differen type.
@@ -79,6 +79,18 @@ export function fieldIndexGetDirectionalSegments( | |||
return fieldIndex.fields.filter(s => s.kind !== IndexKind.CONTAINS); | |||
} | |||
|
|||
/** | |||
* Returns the order of the document key component. |
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.
Returns the order of the document key component for the given index
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.
Done
@@ -906,15 +935,17 @@ export class IndexedDbIndexManager implements IndexManager { | |||
this.uid, | |||
bounds[i].arrayValue, | |||
bounds[i].directionalValue, | |||
new Uint8Array(), |
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'm guessing the encoding of an empty string is an empty byte array
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.
OrderedCodeWriter writes bytes, so this is the byte array that sorts before any other byte arrays.
* The document key this entry points to. This entry is encoded by an ordered | ||
* encoder to match the key order of the index. | ||
*/ | ||
orderedDocumentKey: Uint8Array; |
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.
Is it true that if the order was always ASC, then using EncodedResourcePath
below would have sufficed? in order words: is the only reason we need this is because of DESC indexes?
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.
Yes. EncodedResourcePath already does some gymnastics to make sure that paths order naturally, even if there the slashes would yield our of order results normally. With EncodedResourcePath, we get: a/b
, a/c
, aa/c
instead of a/b
, aa/b
, a/c
for example (example-ish, since the sorting is off here too)
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.
FWIW, I changed the documentKey
entry to no longer use EncodedResourcePath
since we no longer rely on any ordering.
Changeset File Check
|
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.
Still seeing these two test failures:
-
Target Bounds
less than query: -
Target Bounds
greater than or equals query:
I fixed the test failures. Sorry for not catching them earlier. I think we should write better test helpers to reduce the repetitiveness of the bounds tests, but I can't get myself to do that on my current setup. |
This adds code to order all query results by document key, which is needed to return the correct result for limit queries.
Port of firebase/firebase-android-sdk#3499