aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Local
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2018-03-05 11:30:59 -0500
committerGravatar GitHub <noreply@github.com>2018-03-05 11:30:59 -0500
commit1c40e7aada6b32bbc621f06fb5f380149606a58d (patch)
tree6dee81f74f8a33d1beae915d9227caf28b8e2598 /Firestore/Source/Local
parent9b5b4d876eb77e65b3246614855088be101eebf3 (diff)
add converters and port paths to FSTQuery (#869)
* add converters and fix FSTQuery.{h,m} only * address changes * a change forget to address * add a dummy function to make inline-only-library buildable
Diffstat (limited to 'Firestore/Source/Local')
-rw-r--r--Firestore/Source/Local/FSTLevelDBMutationQueue.mm2
-rw-r--r--Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm5
-rw-r--r--Firestore/Source/Local/FSTLocalDocumentsView.mm6
-rw-r--r--Firestore/Source/Local/FSTMemoryMutationQueue.mm4
-rw-r--r--Firestore/Source/Local/FSTMemoryRemoteDocumentCache.mm5
5 files changed, 13 insertions, 9 deletions
diff --git a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm
index 248ef9a..9041ddc 100644
--- a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm
+++ b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm
@@ -426,7 +426,7 @@ static ReadOptions StandardReadOptions() {
FSTAssert(![query isDocumentQuery], @"Document queries shouldn't go down this path");
NSString *userID = self.userID;
- FSTResourcePath *queryPath = query.path;
+ FSTResourcePath *queryPath = [FSTResourcePath resourcePathWithCPPResourcePath:query.path];
int immediateChildrenPathLength = queryPath.length + 1;
// TODO(mcg): Actually implement a single-collection query
diff --git a/Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm b/Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm
index b842cb5..17ecb53 100644
--- a/Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm
+++ b/Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm
@@ -104,7 +104,8 @@ static ReadOptions StandardReadOptions() {
// Documents are ordered by key, so we can use a prefix scan to narrow down
// the documents we need to match the query against.
- std::string startKey = [FSTLevelDBRemoteDocumentKey keyPrefixWithResourcePath:query.path];
+ std::string startKey = [FSTLevelDBRemoteDocumentKey
+ keyPrefixWithResourcePath:[FSTResourcePath resourcePathWithCPPResourcePath:query.path]];
std::unique_ptr<Iterator> it(_db->NewIterator(StandardReadOptions()));
it->Seek(startKey);
@@ -112,7 +113,7 @@ static ReadOptions StandardReadOptions() {
for (; it->Valid() && [currentKey decodeKey:it->key()]; it->Next()) {
FSTMaybeDocument *maybeDoc =
[self decodedMaybeDocument:it->value() withKey:currentKey.documentKey];
- if (![query.path isPrefixOfPath:maybeDoc.key.path]) {
+ if (!query.path.IsPrefixOf([maybeDoc.key.path toCPPResourcePath])) {
break;
} else if ([maybeDoc isKindOfClass:[FSTDocument class]]) {
results = [results dictionaryBySettingObject:(FSTDocument *)maybeDoc forKey:maybeDoc.key];
diff --git a/Firestore/Source/Local/FSTLocalDocumentsView.mm b/Firestore/Source/Local/FSTLocalDocumentsView.mm
index 0e88958..4bcdf47 100644
--- a/Firestore/Source/Local/FSTLocalDocumentsView.mm
+++ b/Firestore/Source/Local/FSTLocalDocumentsView.mm
@@ -25,6 +25,7 @@
#import "Firestore/Source/Model/FSTDocumentKey.h"
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
+#import "Firestore/Source/Model/FSTPath.h"
#import "Firestore/Source/Util/FSTAssert.h"
NS_ASSUME_NONNULL_BEGIN
@@ -74,8 +75,9 @@ NS_ASSUME_NONNULL_BEGIN
}
- (FSTDocumentDictionary *)documentsMatchingQuery:(FSTQuery *)query {
- if ([FSTDocumentKey isDocumentKey:query.path]) {
- return [self documentsMatchingDocumentQuery:query.path];
+ if ([FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:query.path]]) {
+ return [self documentsMatchingDocumentQuery:[FSTResourcePath
+ resourcePathWithCPPResourcePath:query.path]];
} else {
return [self documentsMatchingCollectionQuery:query];
}
diff --git a/Firestore/Source/Local/FSTMemoryMutationQueue.mm b/Firestore/Source/Local/FSTMemoryMutationQueue.mm
index 2a6a1cc..bf4f600 100644
--- a/Firestore/Source/Local/FSTMemoryMutationQueue.mm
+++ b/Firestore/Source/Local/FSTMemoryMutationQueue.mm
@@ -248,13 +248,13 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
- (NSArray<FSTMutationBatch *> *)allMutationBatchesAffectingQuery:(FSTQuery *)query {
// Use the query path as a prefix for testing if a document matches the query.
- FSTResourcePath *prefix = query.path;
+ FSTResourcePath *prefix = [FSTResourcePath resourcePathWithCPPResourcePath:query.path];
int immediateChildrenPathLength = prefix.length + 1;
// Construct a document reference for actually scanning the index. Unlike the prefix, the document
// key in this reference must have an even number of segments. The empty segment can be used as
// a suffix of the query path because it precedes all other segments in an ordered traversal.
- FSTResourcePath *startPath = query.path;
+ FSTResourcePath *startPath = [FSTResourcePath resourcePathWithCPPResourcePath:query.path];
if (![FSTDocumentKey isDocumentKey:startPath]) {
startPath = [startPath pathByAppendingSegment:@""];
}
diff --git a/Firestore/Source/Local/FSTMemoryRemoteDocumentCache.mm b/Firestore/Source/Local/FSTMemoryRemoteDocumentCache.mm
index 9bbc047..7d5e1e2 100644
--- a/Firestore/Source/Local/FSTMemoryRemoteDocumentCache.mm
+++ b/Firestore/Source/Local/FSTMemoryRemoteDocumentCache.mm
@@ -60,10 +60,11 @@ NS_ASSUME_NONNULL_BEGIN
// Documents are ordered by key, so we can use a prefix scan to narrow down the documents
// we need to match the query against.
- FSTDocumentKey *prefix = [FSTDocumentKey keyWithPath:[query.path pathByAppendingSegment:@""]];
+ FSTDocumentKey *prefix = [FSTDocumentKey
+ keyWithPath:[FSTResourcePath resourcePathWithCPPResourcePath:query.path.Append("")]];
NSEnumerator<FSTDocumentKey *> *enumerator = [self.docs keyEnumeratorFrom:prefix];
for (FSTDocumentKey *key in enumerator) {
- if (![query.path isPrefixOfPath:key.path]) {
+ if (!query.path.IsPrefixOf([key.path toCPPResourcePath])) {
break;
}
FSTMaybeDocument *maybeDoc = self.docs[key];