diff options
author | zxu <zxu@google.com> | 2018-05-01 13:37:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 13:37:53 -0400 |
commit | 4e1ffe464900a45915a3a0a4f2a331b5824c24df (patch) | |
tree | c3586f3d840f4b21a4e4643a46fe94f2443d3959 /Firestore/Source/Core | |
parent | 51be76700c3b71a0924e8eaf7bac4b02e0130e62 (diff) |
Port `SnapshotVersion` for the rest Firestore modulo (#1185)
* remove conversions in `Local` and `Remote`
* replace `FSTSnapshotVersion` in `Model`
* replace `FSTSnapshotVersion` in the rest
* let test check equal with C++ equal
* fix newly added code
* address changes
Diffstat (limited to 'Firestore/Source/Core')
-rw-r--r-- | Firestore/Source/Core/FSTSyncEngine.mm | 3 | ||||
-rw-r--r-- | Firestore/Source/Core/FSTTransaction.mm | 15 |
2 files changed, 9 insertions, 9 deletions
diff --git a/Firestore/Source/Core/FSTSyncEngine.mm b/Firestore/Source/Core/FSTSyncEngine.mm index 775f865..8ec98e8 100644 --- a/Firestore/Source/Core/FSTSyncEngine.mm +++ b/Firestore/Source/Core/FSTSyncEngine.mm @@ -24,7 +24,6 @@ #import "FIRFirestoreErrors.h" #import "Firestore/Source/Core/FSTQuery.h" -#import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Core/FSTTransaction.h" #import "Firestore/Source/Core/FSTView.h" #import "Firestore/Source/Core/FSTViewSnapshot.h" @@ -347,7 +346,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1; NSMutableDictionary<NSNumber *, FSTTargetChange *> *targetChanges = [NSMutableDictionary dictionary]; FSTDeletedDocument *doc = - [FSTDeletedDocument documentWithKey:limboKey version:[FSTSnapshotVersion noVersion]]; + [FSTDeletedDocument documentWithKey:limboKey version:SnapshotVersion::None()]; FSTDocumentKeySet *limboDocuments = [[FSTDocumentKeySet keySet] setByAddingObject:doc.key]; FSTRemoteEvent *event = [[FSTRemoteEvent alloc] initWithSnapshotVersion:SnapshotVersion::None() targetChanges:targetChanges diff --git a/Firestore/Source/Core/FSTTransaction.mm b/Firestore/Source/Core/FSTTransaction.mm index 4aabd5a..57dcc48 100644 --- a/Firestore/Source/Core/FSTTransaction.mm +++ b/Firestore/Source/Core/FSTTransaction.mm @@ -23,7 +23,6 @@ #import "FIRFirestoreErrors.h" #import "Firestore/Source/API/FSTUserDataConverter.h" -#import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Model/FSTDocument.h" #import "Firestore/Source/Model/FSTDocumentKeySet.h" #import "Firestore/Source/Model/FSTMutation.h" @@ -33,9 +32,11 @@ #include "Firestore/core/src/firebase/firestore/model/document_key.h" #include "Firestore/core/src/firebase/firestore/model/precondition.h" +#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h" using firebase::firestore::model::DocumentKey; using firebase::firestore::model::Precondition; +using firebase::firestore::model::SnapshotVersion; NS_ASSUME_NONNULL_BEGIN @@ -53,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN @end @implementation FSTTransaction { - std::map<DocumentKey, FSTSnapshotVersion *> _readVersions; + std::map<DocumentKey, SnapshotVersion> _readVersions; } + (instancetype)transactionWithDatastore:(FSTDatastore *)datastore { @@ -79,11 +80,11 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)recordVersionForDocument:(FSTMaybeDocument *)doc error:(NSError **)error { FSTAssert(error != nil, @"nil error parameter"); *error = nil; - FSTSnapshotVersion *docVersion = doc.version; + SnapshotVersion docVersion = doc.version; if ([doc isKindOfClass:[FSTDeletedDocument class]]) { // For deleted docs, we must record an explicit no version to build the right precondition // when writing. - docVersion = [FSTSnapshotVersion noVersion]; + docVersion = SnapshotVersion::None(); } if (_readVersions.find(doc.key) == _readVersions.end()) { _readVersions[doc.key] = docVersion; @@ -159,8 +160,8 @@ NS_ASSUME_NONNULL_BEGIN return Precondition::Exists(true); } - FSTSnapshotVersion *version = iter->second; - if ([version isEqual:[FSTSnapshotVersion noVersion]]) { + const SnapshotVersion &version = iter->second; + if (version == SnapshotVersion::None()) { // The document was read, but doesn't exist. // Return an error because the precondition is impossible if (error) { @@ -200,7 +201,7 @@ NS_ASSUME_NONNULL_BEGIN precondition:[self preconditionForDocumentKey:key]] ]]; // Since the delete will be applied before all following writes, we need to ensure that the // precondition for the next write will be exists without timestamp. - _readVersions[key] = [FSTSnapshotVersion noVersion]; + _readVersions[key] = SnapshotVersion::None(); } - (void)commitWithCompletion:(FSTVoidErrorBlock)completion { |