Skip to content

Commit

Permalink
Merge branch 'master' into daymon-implement-move-changelog-task
Browse files Browse the repository at this point in the history
  • Loading branch information
daymxn authored Jul 19, 2023
2 parents 8b2a05d + 3fcf343 commit 9ce822f
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 61 deletions.
2 changes: 1 addition & 1 deletion firebase-appdistribution/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased
* [feature] Improved development mode to allow all API calls to be made without having to sign in.
* [fixed] Updated the third-party license file to include Dagger's license.

# 16.0.0-beta08
* [fixed] Fixed an issue where a crash happened whenever a feedback
Expand Down Expand Up @@ -67,4 +68,3 @@ The [appdistro] Android library with Kotlin extensions is now available in
beta. The Kotlin extensions library transitively includes the base
`firebase-app-distribution` library. To learn more, visit the
[[appdistro] KTX reference documentation](/docs/reference/kotlin/com/google/firebase/appdistribution/ktx/package-summary).

4 changes: 4 additions & 0 deletions firebase-appdistribution/firebase-appdistribution.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ android {
}
}

thirdPartyLicenses {
add 'Dagger', "${rootDir}/third_party/licenses/apache-2.0.txt"
}

dependencies {
implementation project(':firebase-appdistribution-api')
implementation 'com.google.firebase:firebase-components:17.1.0'
Expand Down
2 changes: 1 addition & 1 deletion firebase-firestore/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ package com.google.firebase.firestore {

public static class MemoryLruGcSettings.Builder {
method @NonNull public com.google.firebase.firestore.MemoryLruGcSettings build();
method public void setSizeBytes(long);
method @NonNull public com.google.firebase.firestore.MemoryLruGcSettings.Builder setSizeBytes(long);
}

public enum MetadataChanges {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,15 @@ public void testMultipleUpdatesWhileOffline() {

@Test
public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Exception {
// TODO(b/291365820): Stop skipping this test when running against the Firestore emulator once
// the emulator is improved to include a bloom filter in the existence filter "messages that it
// sends.
assumeFalse(
"Skip this test when running against the Firestore emulator because the emulator does not "
+ "include a bloom filter when it sends existence filter messages, making it "
+ "impossible for this test to verify the correctness of the bloom filter.",
isRunningAgainstEmulator());

// Prepare the names and contents of the 100 documents to create.
Map<String, Map<String, Object>> testData = new HashMap<>();
for (int i = 0; i < 100; i++) {
Expand All @@ -1068,21 +1077,18 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
}
assertWithMessage("createdDocuments").that(createdDocuments).hasSize(100);

// Delete 50 of the 100 documents. Do this in a transaction, rather than
// DocumentReference.delete(), to avoid affecting the local cache.
// Delete 50 of the 100 documents. Use a WriteBatch, rather than DocumentReference.delete(),
// to avoid affecting the local cache.
HashSet<String> deletedDocumentIds = new HashSet<>();
waitFor(
collection
.getFirestore()
.runTransaction(
transaction -> {
for (int i = 0; i < createdDocuments.size(); i += 2) {
DocumentReference documentToDelete = createdDocuments.get(i);
transaction.delete(documentToDelete);
deletedDocumentIds.add(documentToDelete.getId());
}
return null;
}));
{
WriteBatch writeBatchForDocumentDeletes = collection.getFirestore().batch();
for (int i = 0; i < createdDocuments.size(); i += 2) {
DocumentReference documentToDelete = createdDocuments.get(i);
writeBatchForDocumentDeletes.delete(documentToDelete);
deletedDocumentIds.add(documentToDelete.getId());
}
waitFor(writeBatchForDocumentDeletes.commit());
}
assertWithMessage("deletedDocumentIds").that(deletedDocumentIds).hasSize(50);

// Wait for 10 seconds, during which Watch will stop tracking the query and will send an
Expand All @@ -1103,33 +1109,19 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except

// Verify that the snapshot from the resumed query contains the expected documents; that is,
// that it contains the 50 documents that were _not_ deleted.
// TODO(b/270731363): Remove the "if" condition below once the Firestore Emulator is fixed to
// send an existence filter. At the time of writing, the Firestore emulator fails to send an
// existence filter, resulting in the client including the deleted documents in the snapshot
// of the resumed query.
if (!(isRunningAgainstEmulator() && snapshot2.size() == 100)) {
HashSet<String> actualDocumentIds = new HashSet<>();
for (DocumentSnapshot documentSnapshot : snapshot2.getDocuments()) {
actualDocumentIds.add(documentSnapshot.getId());
}
HashSet<String> expectedDocumentIds = new HashSet<>();
for (DocumentReference documentRef : createdDocuments) {
if (!deletedDocumentIds.contains(documentRef.getId())) {
expectedDocumentIds.add(documentRef.getId());
}
}
assertWithMessage("snapshot2.docs")
.that(actualDocumentIds)
.containsExactlyElementsIn(expectedDocumentIds);
HashSet<String> actualDocumentIds = new HashSet<>();
for (DocumentSnapshot documentSnapshot : snapshot2.getDocuments()) {
actualDocumentIds.add(documentSnapshot.getId());
}

// Skip the verification of the existence filter mismatch when testing against the Firestore
// emulator because the Firestore emulator does not include the `unchanged_names` bloom filter
// when it sends ExistenceFilter messages. Some day the emulator _may_ implement this logic,
// at which time this short-circuit can be removed.
if (isRunningAgainstEmulator()) {
return;
HashSet<String> expectedDocumentIds = new HashSet<>();
for (DocumentReference documentRef : createdDocuments) {
if (!deletedDocumentIds.contains(documentRef.getId())) {
expectedDocumentIds.add(documentRef.getId());
}
}
assertWithMessage("snapshot2.docs")
.that(actualDocumentIds)
.containsExactlyElementsIn(expectedDocumentIds);

// Verify that Watch sent an existence filter with the correct counts when the query was
// resumed.
Expand Down Expand Up @@ -1178,10 +1170,13 @@ private static String unicodeNormalize(String s) {

@Test
public void bloomFilterShouldCorrectlyEncodeComplexUnicodeCharacters() throws Exception {
// TODO(b/291365820): Stop skipping this test when running against the Firestore emulator once
// the emulator is improved to include a bloom filter in the existence filter "messages that it
// sends.
assumeFalse(
"Skip this test when running against the Firestore emulator because the Firestore emulator "
+ "fails to send existence filters when queries are resumed (b/270731363), and even "
+ "if it did send an existence filter it probably wouldn't include a bloom filter.",
"Skip this test when running against the Firestore emulator because the emulator does not "
+ "include a bloom filter when it sends existence filter messages, making it "
+ "impossible for this test to verify the correctness of the bloom filter.",
isRunningAgainstEmulator());

// Firestore does not do any Unicode normalization on the document IDs. Therefore, two document
Expand Down Expand Up @@ -1240,22 +1235,15 @@ public void bloomFilterShouldCorrectlyEncodeComplexUnicodeCharacters() throws Ex
.containsExactlyElementsIn(testDocIds);
}

// Delete one of the documents so that the next call to getDocs() will experience an existence
// filter mismatch. Do this deletion in a transaction, rather than using deleteDoc(), to avoid
// Delete one of the documents so that the next call to collection.get() will experience an
// existence filter mismatch. Use a WriteBatch, rather than DocumentReference.delete(), to avoid
// affecting the local cache.
DocumentReference documentToDelete = collection.document("DocumentToDelete");
waitFor(
collection
.getFirestore()
.runTransaction(
transaction -> {
DocumentSnapshot documentToDeleteSnapshot = transaction.get(documentToDelete);
assertWithMessage("documentToDeleteSnapshot.exists()")
.that(documentToDeleteSnapshot.exists())
.isTrue();
transaction.delete(documentToDelete);
return null;
}));
{
WriteBatch writeBatchForDocumentDeletes = collection.getFirestore().batch();
writeBatchForDocumentDeletes.delete(documentToDelete);
waitFor(writeBatchForDocumentDeletes.commit());
}

// Wait for 10 seconds, during which Watch will stop tracking the query and will send an
// existence filter rather than "delete" events when the query is resumed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
* Configures the SDK to use an eager garbage collector for memory cache. The eager garbage
* collector will attempt to remove any documents from SDK's memory cache as soon as it is no longer
* used.
*
* <p>This is the default garbage collector unless specified explicitly otherwise.
*
* <p>To use, create an instance using {@code MemoryEagerGcSettings#newBuilder().build()}, then set
* the instance to {@code MemoryCacheSettings.Builder#setGcSettings}, and use the built {@code
* MemoryCacheSettings} instance to configure the Firestore SDK.
*/
public final class MemoryEagerGcSettings implements MemoryGarbageCollectorSettings {
private MemoryEagerGcSettings() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

import androidx.annotation.NonNull;

/**
* Configures the SDK to use a Least-Recently-Used garbage collector for memory cache.
*
* <p>To use, create an instance using {@code MemoryLruGcSettings#newBuilder().build()}, then set
* the instance to {@code MemoryCacheSettings.Builder#setGcSettings}, and use the built {@code
* MemoryCacheSettings} instance to configure the Firestore SDK.
*/
public final class MemoryLruGcSettings implements MemoryGarbageCollectorSettings {

private long sizeBytes;
Expand All @@ -30,20 +37,43 @@ public MemoryLruGcSettings build() {
return new MemoryLruGcSettings(sizeBytes);
}

public void setSizeBytes(long size) {
/**
* Sets an approximate cache size threshold for the memory cache. If the cache grows beyond this
* size, Firestore SDK will start removing data that hasn't been recently used. The size is not
* a guarantee that the cache will stay below that size, only that if the cache exceeds the
* given size, cleanup will be attempted.
*
* <p>A default size of 100MB (100 * 1024 * 1024) is used if unset. The minimum value to set is
* 1 MB (1024 * 1024).
*
* @return this {@code Builder} instance.
*/
@NonNull
public Builder setSizeBytes(long size) {
sizeBytes = size;
return this;
}
}

private MemoryLruGcSettings(long size) {
sizeBytes = size;
}

/** Returns a new instance of {@link MemoryLruGcSettings.Builder} with default configurations. */
@NonNull
public static MemoryLruGcSettings.Builder newBuilder() {
return new Builder();
}

/**
* Returns cache size threshold for the memory cache. If the cache grows beyond this size,
* Firestore SDK will start removing data that hasn't been recently used. The size is not a
* guarantee that the cache will stay below that size, only that if the cache exceeds the given
* size, cleanup will be attempted.
*
* <p>By default, memory LRU cache is enabled with a cache size of 100MB (100 * 1024 * 1024). The
* minimum value is 1 MB (1024 * 1024).
*/
public long getSizeBytes() {
return sizeBytes;
}
Expand Down
4 changes: 3 additions & 1 deletion firebase-installations-interop/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
<!-- See the License for the specific language governing permissions and -->
<!-- limitations under the License. -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<!--<uses-sdk android:minSdkVersion="14"/>-->
</manifest>
1 change: 1 addition & 0 deletions firebase-ml-modeldownloader/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Unreleased
* [fixed] Updated the third-party license file to include Dagger's license.

# 24.1.2
* [changed] Internal infrastructure improvements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protobuf {
}

android {
namespace "com.google.firebase.ml.modeldownloader"
namespace "com.google.firebase.ml.modeldownloader"
compileSdkVersion project.targetSdkVersion

defaultConfig {
Expand All @@ -61,6 +61,10 @@ android {
}
}

thirdPartyLicenses {
add 'Dagger', "${rootDir}/third_party/licenses/apache-2.0.txt"
}

dependencies {
implementation 'com.google.firebase:firebase-encoders:17.0.0'
implementation 'com.google.firebase:firebase-encoders-json:18.0.0'
Expand Down

0 comments on commit 9ce822f

Please sign in to comment.