bf66c10b13
Summary: Introduced KeyMayExist checking during writebatch-delete and removed from Outer Delete API because it uses writebatch-delete. Added code to skip getting Table from disk if not already present in table_cache. Some renaming of variables. Introduced KeyMayExistImpl which allows checking since specified sequence number in GetImpl useful to check partially written writebatch. Changed KeyMayExist to not be pure virtual and provided a default implementation. Expanded unit-tests in db_test to check appropriately. Ran db_stress for 1 hour with ./db_stress --max_key=100000 --ops_per_thread=10000000 --delpercent=50 --filter_deletes=1 --statistics=1. Test Plan: db_stress;make check Reviewers: dhruba, haobo Reviewed By: dhruba CC: leveldb, xjin Differential Revision: https://reviews.facebook.net/D11745
58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
#ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
|
|
#define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
|
|
|
|
#include "leveldb/types.h"
|
|
#include "leveldb/write_batch.h"
|
|
#include "leveldb/db.h"
|
|
#include "leveldb/options.h"
|
|
|
|
namespace leveldb {
|
|
|
|
class MemTable;
|
|
|
|
// WriteBatchInternal provides static methods for manipulating a
|
|
// WriteBatch that we don't want in the public WriteBatch interface.
|
|
class WriteBatchInternal {
|
|
public:
|
|
// Return the number of entries in the batch.
|
|
static int Count(const WriteBatch* batch);
|
|
|
|
// Set the count for the number of entries in the batch.
|
|
static void SetCount(WriteBatch* batch, int n);
|
|
|
|
// Return the seqeunce number for the start of this batch.
|
|
static SequenceNumber Sequence(const WriteBatch* batch);
|
|
|
|
// Store the specified number as the seqeunce number for the start of
|
|
// this batch.
|
|
static void SetSequence(WriteBatch* batch, SequenceNumber seq);
|
|
|
|
static Slice Contents(const WriteBatch* batch) {
|
|
return Slice(batch->rep_);
|
|
}
|
|
|
|
static size_t ByteSize(const WriteBatch* batch) {
|
|
return batch->rep_.size();
|
|
}
|
|
|
|
static void SetContents(WriteBatch* batch, const Slice& contents);
|
|
|
|
// Inserts batch entries into memtable
|
|
// Drops deletes in batch if filter_del is set to true and
|
|
// db->KeyMayExist returns false
|
|
static Status InsertInto(const WriteBatch* batch, MemTable* memtable,
|
|
const Options* opts = nullptr, DB* db = nullptr,
|
|
const bool filter_del = false);
|
|
|
|
static void Append(WriteBatch* dst, const WriteBatch* src);
|
|
};
|
|
|
|
} // namespace leveldb
|
|
|
|
|
|
#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
|