use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.
the class SQLiteLocalStoreTest method testUsesIndexes.
@Test
public void testUsesIndexes() {
FieldIndex index = fieldIndex("coll", 0, FieldIndex.INITIAL_STATE, "matches", FieldIndex.Segment.Kind.ASCENDING);
configureFieldIndexes(singletonList(index));
Query query = query("coll").filter(filter("matches", "==", true));
int targetId = allocateQuery(query);
applyRemoteEvent(addedRemoteEvent(doc("coll/a", 10, map("matches", true)), targetId));
backfillIndexes();
executeQuery(query);
assertRemoteDocumentsRead(/* byKey= */
1, /* byQuery= */
0);
assertQueryReturned("coll/a");
}
use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.
the class SQLiteLocalStoreTest method testAddsIndexes.
@Test
public void testAddsIndexes() {
FieldIndex indexA = fieldIndex("coll", 0, FieldIndex.INITIAL_STATE, "a", FieldIndex.Segment.Kind.ASCENDING);
FieldIndex indexB = fieldIndex("coll", 1, FieldIndex.INITIAL_STATE, "b", FieldIndex.Segment.Kind.DESCENDING);
FieldIndex indexC = fieldIndex("coll", 2, FieldIndex.INITIAL_STATE, "c1", FieldIndex.Segment.Kind.ASCENDING, "c2", FieldIndex.Segment.Kind.CONTAINS);
configureFieldIndexes(Arrays.asList(indexA, indexB));
Collection<FieldIndex> fieldIndexes = getFieldIndexes();
assertThat(fieldIndexes).containsExactly(indexA, indexB);
configureFieldIndexes(Arrays.asList(indexA, indexC));
fieldIndexes = getFieldIndexes();
assertThat(fieldIndexes).containsExactly(indexA, indexC);
}
use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.
the class SQLiteLocalStoreTest method testUsesPartiallyIndexedOverlaysWhenAvailable.
@Test
public void testUsesPartiallyIndexedOverlaysWhenAvailable() {
FieldIndex index = fieldIndex("coll", 0, FieldIndex.INITIAL_STATE, "matches", FieldIndex.Segment.Kind.ASCENDING);
configureFieldIndexes(singletonList(index));
writeMutation(setMutation("coll/a", map("matches", true)));
backfillIndexes();
writeMutation(setMutation("coll/b", map("matches", true)));
Query query = query("coll").filter(filter("matches", "==", true));
executeQuery(query);
assertOverlaysRead(/* byKey= */
1, /* byCollection= */
1);
assertQueryReturned("coll/a", "coll/b");
}
use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.
the class SQLiteLocalStoreTest method testUsesPartiallyIndexedRemoteDocumentsWhenAvailable.
@Test
public void testUsesPartiallyIndexedRemoteDocumentsWhenAvailable() {
FieldIndex index = fieldIndex("coll", 0, FieldIndex.INITIAL_STATE, "matches", FieldIndex.Segment.Kind.ASCENDING);
configureFieldIndexes(singletonList(index));
Query query = query("coll").filter(filter("matches", "==", true));
int targetId = allocateQuery(query);
applyRemoteEvent(addedRemoteEvent(doc("coll/a", 10, map("matches", true)), targetId));
backfillIndexes();
applyRemoteEvent(addedRemoteEvent(doc("coll/b", 20, map("matches", true)), targetId));
executeQuery(query);
assertRemoteDocumentsRead(/* byKey= */
1, /* byQuery= */
1);
assertQueryReturned("coll/a", "coll/b");
}
use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.
the class IndexBackfillerTest method addFieldIndex.
private void addFieldIndex(String collectionGroup, String fieldName, SnapshotVersion version) {
FieldIndex fieldIndex = fieldIndex(collectionGroup, FieldIndex.UNKNOWN_ID, FieldIndex.IndexState.create(0, version, DocumentKey.empty(), -1), fieldName, FieldIndex.Segment.Kind.ASCENDING);
indexManager.addFieldIndex(fieldIndex);
}
Aggregations