Skip to content

Remove shared index entries #3138

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 2 commits into from
Nov 19, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ final class SQLiteIndexManager implements IndexManager {

private final SQLitePersistence db;
private final LocalSerializer serializer;
private final User user;
private final String uid;
private final Map<String, Map<Integer, FieldIndex>> memoizedIndexes;

private boolean started = false;
Expand All @@ -77,7 +77,7 @@ final class SQLiteIndexManager implements IndexManager {
SQLiteIndexManager(SQLitePersistence persistence, LocalSerializer serializer, User user) {
this.db = persistence;
this.serializer = serializer;
this.user = user;
this.uid = user.isAuthenticated() ? user.getUid() : "";
this.memoizedIndexes = new HashMap<>();
}

Expand Down Expand Up @@ -376,7 +376,7 @@ private void addSingleEntry(
"INSERT INTO index_entries (index_id, uid, array_value, directional_value, document_name) "
+ "VALUES(?, ?, ?, ?, ?)",
indexId,
document.hasLocalMutations() ? user.getUid() : null,
uid,
arrayValue,
directionalValue,
document.getKey().toString());
Expand Down Expand Up @@ -450,7 +450,7 @@ private SQLitePersistence.Query generateQuery(
// and an upper bound.
StringBuilder statement = new StringBuilder();
statement.append("SELECT document_name, directional_value FROM index_entries ");
statement.append("WHERE index_id = ? AND (uid IS NULL or uid = ?) ");
statement.append("WHERE index_id = ? AND uid = ? ");
if (arrayValues != null) {
statement.append("AND array_value = ? ");
}
Expand Down Expand Up @@ -504,7 +504,7 @@ private Object[] fillBounds(
int offset = 0;
for (int i = 0; i < statementCount; ++i) {
bindArgs[offset++] = indexId;
bindArgs[offset++] = user.getUid();
bindArgs[offset++] = uid;
if (arrayValues != null) {
bindArgs[offset++] = encodeSingleElement(arrayValues.get(i / statementsPerArrayValue));
}
Expand Down