-
Notifications
You must be signed in to change notification settings - Fork 617
Only fetch 50 documents per backfill #3193
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 (4b5d63f4) is created by Prow via merging commits: 110b867 a3a03b1. |
Binary Size ReportAffected SDKs
Test Logs
NotesHead commit (4b5d63f4) is created by Prow via merging commits: 110b867 a3a03b1. |
778a22d
to
2fed47b
Compare
2fed47b
to
2aa194a
Compare
2aa194a
to
fc00ff6
Compare
/retest |
FYI
|
firebase-firestore/src/main/java/com/google/firebase/firestore/local/RemoteDocumentCache.java
Outdated
Show resolved
Hide resolved
for (int i = 0; i < collections.size(); i += pageSize) { | ||
results.putAll( | ||
getAll( | ||
collections.subList(i, Math.min(collections.size(), i + pageSize)), offset, count)); |
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.
Each fan out call to getAll
is called with count
, then added directly to the result. So the result could be #collections * count
?
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.
Only if collections > 100. The maximum number of documents returned is (Math.max(collections / 100) * 50)
. Do you think we should post-process this list?
Actually, let me just add this code. The list should only have 50 elements so there is very little overhead.
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 see. I still think we should explain what pageSize
is here, and I also feel there is a better name..
...e-firestore/src/main/java/com/google/firebase/firestore/local/SQLiteRemoteDocumentCache.java
Show resolved
Hide resolved
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.
@Override | ||
public Map<DocumentKey, MutableDocument> getAll( | ||
String collectionGroup, IndexOffset offset, int limit) { | ||
// Note: This method is pretty inefficient, but t is not called since the method is only used |
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.
t -> 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.
Also, if this is the case then maybe just throw an exception here?
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.
Changed to throw exception.
...e-firestore/src/main/java/com/google/firebase/firestore/local/SQLiteRemoteDocumentCache.java
Show resolved
Hide resolved
for (int i = 0; i < collections.size(); i += pageSize) { | ||
results.putAll( | ||
getAll( | ||
collections.subList(i, Math.min(collections.size(), i + pageSize)), offset, count)); |
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 see. I still think we should explain what pageSize
is here, and I also feel there is a better name..
@@ -366,4 +368,19 @@ public static StringBuilder repeatSequence( | |||
private static <T> T advanceIterator(Iterator<T> it) { | |||
return it.hasNext() ? it.next() : null; | |||
} | |||
|
|||
/** Returns a map with the first {#code count} elements of {#code data} when sorted by comp. */ | |||
public static <K, V> Map<K, V> trimMap(Map<K, V> data, int count, Comparator<V> comp) { |
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.
What about firstNEntries
?
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
This PR adds a dedicated API to the RemoteDocumentCache to fetch the next 50 documents per collection group. This is done with a giant UNION statement.