use of com.google.firebase.firestore.core.Target in project firebase-android-sdk by firebase.
the class SQLiteIndexManager method getSubTargets.
private List<Target> getSubTargets(Target target) {
if (targetToDnfSubTargets.containsKey(target)) {
return targetToDnfSubTargets.get(target);
}
List<Target> subTargets = new ArrayList<>();
if (target.getFilters().isEmpty()) {
subTargets.add(target);
} else {
// There is an implicit AND operation between all the filters stored in the target.
List<Filter> dnf = LogicUtils.DnfTransform(new CompositeFilter(target.getFilters(), StructuredQuery.CompositeFilter.Operator.AND));
for (Filter term : dnf) {
subTargets.add(new Target(target.getPath(), target.getCollectionGroup(), term.getFilters(), target.getOrderBy(), target.getLimit(), target.getStartAt(), target.getEndAt()));
}
}
targetToDnfSubTargets.put(target, subTargets);
return subTargets;
}
use of com.google.firebase.firestore.core.Target in project firebase-android-sdk by firebase.
the class IndexBackfillerTest method verifyQueryResults.
private void verifyQueryResults(Query query, String... expectedKeys) {
Target target = query.toTarget();
Set<DocumentKey> actualKeys = indexManager.getDocumentsMatchingTarget(target);
if (actualKeys == null) {
assertEquals(0, expectedKeys.length);
} else {
assertThat(actualKeys).containsExactlyElementsIn(Arrays.stream(expectedKeys).map(TestUtil::key).toArray());
}
}
use of com.google.firebase.firestore.core.Target in project firebase-android-sdk by firebase.
the class LocalSerializerTest method testEncodesQuery.
@Test
public void testEncodesQuery() {
Target target = new Target(path("room"), /* collectionGroup= */
null, Collections.emptyList(), Collections.emptyList(), Target.NO_LIMIT, /* startAt= */
null, /* endAt= */
null);
BundledQuery bundledQuery = new BundledQuery(target, Query.LimitType.LIMIT_TO_FIRST);
com.google.firestore.bundle.BundledQuery encodedBundledQuery = serializer.encodeBundledQuery(bundledQuery);
BundledQuery decodedBundledQuery = serializer.decodeBundledQuery(encodedBundledQuery);
assertEquals(bundledQuery, decodedBundledQuery);
}
use of com.google.firebase.firestore.core.Target in project firebase-android-sdk by firebase.
the class LocalStoreTestCase method testHandlesSavingAndLoadingLimitToLastQueries.
@Test
public void testHandlesSavingAndLoadingLimitToLastQueries() {
Target target = query("foo").orderBy(orderBy("foo")).limitToFirst(// Use `limitToFirst` so toTarget() does not flip ordering constraint
5).toTarget();
NamedQuery namedQuery = new NamedQuery("testQuery", new BundledQuery(target, Query.LimitType.LIMIT_TO_LAST), SnapshotVersion.NONE);
saveNamedQuery(namedQuery);
assertHasNamedQuery(namedQuery);
}
use of com.google.firebase.firestore.core.Target in project firebase-android-sdk by firebase.
the class BundleCacheTestCase method testReturnsSavedCollectionGroupQueries.
@Test
public void testReturnsSavedCollectionGroupQueries() {
Target target = new Target(ResourcePath.EMPTY, /* collectionGroup= */
"collectionGroup", Collections.emptyList(), Collections.emptyList(), /* limit= */
1, /* startAt= */
null, /* endAt= */
null);
BundledQuery bundledQuery = new BundledQuery(target, Query.LimitType.LIMIT_TO_FIRST);
NamedQuery expectedQuery = new NamedQuery("query-1", bundledQuery, new SnapshotVersion(Timestamp.now()));
bundleCache.saveNamedQuery(expectedQuery);
NamedQuery actualQuery = bundleCache.getNamedQuery("query-1");
assertEquals(expectedQuery, actualQuery);
}
Aggregations