Skip to content

Commit bfede01

Browse files
Revert: Index-Free Queries (code, feature still disabled) (#727)
1 parent 11fd0d6 commit bfede01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+200
-1522
lines changed

firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/TestUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ public static QuerySnapshot querySnapshot(
117117
documentChanges,
118118
isFromCache,
119119
mutatedKeys,
120-
/* synced= */ false,
121-
/* didSyncStateChange= */ true,
120+
true,
122121
/* excludesMetadataChanges= */ false);
123122
return new QuerySnapshot(query(path), viewSnapshot, FIRESTORE);
124123
}

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/remote/RemoteStoreTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.google.firebase.firestore.local.LocalStore;
2525
import com.google.firebase.firestore.local.MemoryPersistence;
2626
import com.google.firebase.firestore.local.Persistence;
27-
import com.google.firebase.firestore.local.SimpleQueryEngine;
2827
import com.google.firebase.firestore.model.DocumentKey;
2928
import com.google.firebase.firestore.model.mutation.MutationBatchResult;
3029
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
@@ -73,10 +72,9 @@ public ImmutableSortedSet<DocumentKey> getRemoteKeysForTarget(int targetId) {
7372
};
7473

7574
FakeConnectivityMonitor connectivityMonitor = new FakeConnectivityMonitor();
76-
SimpleQueryEngine queryEngine = new SimpleQueryEngine();
7775
Persistence persistence = MemoryPersistence.createEagerGcMemoryPersistence();
7876
persistence.start();
79-
LocalStore localStore = new LocalStore(persistence, queryEngine, User.UNAUTHENTICATED);
77+
LocalStore localStore = new LocalStore(persistence, User.UNAUTHENTICATED);
8078
RemoteStore remoteStore =
8179
new RemoteStore(callback, localStore, datastore, testQueue, connectivityMonitor);
8280

firebase-firestore/src/main/java/com/google/firebase/firestore/core/FirestoreClient.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
import com.google.firebase.firestore.local.LruGarbageCollector;
3838
import com.google.firebase.firestore.local.MemoryPersistence;
3939
import com.google.firebase.firestore.local.Persistence;
40-
import com.google.firebase.firestore.local.QueryEngine;
4140
import com.google.firebase.firestore.local.SQLitePersistence;
42-
import com.google.firebase.firestore.local.SimpleQueryEngine;
4341
import com.google.firebase.firestore.model.Document;
4442
import com.google.firebase.firestore.model.DocumentKey;
4543
import com.google.firebase.firestore.model.MaybeDocument;
@@ -268,9 +266,7 @@ private void initialize(Context context, User user, boolean usePersistence, long
268266
}
269267

270268
persistence.start();
271-
// TODO(index-free): Use IndexFreeQueryEngine/IndexedQueryEngine as appropriate.
272-
QueryEngine queryEngine = new SimpleQueryEngine();
273-
localStore = new LocalStore(persistence, queryEngine, user);
269+
localStore = new LocalStore(persistence, user);
274270
if (gc != null) {
275271
lruScheduler = gc.newScheduler(asyncQueue, localStore);
276272
lruScheduler.start();

firebase-firestore/src/main/java/com/google/firebase/firestore/core/Query.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,6 @@ public boolean isCollectionGroupQuery() {
117117
return collectionGroup != null;
118118
}
119119

120-
/**
121-
* Returns true if this query does not specify any query constraints that could remove results.
122-
*/
123-
public boolean matchesAllDocuments() {
124-
return filters.isEmpty()
125-
&& limit == NO_LIMIT
126-
&& startAt == null
127-
&& endAt == null
128-
&& (getExplicitOrderBy().isEmpty()
129-
|| (getExplicitOrderBy().size() == 1 && getFirstOrderByField().isKeyField()));
130-
}
131-
132120
/** The filters on the documents returned by the query. */
133121
public List<Filter> getFilters() {
134122
return filters;

firebase-firestore/src/main/java/com/google/firebase/firestore/core/QueryListener.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public boolean onViewSnapshot(ViewSnapshot newSnapshot) {
8686
documentChanges,
8787
newSnapshot.isFromCache(),
8888
newSnapshot.getMutatedKeys(),
89-
newSnapshot.isSynced(),
9089
newSnapshot.didSyncStateChange(),
9190
/* excludesMetadataChanges= */ true);
9291
}
@@ -172,7 +171,6 @@ private void raiseInitialEvent(ViewSnapshot snapshot) {
172171
snapshot.getDocuments(),
173172
snapshot.getMutatedKeys(),
174173
snapshot.isFromCache(),
175-
snapshot.isSynced(),
176174
snapshot.excludesMetadataChanges());
177175
raisedInitialEvent = true;
178176
listener.onEvent(snapshot, null);

firebase-firestore/src/main/java/com/google/firebase/firestore/core/SyncEngine.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,9 @@ public int listen(Query query) {
191191
private ViewSnapshot initializeViewAndComputeSnapshot(QueryData queryData) {
192192
Query query = queryData.getQuery();
193193

194+
ImmutableSortedMap<DocumentKey, Document> docs = localStore.executeQuery(query);
194195
ImmutableSortedSet<DocumentKey> remoteKeys =
195196
localStore.getRemoteDocumentKeys(queryData.getTargetId());
196-
ImmutableSortedMap<DocumentKey, Document> docs =
197-
localStore.executeQuery(query, queryData, remoteKeys);
198197

199198
View view = new View(query, remoteKeys);
200199
View.DocumentChanges viewDocChanges = view.computeDocChanges(docs);
@@ -531,8 +530,7 @@ private void emitNewSnapsAndNotifyLocalStore(
531530
// against the local store to make sure we didn't lose any good docs that had been past the
532531
// limit.
533532
ImmutableSortedMap<DocumentKey, Document> docs =
534-
localStore.executeQuery(
535-
queryView.getQuery(), /* queryData= */ null, DocumentKey.emptyKeySet());
533+
localStore.executeQuery(queryView.getQuery());
536534
viewDocChanges = view.computeDocChanges(docs, viewDocChanges);
537535
}
538536
TargetChange targetChange =

firebase-firestore/src/main/java/com/google/firebase/firestore/core/View.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ public ViewChange applyChanges(DocumentChanges docChanges, TargetChange targetCh
311311
viewChanges,
312312
fromCache,
313313
docChanges.mutatedKeys,
314-
synced,
315314
syncStatedChanged,
316315
/* excludesMetadataChanges= */ false);
317316
}

firebase-firestore/src/main/java/com/google/firebase/firestore/core/ViewSnapshot.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public enum SyncState {
3737
private final List<DocumentViewChange> changes;
3838
private final boolean isFromCache;
3939
private final ImmutableSortedSet<DocumentKey> mutatedKeys;
40-
private final boolean synced;
4140
private final boolean didSyncStateChange;
4241
private boolean excludesMetadataChanges;
4342

@@ -48,7 +47,6 @@ public ViewSnapshot(
4847
List<DocumentViewChange> changes,
4948
boolean isFromCache,
5049
ImmutableSortedSet<DocumentKey> mutatedKeys,
51-
boolean synced,
5250
boolean didSyncStateChange,
5351
boolean excludesMetadataChanges) {
5452
this.query = query;
@@ -57,7 +55,6 @@ public ViewSnapshot(
5755
this.changes = changes;
5856
this.isFromCache = isFromCache;
5957
this.mutatedKeys = mutatedKeys;
60-
this.synced = synced;
6158
this.didSyncStateChange = didSyncStateChange;
6259
this.excludesMetadataChanges = excludesMetadataChanges;
6360
}
@@ -68,7 +65,6 @@ public static ViewSnapshot fromInitialDocuments(
6865
DocumentSet documents,
6966
ImmutableSortedSet<DocumentKey> mutatedKeys,
7067
boolean fromCache,
71-
boolean synced,
7268
boolean excludesMetadataChanges) {
7369
List<DocumentViewChange> viewChanges = new ArrayList<>();
7470
for (Document doc : documents) {
@@ -81,7 +77,6 @@ public static ViewSnapshot fromInitialDocuments(
8177
viewChanges,
8278
fromCache,
8379
mutatedKeys,
84-
synced,
8580
/* didSyncStateChange= */ true,
8681
excludesMetadataChanges);
8782
}
@@ -90,10 +85,6 @@ public Query getQuery() {
9085
return query;
9186
}
9287

93-
public boolean isSynced() {
94-
return synced;
95-
}
96-
9788
public DocumentSet getDocuments() {
9889
return documents;
9990
}
@@ -140,9 +131,6 @@ public final boolean equals(Object o) {
140131
if (isFromCache != that.isFromCache) {
141132
return false;
142133
}
143-
if (synced != that.synced) {
144-
return false;
145-
}
146134
if (didSyncStateChange != that.didSyncStateChange) {
147135
return false;
148136
}
@@ -172,7 +160,6 @@ public int hashCode() {
172160
result = 31 * result + changes.hashCode();
173161
result = 31 * result + mutatedKeys.hashCode();
174162
result = 31 * result + (isFromCache ? 1 : 0);
175-
result = 31 * result + (synced ? 1 : 0);
176163
result = 31 * result + (didSyncStateChange ? 1 : 0);
177164
result = 31 * result + (excludesMetadataChanges ? 1 : 0);
178165
return result;
@@ -192,8 +179,6 @@ public String toString() {
192179
+ isFromCache
193180
+ ", mutatedKeys="
194181
+ mutatedKeys.size()
195-
+ ", synced="
196-
+ synced
197182
+ ", didSyncStateChange="
198183
+ didSyncStateChange
199184
+ ", excludesMetadataChanges="

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

Lines changed: 0 additions & 166 deletions
This file was deleted.

0 commit comments

Comments
 (0)