-
Notifications
You must be signed in to change notification settings - Fork 617
Performance optimizations to speed up reading large collections #123
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
Changes from all commits
876e4eb
cfa2338
999d655
7fefc65
8b2af95
3585c3a
2438147
2f47171
4b02f9b
3e005bd
284e08b
56e1681
323d697
7ad6899
de3486c
44682ab
d5357d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,13 +48,19 @@ public LocalSerializer(RemoteSerializer rpcSerializer) { | |
com.google.firebase.firestore.proto.MaybeDocument encodeMaybeDocument(MaybeDocument document) { | ||
com.google.firebase.firestore.proto.MaybeDocument.Builder builder = | ||
com.google.firebase.firestore.proto.MaybeDocument.newBuilder(); | ||
|
||
if (document instanceof NoDocument) { | ||
NoDocument noDocument = (NoDocument) document; | ||
builder.setNoDocument(encodeNoDocument(noDocument)); | ||
builder.setHasCommittedMutations(noDocument.hasCommittedMutations()); | ||
} else if (document instanceof Document) { | ||
Document existingDocument = (Document) document; | ||
builder.setDocument(encodeDocument(existingDocument)); | ||
// Use the memoized encoded form if it exists. | ||
if (existingDocument.getProto() != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimization 1 ("Avoid encode"): avoid serializing a |
||
builder.setDocument(existingDocument.getProto()); | ||
} else { | ||
builder.setDocument(encodeDocument(existingDocument)); | ||
} | ||
builder.setHasCommittedMutations(existingDocument.hasCommittedMutations()); | ||
} else if (document instanceof UnknownDocument) { | ||
builder.setUnknownDocument(encodeUnknownDocument((UnknownDocument) document)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
import com.google.firebase.firestore.model.DocumentKey; | ||
import com.google.firebase.firestore.model.MaybeDocument; | ||
import com.google.firebase.firestore.model.ResourcePath; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
import javax.annotation.Nullable; | ||
|
@@ -53,6 +54,19 @@ public MaybeDocument get(DocumentKey key) { | |
return docs.get(key); | ||
} | ||
|
||
@Override | ||
public Map<DocumentKey, MaybeDocument> getAll(Iterable<DocumentKey> keys) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the reasons I'm returning a |
||
Map<DocumentKey, MaybeDocument> result = new HashMap<>(); | ||
|
||
for (DocumentKey key : keys) { | ||
// Make sure each key has a corresponding entry, which is null in case the document is not | ||
// found. | ||
result.put(key, get(key)); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
@Override | ||
public ImmutableSortedMap<DocumentKey, Document> getAllDocumentsMatchingQuery(Query query) { | ||
ImmutableSortedMap<DocumentKey, Document> result = emptyDocumentMap(); | ||
|
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.
Note the significant refactoring in this file.