blob: 310a3c891220bb78dcd00bc36bddb5e3c1116361 [file] [log] [blame]
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +00001// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file. See the AUTHORS file for names of contributors.
4
5#ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
6#define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
7
jorlow@chromium.org4671a692011-03-30 18:35:40 +00008#include "leveldb/write_batch.h"
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +00009
10namespace leveldb {
11
gabor@google.com6699c7e2011-07-15 00:20:57 +000012class MemTable;
13
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000014// WriteBatchInternal provides static methods for manipulating a
15// WriteBatch that we don't want in the public WriteBatch interface.
16class WriteBatchInternal {
17 public:
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000018 // Return the number of entries in the batch.
19 static int Count(const WriteBatch* batch);
20
21 // Set the count for the number of entries in the batch.
22 static void SetCount(WriteBatch* batch, int n);
23
Chris Mumford803d6922014-09-16 14:19:52 -070024 // Return the sequence number for the start of this batch.
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000025 static SequenceNumber Sequence(const WriteBatch* batch);
26
Chris Mumford803d6922014-09-16 14:19:52 -070027 // Store the specified number as the sequence number for the start of
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000028 // this batch.
29 static void SetSequence(WriteBatch* batch, SequenceNumber seq);
30
31 static Slice Contents(const WriteBatch* batch) {
32 return Slice(batch->rep_);
33 }
34
35 static size_t ByteSize(const WriteBatch* batch) {
36 return batch->rep_.size();
37 }
38
39 static void SetContents(WriteBatch* batch, const Slice& contents);
40
41 static Status InsertInto(const WriteBatch* batch, MemTable* memtable);
Sanjay Ghemawatd79762e2012-03-08 16:23:21 -080042
43 static void Append(WriteBatch* dst, const WriteBatch* src);
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000044};
45
Hans Wennborg36a5f8e2011-10-31 17:22:06 +000046} // namespace leveldb
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000047
48
49#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_