Bitcoin
write_batch_internal.h
Go to the documentation of this file.
1 // 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 
8 #include "db/dbformat.h"
9 #include "leveldb/write_batch.h"
10 
11 namespace leveldb {
12 
13 class MemTable;
14 
15 // WriteBatchInternal provides static methods for manipulating a
16 // WriteBatch that we don't want in the public WriteBatch interface.
18  public:
19  // 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 
25  // Return the sequence number for the start of this batch.
26  static SequenceNumber Sequence(const WriteBatch* batch);
27 
28  // Store the specified number as the sequence number for the start of
29  // 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);
43 
44  static void Append(WriteBatch* dst, const WriteBatch* src);
45 };
46 
47 } // namespace leveldb
48 
49 
50 #endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
Definition: autocompact_test.cc:11
Definition: write_batch_internal.h:17
static size_t ByteSize(const WriteBatch *batch)
Definition: write_batch_internal.h:36
static void SetSequence(WriteBatch *batch, SequenceNumber seq)
Definition: write_batch.cc:94
static Status InsertInto(const WriteBatch *batch, MemTable *memtable)
Definition: write_batch.cc:128
uint64_t SequenceNumber
Definition: dbformat.h:63
Definition: write_batch.h:31
static void SetContents(WriteBatch *batch, const Slice &contents)
Definition: write_batch.cc:136
std::string rep_
Definition: write_batch.h:57
static void SetCount(WriteBatch *batch, int n)
Definition: write_batch.cc:86
Definition: slice.h:25
static int Count(const WriteBatch *batch)
Definition: write_batch.cc:82
static Slice Contents(const WriteBatch *batch)
Definition: write_batch_internal.h:32
Definition: memtable.h:20
Definition: status.h:21
static void Append(WriteBatch *dst, const WriteBatch *src)
Definition: write_batch.cc:141
static SequenceNumber Sequence(const WriteBatch *batch)
Definition: write_batch.cc:90