diff options
author | Gil <mcg@google.com> | 2018-06-13 08:12:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-13 08:12:09 -0700 |
commit | afd897619fba10b881c4567d76793c6fdc60e93a (patch) | |
tree | 916cfceabe732ca375b82c7fe4e2cecfb265d251 /Firestore/Source | |
parent | 51fb4d0ca4fae5ad30b53c9470f9e59c4678b034 (diff) |
Minor LevelDB cleanups (#1401)
* Add leveldb_transaction* to the CMake build
* Use std::unique_ptr for leveldb::DB pointers
Diffstat (limited to 'Firestore/Source')
-rw-r--r-- | Firestore/Source/Local/FSTLevelDB.h | 2 | ||||
-rw-r--r-- | Firestore/Source/Local/FSTLevelDB.mm | 6 | ||||
-rw-r--r-- | Firestore/Source/Local/FSTLevelDBMutationQueue.h | 2 | ||||
-rw-r--r-- | Firestore/Source/Local/FSTLevelDBMutationQueue.mm | 2 | ||||
-rw-r--r-- | Firestore/Source/Local/FSTLevelDBQueryCache.h | 2 | ||||
-rw-r--r-- | Firestore/Source/Local/FSTLevelDBQueryCache.mm | 2 |
6 files changed, 11 insertions, 5 deletions
diff --git a/Firestore/Source/Local/FSTLevelDB.h b/Firestore/Source/Local/FSTLevelDB.h index 95b80a6..a56c133 100644 --- a/Firestore/Source/Local/FSTLevelDB.h +++ b/Firestore/Source/Local/FSTLevelDB.h @@ -95,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN + (NSString *)descriptionOfStatus:(leveldb::Status)status; /** The native db pointer, allocated during start. */ -@property(nonatomic, assign, readonly) std::shared_ptr<leveldb::DB> ptr; +@property(nonatomic, assign, readonly) leveldb::DB *ptr; @property(nonatomic, readonly) firebase::firestore::local::LevelDbTransaction *currentTransaction; diff --git a/Firestore/Source/Local/FSTLevelDB.mm b/Firestore/Source/Local/FSTLevelDB.mm index 9f75a3e..9dc50a2 100644 --- a/Firestore/Source/Local/FSTLevelDB.mm +++ b/Firestore/Source/Local/FSTLevelDB.mm @@ -17,6 +17,7 @@ #import "Firestore/Source/Local/FSTLevelDB.h" #include <memory> +#include <utility> #import "FIRFirestoreErrors.h" #import "Firestore/Source/Local/FSTLevelDBMigrations.h" @@ -60,6 +61,7 @@ using leveldb::WriteOptions; @implementation FSTLevelDB { std::unique_ptr<LevelDbTransaction> _transaction; + std::unique_ptr<leveldb::DB> _ptr; FSTTransactionRunner _transactionRunner; } @@ -82,6 +84,10 @@ using leveldb::WriteOptions; return self; } +- (leveldb::DB *)ptr { + return _ptr.get(); +} + - (const FSTTransactionRunner &)run { return _transactionRunner; } diff --git a/Firestore/Source/Local/FSTLevelDBMutationQueue.h b/Firestore/Source/Local/FSTLevelDBMutationQueue.h index 034738f..911fa37 100644 --- a/Firestore/Source/Local/FSTLevelDBMutationQueue.h +++ b/Firestore/Source/Local/FSTLevelDBMutationQueue.h @@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN * Returns one larger than the largest batch ID that has been stored. If there are no mutations * returns 0. Note that batch IDs are global. */ -+ (FSTBatchID)loadNextBatchIDFromDB:(std::shared_ptr<leveldb::DB>)db; ++ (FSTBatchID)loadNextBatchIDFromDB:(leveldb::DB *)db; @end diff --git a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm index 3b4687c..94ab8a5 100644 --- a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm +++ b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm @@ -132,7 +132,7 @@ using leveldb::WriteOptions; self.metadata = metadata; } -+ (FSTBatchID)loadNextBatchIDFromDB:(std::shared_ptr<DB>)db { ++ (FSTBatchID)loadNextBatchIDFromDB:(DB *)db { // TODO(gsoltis): implement Prev() and SeekToLast() on LevelDbTransaction::Iterator, then port // this to a transaction. std::unique_ptr<Iterator> it(db->NewIterator(LevelDbTransaction::DefaultReadOptions())); diff --git a/Firestore/Source/Local/FSTLevelDBQueryCache.h b/Firestore/Source/Local/FSTLevelDBQueryCache.h index 2cd6758..f756d9e 100644 --- a/Firestore/Source/Local/FSTLevelDBQueryCache.h +++ b/Firestore/Source/Local/FSTLevelDBQueryCache.h @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN * Retrieves the global singleton metadata row from the given database, if it exists. * TODO(gsoltis): remove this method once fully ported to transactions. */ -+ (nullable FSTPBTargetGlobal *)readTargetMetadataFromDB:(std::shared_ptr<leveldb::DB>)db; ++ (nullable FSTPBTargetGlobal *)readTargetMetadataFromDB:(leveldb::DB *)db; /** * Retrieves the global singleton metadata row using the given transaction, if it exists. diff --git a/Firestore/Source/Local/FSTLevelDBQueryCache.mm b/Firestore/Source/Local/FSTLevelDBQueryCache.mm index f28370a..31c2a2e 100644 --- a/Firestore/Source/Local/FSTLevelDBQueryCache.mm +++ b/Firestore/Source/Local/FSTLevelDBQueryCache.mm @@ -85,7 +85,7 @@ using firebase::firestore::model::DocumentKeySet; return proto; } -+ (nullable FSTPBTargetGlobal *)readTargetMetadataFromDB:(std::shared_ptr<DB>)db { ++ (nullable FSTPBTargetGlobal *)readTargetMetadataFromDB:(DB *)db { std::string key = [FSTLevelDBTargetGlobalKey key]; std::string value; Status status = db->Get([FSTLevelDB standardReadOptions], key, &value); |