Skip to content

Commit 6349a09

Browse files
authored
Public Auto Persistent Index Creation API (#5256)
1 parent de35ba0 commit 6349a09

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

firebase-firestore/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# 24.7.1
44
* [fixed] Implement equals method on Filter class. [#5210](//github.com/firebase/firebase-android-sdk/issues/5210)
5+
* [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)
56

67
# 24.7.0
78
* [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 to create
360+
* cache indexes for queries 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
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ private void createCacheIndexes(Query query, QueryContext context, int resultSiz
145145
"The SDK decides to create cache indexes for query: %s, as using cache indexes "
146146
+ "may help improve performance.",
147147
query.toString());
148-
} else {
149-
Logger.debug(
150-
LOG_TAG,
151-
"The SDK decides not to create cache indexes for this query: %s, as using cache "
152-
+ "indexes may not help improve performance.",
153-
query.toString());
154148
}
155149
}
156150

0 commit comments

Comments
 (0)