Skip to content

Commit 39771c3

Browse files
committed
Release Overlay
1 parent 9e93fff commit 39771c3

File tree

13 files changed

+36
-215
lines changed

13 files changed

+36
-215
lines changed

firebase-firestore/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ Android changes are not released automatically. Ensure that changes are released
22
by opting into a release at
33
[go/firebase-android-release](http:go/firebase-android-release) (Googlers only).
44

5-
# Unreleased
5+
# 24.1.0
6+
- [feature] Performance optimization for offline usage.
7+
8+
# 24.0.0
69
- [feature] Added support for Firebase AppCheck.
710

811
# 23.0.4

firebase-firestore/firebase-firestore.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ android.libraryVariants.all { variant ->
112112
} else {
113113
variant.buildConfigField("boolean", "ENABLE_INDEXING", "false")
114114
}
115-
116-
// TODO(Overlay): Delete below once overlay is shipped.
117-
if (localProps['firestoreEnableOverlay']) {
118-
variant.buildConfigField("boolean", "ENABLE_OVERLAY", "true")
119-
} else {
120-
variant.buildConfigField("boolean", "ENABLE_OVERLAY", "false")
121-
}
122115
}
123116

124117
configurations.all {

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ public static FirebaseFirestore testFirestore(
255255
// This unfortunately is a global setting that affects existing Firestore clients.
256256
Logger.setLogLevel(logLevel);
257257

258-
// TODO(Overlay): Remove below once this is ready to ship.
259-
Persistence.OVERLAY_SUPPORT_ENABLED = true;
260258
Persistence.INDEXING_SUPPORT_ENABLED = true;
261259

262260
Context context = ApplicationProvider.getApplicationContext();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public abstract class Persistence {
5252

5353
/** Temporary setting for enabling document overlays. */
5454
// TODO(Overlay): Remove this.
55-
public static boolean OVERLAY_SUPPORT_ENABLED = BuildConfig.ENABLE_OVERLAY;
55+
public static boolean OVERLAY_SUPPORT_ENABLED = true;
5656
/** Constant string to indicate a data migration is required to support overlays. */
5757
public static String DATA_MIGRATION_BUILD_OVERLAYS = "BUILD_OVERLAYS";
5858

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.Map;
3131
import org.junit.After;
3232
import org.junit.Before;
33-
import org.junit.BeforeClass;
3433
import org.junit.Rule;
3534
import org.junit.Test;
3635
import org.junit.rules.TestName;
@@ -52,17 +51,6 @@ public abstract class DocumentOverlayCacheTestCase {
5251
private DocumentOverlayCache overlays;
5352
private static boolean overlayEnabled = false;
5453

55-
@BeforeClass
56-
public static void beforeClass() {
57-
overlayEnabled = Persistence.OVERLAY_SUPPORT_ENABLED;
58-
Persistence.OVERLAY_SUPPORT_ENABLED = true;
59-
}
60-
61-
@BeforeClass
62-
public static void afterClass() {
63-
Persistence.OVERLAY_SUPPORT_ENABLED = overlayEnabled;
64-
}
65-
6654
@Before
6755
public void setUp() {
6856
persistence = getPersistence();

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

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@
7474
import com.google.firebase.firestore.testutil.TestUtil;
7575
import com.google.firebase.firestore.util.AsyncQueue;
7676
import java.util.ArrayList;
77+
import java.util.Arrays;
7778
import java.util.Collections;
7879
import java.util.List;
7980
import java.util.Map.Entry;
8081
import java.util.Set;
82+
import java.util.stream.Collectors;
8183
import javax.annotation.Nullable;
8284
import org.junit.After;
8385
import org.junit.Assert;
@@ -152,23 +154,22 @@ private void udpateViews(int targetId, boolean fromCache) {
152154
notifyLocalViewChanges(viewChanges(targetId, fromCache, asList(), asList()));
153155
}
154156

155-
private void acknowledgeMutation(long documentVersion, @Nullable Object transformResult) {
157+
private void acknowledgeMutationWithTransform(long documentVersion, Object... transformResult) {
156158
MutationBatch batch = batches.remove(0);
157159
SnapshotVersion version = version(documentVersion);
158-
MutationResult mutationResult =
159-
new MutationResult(
160-
version,
161-
transformResult != null
162-
? Collections.singletonList(TestUtil.wrap(transformResult))
163-
: Collections.emptyList());
160+
List<MutationResult> mutationResults =
161+
transformResult == null
162+
? singletonList(new MutationResult(version, emptyList()))
163+
: Arrays.stream(transformResult)
164+
.map(o -> new MutationResult(version, Collections.singletonList(TestUtil.wrap(o))))
165+
.collect(Collectors.toList());
164166
MutationBatchResult result =
165-
MutationBatchResult.create(
166-
batch, version, singletonList(mutationResult), WriteStream.EMPTY_STREAM_TOKEN);
167+
MutationBatchResult.create(batch, version, mutationResults, WriteStream.EMPTY_STREAM_TOKEN);
167168
lastChanges = localStore.acknowledgeBatch(result);
168169
}
169170

170171
private void acknowledgeMutation(long documentVersion) {
171-
acknowledgeMutation(documentVersion, null);
172+
acknowledgeMutationWithTransform(documentVersion, null);
172173
}
173174

174175
private void rejectMutation() {
@@ -963,9 +964,8 @@ public void testReadsAllDocumentsForInitialCollectionQueries() {
963964
localStore.executeQuery(query, /* usePreviousResults= */ true);
964965

965966
assertRemoteDocumentsRead(/* byKey= */ 0, /* byQuery= */ 2);
966-
if (!Persistence.OVERLAY_SUPPORT_ENABLED) {
967-
assertMutationsRead(/* byKey= */ 0, /* byQuery= */ 1);
968-
}
967+
// No mutations are read because only overlay is needed.
968+
assertMutationsRead(/* byKey= */ 0, /* byQuery= */ 0);
969969
}
970970

971971
@Test
@@ -1059,7 +1059,7 @@ public void testHandlesSetMutationThenAckThenTransformThenAckThenTransform() {
10591059
assertContains(doc("foo/bar", 1, map("sum", 1)).setHasLocalMutations());
10601060
assertChanged(doc("foo/bar", 1, map("sum", 1)).setHasLocalMutations());
10611061

1062-
acknowledgeMutation(2, 1);
1062+
acknowledgeMutationWithTransform(2, 1);
10631063
assertChanged(doc("foo/bar", 2, map("sum", 1)).setHasCommittedMutations());
10641064
assertContains(doc("foo/bar", 2, map("sum", 1)).setHasCommittedMutations());
10651065

@@ -1273,17 +1273,17 @@ public void testHandlesSetMutationThenTransformThenRemoteEventThenTransform() {
12731273
assertChanged(doc("foo/bar", 2, map("sum", 3)).setHasLocalMutations());
12741274
assertContains(doc("foo/bar", 2, map("sum", 3)).setHasLocalMutations());
12751275

1276-
acknowledgeMutation(3, 1);
1276+
acknowledgeMutationWithTransform(3, 1);
12771277
assertChanged(doc("foo/bar", 3, map("sum", 3)).setHasLocalMutations());
12781278
assertContains(doc("foo/bar", 3, map("sum", 3)).setHasLocalMutations());
12791279

1280-
acknowledgeMutation(4, 1339);
1280+
acknowledgeMutationWithTransform(4, 1339);
12811281
assertChanged(doc("foo/bar", 4, map("sum", 1339)).setHasCommittedMutations());
12821282
assertContains(doc("foo/bar", 4, map("sum", 1339)).setHasCommittedMutations());
12831283
}
12841284

12851285
@Test
1286-
public void testHoldsBackOnlyNonIdempotentTransforms() {
1286+
public void testHoldsBackTransforms() {
12871287
Query query = Query.atPath(ResourcePath.fromString("foo"));
12881288
allocateQuery(query);
12891289
assertTargetId(2);
@@ -1320,8 +1320,13 @@ public void testHoldsBackOnlyNonIdempotentTransforms() {
13201320
asList(2),
13211321
emptyList()));
13221322
assertChanged(
1323-
doc("foo/bar", 2, map("sum", 1, "array_union", asList("bar", "foo")))
1324-
.setHasLocalMutations());
1323+
doc("foo/bar", 2, map("sum", 1, "array_union", asList("foo"))).setHasLocalMutations());
1324+
1325+
acknowledgeMutationWithTransform(3, 1338, asList("bar", "foo"));
1326+
assertChanged(
1327+
doc("foo/bar", 3, map("sum", 1338, "array_union", asList("bar", "foo")))
1328+
.withReadTime(new SnapshotVersion(new Timestamp(0, 3000)))
1329+
.setHasCommittedMutations());
13251330
}
13261331

13271332
@Test

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
package com.google.firebase.firestore.local;
1616

17-
import org.junit.AfterClass;
18-
import org.junit.BeforeClass;
1917
import org.junit.runner.RunWith;
2018
import org.robolectric.RobolectricTestRunner;
2119
import org.robolectric.annotation.Config;
@@ -25,17 +23,6 @@
2523
public class MemoryLocalStoreTest extends LocalStoreTestCase {
2624
private static boolean enabled = false;
2725

28-
@BeforeClass
29-
public static void beforeClass() {
30-
enabled = Persistence.OVERLAY_SUPPORT_ENABLED;
31-
Persistence.OVERLAY_SUPPORT_ENABLED = false;
32-
}
33-
34-
@AfterClass
35-
public static void afterClass() {
36-
Persistence.OVERLAY_SUPPORT_ENABLED = enabled;
37-
}
38-
3926
@Override
4027
Persistence getPersistence() {
4128
return PersistenceTestHelpers.createEagerGCMemoryPersistence();

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

Lines changed: 0 additions & 54 deletions
This file was deleted.

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

Lines changed: 0 additions & 54 deletions
This file was deleted.

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,16 +408,4 @@ public void doesNotIncludeDocumentsDeletedByMutation() throws Exception {
408408
targetCache.getMatchingKeysForTargetId(TEST_TARGET_ID)));
409409
assertEquals(emptyMutableDocumentMap().insert(MATCHING_DOC_A.getKey(), MATCHING_DOC_A), docs);
410410
}
411-
412-
@Test
413-
public void doesNotIncludeDocumentsDeletedByMutation_OverlayEnabled() throws Exception {
414-
boolean saved = Persistence.OVERLAY_SUPPORT_ENABLED;
415-
Persistence.OVERLAY_SUPPORT_ENABLED = true;
416-
417-
try {
418-
doesNotIncludeDocumentsDeletedByMutation();
419-
} finally {
420-
Persistence.OVERLAY_SUPPORT_ENABLED = saved;
421-
}
422-
}
423411
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
package com.google.firebase.firestore.local;
1616

17-
import org.junit.AfterClass;
18-
import org.junit.BeforeClass;
1917
import org.junit.runner.RunWith;
2018
import org.robolectric.RobolectricTestRunner;
2119
import org.robolectric.annotation.Config;
@@ -25,17 +23,6 @@
2523
public class SQLiteLocalStoreTest extends LocalStoreTestCase {
2624
private static boolean enabled = false;
2725

28-
@BeforeClass
29-
public static void beforeClass() {
30-
enabled = Persistence.OVERLAY_SUPPORT_ENABLED;
31-
Persistence.OVERLAY_SUPPORT_ENABLED = false;
32-
}
33-
34-
@AfterClass
35-
public static void afterClass() {
36-
Persistence.OVERLAY_SUPPORT_ENABLED = enabled;
37-
}
38-
3926
@Override
4027
Persistence getPersistence() {
4128
return PersistenceTestHelpers.createSQLitePersistence();

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
import java.util.Collections;
3636
import java.util.List;
3737
import org.junit.After;
38-
import org.junit.AfterClass;
3938
import org.junit.Before;
40-
import org.junit.BeforeClass;
4139
import org.junit.Test;
4240
import org.junit.runner.RunWith;
4341
import org.robolectric.RobolectricTestRunner;
@@ -51,17 +49,6 @@ public class SQLiteOverlayMigrationManagerTest {
5149
private Persistence persistence;
5250
private LocalStore localStore;
5351

54-
@BeforeClass
55-
public static void beforeClass() {
56-
overlayEnabled = Persistence.OVERLAY_SUPPORT_ENABLED;
57-
Persistence.OVERLAY_SUPPORT_ENABLED = true;
58-
}
59-
60-
@AfterClass
61-
public static void afterClass() {
62-
Persistence.OVERLAY_SUPPORT_ENABLED = overlayEnabled;
63-
}
64-
6552
@Before
6653
public void setUp() {
6754
persistence =

0 commit comments

Comments
 (0)