use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testOrderByKeyFilter.
@Test
public void testOrderByKeyFilter() {
indexManager.addFieldIndex(fieldIndex("coll", "count", Kind.ASCENDING));
indexManager.addFieldIndex(fieldIndex("coll", "count", Kind.DESCENDING));
addDoc("coll/val1", map("count", 1));
addDoc("coll/val2", map("count", 1));
addDoc("coll/val3", map("count", 3));
Query query = query("coll").orderBy(orderBy("count"));
verifyResults(query, "coll/val1", "coll/val2", "coll/val3");
query = query("coll").orderBy(orderBy("count", "desc"));
verifyResults(query, "coll/val3", "coll/val2", "coll/val1");
}
use of com.google.firebase.firestore.core.Query 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, /* byCollection= */
1);
assertQueryReturned("coll/a", "coll/b");
}
use of com.google.firebase.firestore.core.Query 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, /* byCollection= */
0);
assertQueryReturned("coll/a");
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteLocalStoreTest method testUsesIndexForLimitQueryWhenIndexIsUpdated.
@Test
public void testUsesIndexForLimitQueryWhenIndexIsUpdated() {
FieldIndex index = fieldIndex("coll", 0, FieldIndex.INITIAL_STATE, "count", FieldIndex.Segment.Kind.ASCENDING);
configureFieldIndexes(singletonList(index));
Query query = query("coll").orderBy(orderBy("count")).limitToFirst(2);
int targetId = allocateQuery(query);
applyRemoteEvent(addedRemoteEvent(Arrays.asList(doc("coll/a", 10, map("count", 1)), doc("coll/b", 10, map("count", 2)), doc("coll/c", 10, map("count", 3))), Collections.singletonList(targetId), Collections.emptyList()));
writeMutation(deleteMutation("coll/b"));
backfillIndexes();
executeQuery(query);
assertRemoteDocumentsRead(/* byKey= */
2, /* byCollection= */
0);
assertOverlaysRead(/* byKey= */
2, /* byCollection= */
0);
assertQueryReturned("coll/a", "coll/c");
}
use of com.google.firebase.firestore.core.Query 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");
}
Aggregations