Skip to content

Commit 52bbf21

Browse files
committed
Public Auto Persistent Index Creation API
1 parent f2a0fa3 commit 52bbf21

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

firebase-firestore/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22
* [fixed] Implement equals method on Filter class. [#5210](//github.com/firebase/firebase-android-sdk/issues/5210)
3+
* [feature] Add option to allow SDK create cache indexes automatically to improve query execution locally. [`db.getPersistentCacheIndexManager().enableIndexAutoCreation()`](//github.com/firebase/firebase-android-sdk/pull/4987)
34

45
# 24.7.0
56
* [feature] Expose MultiDb support in API. [#4015](//github.com/firebase/firebase-android-sdk/issues/4015)

firebase-firestore/api.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ package com.google.firebase.firestore {
189189
method @NonNull public static com.google.firebase.firestore.FirebaseFirestore getInstance(@NonNull String);
190190
method @NonNull public static com.google.firebase.firestore.FirebaseFirestore getInstance(@NonNull com.google.firebase.FirebaseApp, @NonNull String);
191191
method @NonNull public com.google.android.gms.tasks.Task<com.google.firebase.firestore.Query> getNamedQuery(@NonNull String);
192+
method @Nullable public com.google.firebase.firestore.PersistentCacheIndexManager getPersistentCacheIndexManager();
192193
method @NonNull public com.google.firebase.firestore.LoadBundleTask loadBundle(@NonNull java.io.InputStream);
193194
method @NonNull public com.google.firebase.firestore.LoadBundleTask loadBundle(@NonNull byte[]);
194195
method @NonNull public com.google.firebase.firestore.LoadBundleTask loadBundle(@NonNull java.nio.ByteBuffer);
@@ -357,6 +358,12 @@ package com.google.firebase.firestore {
357358
method public void onProgress(@NonNull ProgressT);
358359
}
359360

361+
public final class PersistentCacheIndexManager {
362+
method public void deleteAllIndexes();
363+
method public void disableIndexAutoCreation();
364+
method public void enableIndexAutoCreation();
365+
}
366+
360367
public final class PersistentCacheSettings implements com.google.firebase.firestore.LocalCacheSettings {
361368
method public long getSizeBytes();
362369
method @NonNull public static com.google.firebase.firestore.PersistentCacheSettings.Builder newBuilder();

firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import androidx.annotation.Keep;
2424
import androidx.annotation.NonNull;
2525
import androidx.annotation.Nullable;
26-
import androidx.annotation.RestrictTo;
2726
import androidx.annotation.VisibleForTesting;
2827
import com.google.android.gms.tasks.Task;
2928
import com.google.android.gms.tasks.TaskCompletionSource;
@@ -356,7 +355,11 @@ public FirebaseApp getApp() {
356355
* @param json The JSON format exported by the Firebase CLI.
357356
* @return A task that resolves once all indices are successfully configured.
358357
* @throws IllegalArgumentException if the JSON format is invalid
358+
* @deprecated Instead of creating cache indexes manually, consider using {@link
359+
* PersistentCacheIndexManager#enableIndexAutoCreation()} to let SDK decide whether cache
360+
* indexed should be created for query running locally.
359361
*/
362+
@Deprecated
360363
@PreviewApi
361364
@NonNull
362365
public Task<Void> setIndexConfiguration(@NonNull String json) {
@@ -412,9 +415,6 @@ public Task<Void> setIndexConfiguration(@NonNull String json) {
412415
* @return The {@code PersistentCacheIndexManager} instance or null if local persistent storage is
413416
* not in use.
414417
*/
415-
// TODO(csi): Remove the `hide` and scope annotations.
416-
/** @hide */
417-
@RestrictTo(RestrictTo.Scope.LIBRARY)
418418
@Nullable
419419
public synchronized PersistentCacheIndexManager getPersistentCacheIndexManager() {
420420
ensureClientConfigured();

firebase-firestore/src/main/java/com/google/firebase/firestore/PersistentCacheIndexManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
*
2525
* <p>To use, call {@link FirebaseFirestore#getPersistentCacheIndexManager()} to get an instance.
2626
*/
27-
// TODO(csi): Remove the `hide` and scope annotations.
28-
/** @hide */
29-
@RestrictTo(RestrictTo.Scope.LIBRARY)
3027
public final class PersistentCacheIndexManager {
3128
@NonNull private FirestoreClient client;
3229

30+
/** @hide */
31+
@RestrictTo(RestrictTo.Scope.LIBRARY)
3332
PersistentCacheIndexManager(FirestoreClient client) {
3433
this.client = client;
3534
}

0 commit comments

Comments
 (0)