Skip to content

Commit c145203

Browse files
committed
More feedback.
1 parent 4c53217 commit c145203

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalDocumentsView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ private void recalculateAndSaveOverlays(Map<DocumentKey, MutableDocument> docs)
203203
// along the way.
204204
for (MutationBatch batch : batches) {
205205
for (DocumentKey key : batch.getKeys()) {
206-
FieldMask mask =
207-
masks.containsKey(key) ? masks.get(key) : FieldMask.fromSet(new HashSet<>());
206+
FieldMask mask = masks.containsKey(key) ? masks.get(key) : FieldMask.EMPTY;
208207
mask = batch.applyToLocalView(docs.get(key), mask);
209208
masks.put(key, mask);
210209
int batchId = batch.getBatchId();

firebase-firestore/src/main/java/com/google/firebase/firestore/model/mutation/FieldMask.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.firebase.firestore.model.mutation;
1616

1717
import com.google.firebase.firestore.model.FieldPath;
18+
import java.util.HashSet;
1819
import java.util.Set;
1920

2021
/**
@@ -26,6 +27,8 @@
2627
* object foo. If foo is not an object, foo is replaced with an object containing foo.
2728
*/
2829
public final class FieldMask {
30+
public static FieldMask EMPTY = fromSet(new HashSet<>());
31+
2932
public static FieldMask fromSet(Set<FieldPath> mask) {
3033
return new FieldMask(mask);
3134
}

firebase-firestore/src/test/java/com/google/firebase/firestore/local/LocalStoreTestCase.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
import org.junit.After;
8484
import org.junit.Assert;
8585
import org.junit.Before;
86-
import org.junit.Ignore;
8786
import org.junit.Test;
8887

8988
/**
@@ -154,7 +153,8 @@ private void udpateViews(int targetId, boolean fromCache) {
154153
notifyLocalViewChanges(viewChanges(targetId, fromCache, asList(), asList()));
155154
}
156155

157-
private void acknowledgeMutationWithTransform(long documentVersion, Object... transformResult) {
156+
private void acknowledgeMutationWithTransformResults(
157+
long documentVersion, Object... transformResult) {
158158
MutationBatch batch = batches.remove(0);
159159
SnapshotVersion version = version(documentVersion);
160160
List<MutationResult> mutationResults =
@@ -172,7 +172,7 @@ private void acknowledgeMutationWithTransform(long documentVersion, Object... tr
172172
}
173173

174174
private void acknowledgeMutation(long documentVersion) {
175-
acknowledgeMutationWithTransform(documentVersion, null);
175+
acknowledgeMutationWithTransformResults(documentVersion, null);
176176
}
177177

178178
private void rejectMutation() {
@@ -1074,7 +1074,7 @@ public void testHandlesSetMutationThenAckThenTransformThenAckThenTransform() {
10741074
assertContains(doc("foo/bar", 1, map("sum", 1)).setHasLocalMutations());
10751075
assertChanged(doc("foo/bar", 1, map("sum", 1)).setHasLocalMutations());
10761076

1077-
acknowledgeMutationWithTransform(2, 1);
1077+
acknowledgeMutationWithTransformResults(2, 1);
10781078
assertChanged(doc("foo/bar", 2, map("sum", 1)).setHasCommittedMutations());
10791079
assertContains(doc("foo/bar", 2, map("sum", 1)).setHasCommittedMutations());
10801080

@@ -1288,11 +1288,11 @@ public void testHandlesSetMutationThenTransformThenRemoteEventThenTransform() {
12881288
assertChanged(doc("foo/bar", 2, map("sum", 3)).setHasLocalMutations());
12891289
assertContains(doc("foo/bar", 2, map("sum", 3)).setHasLocalMutations());
12901290

1291-
acknowledgeMutationWithTransform(3, 1);
1291+
acknowledgeMutationWithTransformResults(3, 1);
12921292
assertChanged(doc("foo/bar", 3, map("sum", 3)).setHasLocalMutations());
12931293
assertContains(doc("foo/bar", 3, map("sum", 3)).setHasLocalMutations());
12941294

1295-
acknowledgeMutationWithTransform(4, 1339);
1295+
acknowledgeMutationWithTransformResults(4, 1339);
12961296
assertChanged(doc("foo/bar", 4, map("sum", 1339)).setHasCommittedMutations());
12971297
assertContains(doc("foo/bar", 4, map("sum", 1339)).setHasCommittedMutations());
12981298
}
@@ -1337,7 +1337,7 @@ public void testHoldsBackTransforms() {
13371337
assertChanged(
13381338
doc("foo/bar", 2, map("sum", 1, "array_union", asList("foo"))).setHasLocalMutations());
13391339

1340-
acknowledgeMutationWithTransform(3, 1338, asList("bar", "foo"));
1340+
acknowledgeMutationWithTransformResults(3, 1338, asList("bar", "foo"));
13411341
assertChanged(
13421342
doc("foo/bar", 3, map("sum", 1338, "array_union", asList("bar", "foo")))
13431343
.withReadTime(new SnapshotVersion(new Timestamp(0, 3000)))

0 commit comments

Comments
 (0)