use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromSinceReadTimeAndNanoseconds.
@Test
public void testGetAllFromSinceReadTimeAndNanoseconds() {
add(doc("b/old", 1, DOC_DATA), version(1, 1));
add(doc("b/current", 1, DOC_DATA), version(1, 2));
add(doc("b/new", 1, DOC_DATA), version(1, 3));
ResourcePath collection = path("b");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.createSuccessor(version(1, 2), -1));
assertThat(results.values()).containsExactly(doc("b/new", 1, DOC_DATA));
}
use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromCollection.
@Test
public void testGetAllFromCollection() {
addTestDocumentAtPath("a/1");
addTestDocumentAtPath("b/1");
addTestDocumentAtPath("b/2");
addTestDocumentAtPath("c/1");
ResourcePath collection = path("b");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.NONE);
assertThat(results.values()).containsExactly(doc("b/1", 42, DOC_DATA), doc("b/2", 42, DOC_DATA));
}
use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromSinceReadTimeAndDocumentKey.
@Test
public void testGetAllFromSinceReadTimeAndDocumentKey() {
addTestDocumentAtPath("b/a", /* updateTime= */
1, /* readTime= */
11);
addTestDocumentAtPath("b/b", /* updateTime= */
2, /* readTime= = */
11);
addTestDocumentAtPath("b/c", /* updateTime= */
3, /* readTime= = */
11);
addTestDocumentAtPath("b/d", /* updateTime= */
4, /* readTime= = */
12);
ResourcePath collection = path("b");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.create(version(11), key("b/b"), -1));
assertThat(results.values()).containsExactly(doc("b/c", 3, DOC_DATA), doc("b/d", 4, DOC_DATA));
}
use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class BundleSerializer method decodeBundledQuery.
private BundledQuery decodeBundledQuery(JSONObject bundledQuery) throws JSONException {
JSONObject structuredQuery = bundledQuery.getJSONObject("structuredQuery");
verifyNoSelect(structuredQuery);
ResourcePath parent = decodeName(bundledQuery.getString("parent"));
JSONArray from = structuredQuery.getJSONArray("from");
verifyCollectionSelector(from);
JSONObject collectionSelector = from.getJSONObject(0);
boolean allDescendants = collectionSelector.optBoolean("allDescendants", false);
@Nullable String collectionGroup = null;
if (allDescendants) {
collectionGroup = collectionSelector.getString("collectionId");
} else {
parent = parent.append(collectionSelector.getString("collectionId"));
}
List<Filter> filters = decodeWhere(structuredQuery.optJSONObject("where"));
List<OrderBy> orderBys = decodeOrderBy(structuredQuery.optJSONArray("orderBy"));
@Nullable Bound startAt = decodeStartAtBound(structuredQuery.optJSONObject("startAt"));
@Nullable Bound endAt = decodeEndAtBound(structuredQuery.optJSONObject("endAt"));
verifyNoOffset(structuredQuery);
int limit = decodeLimit(structuredQuery);
Query.LimitType limitType = decodeLimitType(bundledQuery);
return new BundledQuery(new Target(parent, collectionGroup, filters, orderBys, limit, startAt, endAt), limitType);
}
use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class FirestoreIndexValueWriter method writeIndexEntityRef.
private void writeIndexEntityRef(String referenceValue, DirectionalIndexByteEncoder encoder) {
writeValueTypeLabel(encoder, INDEX_TYPE_REFERENCE);
ResourcePath path = ResourcePath.fromString(referenceValue);
int numSegments = path.length();
for (int index = DOCUMENT_NAME_OFFSET; index < numSegments; ++index) {
String segment = path.getSegment(index);
writeValueTypeLabel(encoder, INDEX_TYPE_REFERENCE_SEGMENT);
writeUnlabeledIndexString(segment, encoder);
}
}
Aggregations