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
@ -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;
Status PessimisticTransactionDB::Merge(const WriteOptions& options,
const Slice& key, const Slice& value) {
@ -50,6 +50,11 @@ class PessimisticTransactionDB : public TransactionDB {
const Slice& key) override;
using StackableDB::SingleDelete;
virtual Status SingleDelete(const WriteOptions& wopts,
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,
Status TransactionBaseImpl::SingleDeleteUntracked(
ColumnFamilyHandle* column_family, const Slice& key) {
Status s = TryLock(column_family, key, false /* read_only */,
true /* exclusive */, true /* untracked */);
s = GetBatchForWrite()->SingleDelete(column_family, key);
num_deletes_++;
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,
Status SingleDeleteUntracked(const Slice& key) override {
return SingleDeleteUntracked(nullptr, key);
void PutLogData(const Slice& blob) override;
WriteBatchWithIndex* GetWriteBatch() override;