Search in sources :

Example 26 with FieldIndex

use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.

the class TargetTest method startAfterWithFilterQueryBound.

@Test
public void startAfterWithFilterQueryBound() {
    Target target = query("c").filter(filter("a", ">=", "a1")).filter(filter("b", "==", "b1")).orderBy(orderBy("a")).orderBy(orderBy("b")).startAt(bound(/* inclusive= */
    false, "a2", "b1")).toTarget();
    FieldIndex index = fieldIndex("c", "a", FieldIndex.Segment.Kind.ASCENDING, "b", FieldIndex.Segment.Kind.ASCENDING);
    Bound lowerBound = target.getLowerBound(index);
    verifyBound(lowerBound, false, "a2", "b1");
    Bound upperBound = target.getUpperBound(index);
    verifyBound(upperBound, false, blob(), "b1");
}
Also used : FieldIndex(com.google.firebase.firestore.model.FieldIndex) Test(org.junit.Test)

Example 27 with FieldIndex

use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.

the class TargetTest method startAtWithFilterQueryBound.

@Test
public void startAtWithFilterQueryBound() {
    // Tests that the startAt and the filter get merged to form a narrow bound
    Target target = query("c").filter(filter("a", ">=", "a1")).filter(filter("b", "==", "b1")).orderBy(orderBy("a")).orderBy(orderBy("b")).startAt(bound(/* inclusive= */
    true, "a1", "b1")).toTarget();
    FieldIndex index = fieldIndex("c", "a", FieldIndex.Segment.Kind.ASCENDING, "b", FieldIndex.Segment.Kind.ASCENDING);
    Bound lowerBound = target.getLowerBound(index);
    verifyBound(lowerBound, true, "a1", "b1");
    Bound upperBound = target.getUpperBound(index);
    verifyBound(upperBound, false, blob(), "b1");
}
Also used : FieldIndex(com.google.firebase.firestore.model.FieldIndex) Test(org.junit.Test)

Example 28 with FieldIndex

use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.

the class TargetTest method endAtQueryBound.

@Test
public void endAtQueryBound() {
    Target target = query("c").orderBy(orderBy("foo")).endAt(bound(/* inclusive= */
    true, "bar")).toTarget();
    FieldIndex index = fieldIndex("c", "foo", FieldIndex.Segment.Kind.ASCENDING);
    Bound lowerBound = target.getLowerBound(index);
    assertNull(lowerBound);
    Bound upperBound = target.getUpperBound(index);
    verifyBound(upperBound, true, "bar");
}
Also used : FieldIndex(com.google.firebase.firestore.model.FieldIndex) Test(org.junit.Test)

Example 29 with FieldIndex

use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.

the class TargetTest method startAtQueryBound.

@Test
public void startAtQueryBound() {
    Target target = query("c").orderBy(orderBy("foo")).startAt(bound(/* inclusive= */
    true, "bar")).toTarget();
    FieldIndex index = fieldIndex("c", "foo", FieldIndex.Segment.Kind.ASCENDING);
    Bound lowerBound = target.getLowerBound(index);
    verifyBound(lowerBound, true, "bar");
    Bound upperBound = target.getUpperBound(index);
    assertNull(upperBound);
}
Also used : FieldIndex(com.google.firebase.firestore.model.FieldIndex) Test(org.junit.Test)

Example 30 with FieldIndex

use of com.google.firebase.firestore.model.FieldIndex in project firebase-android-sdk by firebase.

the class TargetTest method endBeforeWithFilterQueryBound.

@Test
public void endBeforeWithFilterQueryBound() {
    Target target = query("c").filter(filter("a", "<=", "a2")).filter(filter("b", "==", "b2")).orderBy(orderBy("a")).orderBy(orderBy("b")).endAt(bound(/* inclusive= */
    false, "a1", "b1")).toTarget();
    FieldIndex index = fieldIndex("c", "a", FieldIndex.Segment.Kind.ASCENDING, "b", FieldIndex.Segment.Kind.ASCENDING);
    Bound lowerBound = target.getLowerBound(index);
    verifyBound(lowerBound, true, "", "b2");
    Bound upperBound = target.getUpperBound(index);
    verifyBound(upperBound, false, "a1", "b1");
}
Also used : FieldIndex(com.google.firebase.firestore.model.FieldIndex) Test(org.junit.Test)

Aggregations

FieldIndex (com.google.firebase.firestore.model.FieldIndex)49 Test (org.junit.Test)32 Nullable (androidx.annotation.Nullable)8 Value (com.google.firestore.v1.Value)8 Query (com.google.firebase.firestore.core.Query)6 ArrayList (java.util.ArrayList)6 DocumentKey (com.google.firebase.firestore.model.DocumentKey)3 DirectionalIndexByteEncoder (com.google.firebase.firestore.index.DirectionalIndexByteEncoder)2 IndexByteEncoder (com.google.firebase.firestore.index.IndexByteEncoder)2 IndexEntry (com.google.firebase.firestore.index.IndexEntry)2 IndexOffset (com.google.firebase.firestore.model.FieldIndex.IndexOffset)2 HashMap (java.util.HashMap)2 VisibleForTesting (androidx.annotation.VisibleForTesting)1 Timestamp (com.google.firebase.Timestamp)1 ImmutableSortedMap (com.google.firebase.database.collection.ImmutableSortedMap)1 Bound (com.google.firebase.firestore.core.Bound)1 Target (com.google.firebase.firestore.core.Target)1 Document (com.google.firebase.firestore.model.Document)1 FieldPath (com.google.firebase.firestore.model.FieldPath)1 SnapshotVersion (com.google.firebase.firestore.model.SnapshotVersion)1