annotate src/leveldb/db/write_batch_internal.h @ 3634:98b459278ba3 draft

Import LevelDB 1.5, it will be used for the transaction database.
author Mike Hearn <hearn@google.com>
date Mon, 25 Jun 2012 11:17:22 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3634
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
2 // Use of this source code is governed by a BSD-style license that can be
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
3 // found in the LICENSE file. See the AUTHORS file for names of contributors.
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
4
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
5 #ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
6 #define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
7
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
8 #include "leveldb/write_batch.h"
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
9
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
10 namespace leveldb {
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
11
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
12 class MemTable;
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
13
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
14 // WriteBatchInternal provides static methods for manipulating a
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
15 // WriteBatch that we don't want in the public WriteBatch interface.
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
16 class WriteBatchInternal {
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
17 public:
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
18 // Return the number of entries in the batch.
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
19 static int Count(const WriteBatch* batch);
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
20
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
21 // Set the count for the number of entries in the batch.
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
22 static void SetCount(WriteBatch* batch, int n);
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
23
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
24 // Return the seqeunce number for the start of this batch.
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
25 static SequenceNumber Sequence(const WriteBatch* batch);
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
26
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
27 // Store the specified number as the seqeunce number for the start of
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
28 // this batch.
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
29 static void SetSequence(WriteBatch* batch, SequenceNumber seq);
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
30
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
31 static Slice Contents(const WriteBatch* batch) {
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
32 return Slice(batch->rep_);
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
33 }
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
34
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
35 static size_t ByteSize(const WriteBatch* batch) {
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
36 return batch->rep_.size();
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
37 }
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
38
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
39 static void SetContents(WriteBatch* batch, const Slice& contents);
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
40
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
41 static Status InsertInto(const WriteBatch* batch, MemTable* memtable);
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
42
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
43 static void Append(WriteBatch* dst, const WriteBatch* src);
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
44 };
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
45
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
46 } // namespace leveldb
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
47
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
48
98b459278ba3 Import LevelDB 1.5, it will be used for the transaction database.
Mike Hearn <hearn@google.com>
parents:
diff changeset
49 #endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_