mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 16:30:56 +00:00
Add TransactionDB::SingleDelete()
Summary: Looks like the API is simply missing. Adding it. Closes https://github.com/facebook/rocksdb/pull/2937 Differential Revision: D5919955 Pulled By: yiwu-arbug fbshipit-source-id: 6e2e9c96c29882b0bb4113d1f8efb72bffc57878
This commit is contained in:
parent
0806801dc8
commit
ec48e5c77f
|
@ -344,6 +344,10 @@ class Transaction {
|
|||
virtual Status DeleteUntracked(ColumnFamilyHandle* column_family,
|
||||
const SliceParts& key) = 0;
|
||||
virtual Status DeleteUntracked(const SliceParts& key) = 0;
|
||||
virtual Status SingleDeleteUntracked(ColumnFamilyHandle* column_family,
|
||||
const Slice& key) = 0;
|
||||
|
||||
virtual Status SingleDeleteUntracked(const Slice& key) = 0;
|
||||
|
||||
// Similar to WriteBatch::PutLogData
|
||||
virtual void PutLogData(const Slice& blob) = 0;
|
||||
|
|
|
@ -396,6 +396,28 @@ Status PessimisticTransactionDB::Delete(const WriteOptions& wopts,
|
|||
return s;
|
||||
}
|
||||
|
||||
Status PessimisticTransactionDB::SingleDelete(const WriteOptions& wopts,
|
||||
ColumnFamilyHandle* column_family,
|
||||
const Slice& key) {
|
||||
Status s;
|
||||
|
||||
Transaction* txn = BeginInternalTransaction(wopts);
|
||||
txn->DisableIndexing();
|
||||
|
||||
// Since the client didn't create a transaction, they don't care about
|
||||
// conflict checking for this write. So we just need to do
|
||||
// SingleDeleteUntracked().
|
||||
s = txn->SingleDeleteUntracked(column_family, key);
|
||||
|
||||
if (s.ok()) {
|
||||
s = txn->Commit();
|
||||
}
|
||||
|
||||
delete txn;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
Status PessimisticTransactionDB::Merge(const WriteOptions& options,
|
||||
ColumnFamilyHandle* column_family,
|
||||
const Slice& key, const Slice& value) {
|
||||
|
|
|
@ -50,6 +50,11 @@ class PessimisticTransactionDB : public TransactionDB {
|
|||
ColumnFamilyHandle* column_family,
|
||||
const Slice& key) override;
|
||||
|
||||
using StackableDB::SingleDelete;
|
||||
virtual Status SingleDelete(const WriteOptions& wopts,
|
||||
ColumnFamilyHandle* column_family,
|
||||
const Slice& key) override;
|
||||
|
||||
using StackableDB::Merge;
|
||||
virtual Status Merge(const WriteOptions& options,
|
||||
ColumnFamilyHandle* column_family, const Slice& key,
|
||||
|
|
|
@ -471,6 +471,21 @@ Status TransactionBaseImpl::DeleteUntracked(ColumnFamilyHandle* column_family,
|
|||
return s;
|
||||
}
|
||||
|
||||
Status TransactionBaseImpl::SingleDeleteUntracked(
|
||||
ColumnFamilyHandle* column_family, const Slice& key) {
|
||||
Status s = TryLock(column_family, key, false /* read_only */,
|
||||
true /* exclusive */, true /* untracked */);
|
||||
|
||||
if (s.ok()) {
|
||||
s = GetBatchForWrite()->SingleDelete(column_family, key);
|
||||
if (s.ok()) {
|
||||
num_deletes_++;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void TransactionBaseImpl::PutLogData(const Slice& blob) {
|
||||
write_batch_.PutLogData(blob);
|
||||
}
|
||||
|
|
|
@ -170,6 +170,12 @@ class TransactionBaseImpl : public Transaction {
|
|||
return DeleteUntracked(nullptr, key);
|
||||
}
|
||||
|
||||
Status SingleDeleteUntracked(ColumnFamilyHandle* column_family,
|
||||
const Slice& key) override;
|
||||
Status SingleDeleteUntracked(const Slice& key) override {
|
||||
return SingleDeleteUntracked(nullptr, key);
|
||||
}
|
||||
|
||||
void PutLogData(const Slice& blob) override;
|
||||
|
||||
WriteBatchWithIndex* GetWriteBatch() override;
|
||||
|
|
Loading…
Reference in a new issue