Skip to content

Public Auto Persistent Index Creation API #5256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions firebase-firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased
* [fixed] Implement equals method on Filter class. [#5210](//github.com/firebase/firebase-android-sdk/issues/5210)
* [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)

# 24.7.0
* [feature] Expose MultiDb support in API. [#4015](//github.com/firebase/firebase-android-sdk/issues/4015)
Expand Down
7 changes: 7 additions & 0 deletions firebase-firestore/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ package com.google.firebase.firestore {
method @NonNull public static com.google.firebase.firestore.FirebaseFirestore getInstance(@NonNull String);
method @NonNull public static com.google.firebase.firestore.FirebaseFirestore getInstance(@NonNull com.google.firebase.FirebaseApp, @NonNull String);
method @NonNull public com.google.android.gms.tasks.Task<com.google.firebase.firestore.Query> getNamedQuery(@NonNull String);
method @Nullable public com.google.firebase.firestore.PersistentCacheIndexManager getPersistentCacheIndexManager();
method @NonNull public com.google.firebase.firestore.LoadBundleTask loadBundle(@NonNull java.io.InputStream);
method @NonNull public com.google.firebase.firestore.LoadBundleTask loadBundle(@NonNull byte[]);
method @NonNull public com.google.firebase.firestore.LoadBundleTask loadBundle(@NonNull java.nio.ByteBuffer);
Expand Down Expand Up @@ -357,6 +358,12 @@ package com.google.firebase.firestore {
method public void onProgress(@NonNull ProgressT);
}

public final class PersistentCacheIndexManager {
method public void deleteAllIndexes();
method public void disableIndexAutoCreation();
method public void enableIndexAutoCreation();
}

public final class PersistentCacheSettings implements com.google.firebase.firestore.LocalCacheSettings {
method public long getSizeBytes();
method @NonNull public static com.google.firebase.firestore.PersistentCacheSettings.Builder newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
Expand Down Expand Up @@ -356,7 +355,11 @@ public FirebaseApp getApp() {
* @param json The JSON format exported by the Firebase CLI.
* @return A task that resolves once all indices are successfully configured.
* @throws IllegalArgumentException if the JSON format is invalid
* @deprecated Instead of creating cache indexes manually, consider using {@link
* PersistentCacheIndexManager#enableIndexAutoCreation()} to let SDK decide whether to create
* cache indexes for queries running locally.
*/
@Deprecated
@PreviewApi
@NonNull
public Task<Void> setIndexConfiguration(@NonNull String json) {
Expand Down Expand Up @@ -412,9 +415,6 @@ public Task<Void> setIndexConfiguration(@NonNull String json) {
* @return The {@code PersistentCacheIndexManager} instance or null if local persistent storage is
* not in use.
*/
// TODO(csi): Remove the `hide` and scope annotations.
/** @hide */
@RestrictTo(RestrictTo.Scope.LIBRARY)
@Nullable
public synchronized PersistentCacheIndexManager getPersistentCacheIndexManager() {
ensureClientConfigured();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
*
* <p>To use, call {@link FirebaseFirestore#getPersistentCacheIndexManager()} to get an instance.
*/
// TODO(csi): Remove the `hide` and scope annotations.
/** @hide */
@RestrictTo(RestrictTo.Scope.LIBRARY)
public final class PersistentCacheIndexManager {
@NonNull private FirestoreClient client;

/** @hide */
@RestrictTo(RestrictTo.Scope.LIBRARY)
PersistentCacheIndexManager(FirestoreClient client) {
this.client = client;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ private void createCacheIndexes(Query query, QueryContext context, int resultSiz
"The SDK decides to create cache indexes for query: %s, as using cache indexes "
+ "may help improve performance.",
query.toString());
} else {
Logger.debug(
LOG_TAG,
"The SDK decides not to create cache indexes for this query: %s, as using cache "
+ "indexes may not help improve performance.",
query.toString());
}
}

Expand Down