2011-03-19 06:37:00 +08:00
|
|
|
// 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_
|
|
|
|
|
2014-12-12 00:02:45 +08:00
|
|
|
#include "db/dbformat.h"
|
2011-03-31 02:35:40 +08:00
|
|
|
#include "leveldb/write_batch.h"
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
namespace leveldb {
|
|
|
|
|
2011-07-15 08:20:57 +08:00
|
|
|
class MemTable;
|
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
// 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);
|
|
|
|
|
2014-09-17 05:19:52 +08:00
|
|
|
// Return the sequence number for the start of this batch.
|
2011-03-19 06:37:00 +08:00
|
|
|
static SequenceNumber Sequence(const WriteBatch* batch);
|
|
|
|
|
2014-09-17 05:19:52 +08:00
|
|
|
// Store the specified number as the sequence number for the start of
|
2011-03-19 06:37:00 +08:00
|
|
|
// this batch.
|
|
|
|
static void SetSequence(WriteBatch* batch, SequenceNumber seq);
|
|
|
|
|
2019-05-03 02:01:00 +08:00
|
|
|
static Slice Contents(const WriteBatch* batch) { return Slice(batch->rep_); }
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2019-05-03 02:01:00 +08:00
|
|
|
static size_t ByteSize(const WriteBatch* batch) { return batch->rep_.size(); }
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
static void SetContents(WriteBatch* batch, const Slice& contents);
|
|
|
|
|
|
|
|
static Status InsertInto(const WriteBatch* batch, MemTable* memtable);
|
2012-03-09 08:23:21 +08:00
|
|
|
|
|
|
|
static void Append(WriteBatch* dst, const WriteBatch* src);
|
2011-03-19 06:37:00 +08:00
|
|
|
};
|
|
|
|
|
2011-11-01 01:22:06 +08:00
|
|
|
} // namespace leveldb
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
|