blob: 9448ef7b21c3af42c570cf91391694bc6369972e [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
Chris Mumforda75d4352014-12-11 08:02:45 -08008#include "db/dbformat.h"
jorlow@chromium.org4671a692011-03-30 18:35:40 +00009#include "leveldb/write_batch.h"
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000010
11namespace leveldb {
12
gabor@google.com6699c7e2011-07-15 00:20:57 +000013class MemTable;
14
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000015// WriteBatchInternal provides static methods for manipulating a
16// WriteBatch that we don't want in the public WriteBatch interface.
17class WriteBatchInternal {
18 public:
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000019 // Return the number of entries in the batch.
20 static int Count(const WriteBatch* batch);
21
22 // Set the count for the number of entries in the batch.
23 static void SetCount(WriteBatch* batch, int n);
24
Chris Mumford803d6922014-09-16 14:19:52 -070025 // Return the sequence number for the start of this batch.
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000026 static SequenceNumber Sequence(const WriteBatch* batch);
27
Chris Mumford803d6922014-09-16 14:19:52 -070028 // Store the specified number as the sequence number for the start of
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000029 // this batch.
30 static void SetSequence(WriteBatch* batch, SequenceNumber seq);
31
32 static Slice Contents(const WriteBatch* batch) {
33 return Slice(batch->rep_);
34 }
35
36 static size_t ByteSize(const WriteBatch* batch) {
37 return batch->rep_.size();
38 }
39
40 static void SetContents(WriteBatch* batch, const Slice& contents);
41
42 static Status InsertInto(const WriteBatch* batch, MemTable* memtable);
Sanjay Ghemawatd79762e2012-03-08 16:23:21 -080043
44 static void Append(WriteBatch* dst, const WriteBatch* src);
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000045};
46
Hans Wennborg36a5f8e2011-10-31 17:22:06 +000047} // namespace leveldb
jorlow@chromium.orgf67e15e2011-03-18 22:37:00 +000048
49
50#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_