jorlow@chromium.org | f67e15e | 2011-03-18 22:37:00 +0000 | [diff] [blame] | 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 | |
Chris Mumford | a75d435 | 2014-12-11 08:02:45 -0800 | [diff] [blame^] | 8 | #include "db/dbformat.h" |
jorlow@chromium.org | 4671a69 | 2011-03-30 18:35:40 +0000 | [diff] [blame] | 9 | #include "leveldb/write_batch.h" |
jorlow@chromium.org | f67e15e | 2011-03-18 22:37:00 +0000 | [diff] [blame] | 10 | |
| 11 | namespace leveldb { |
| 12 | |
gabor@google.com | 6699c7e | 2011-07-15 00:20:57 +0000 | [diff] [blame] | 13 | class MemTable; |
| 14 | |
jorlow@chromium.org | f67e15e | 2011-03-18 22:37:00 +0000 | [diff] [blame] | 15 | // WriteBatchInternal provides static methods for manipulating a |
| 16 | // WriteBatch that we don't want in the public WriteBatch interface. |
| 17 | class WriteBatchInternal { |
| 18 | public: |
jorlow@chromium.org | f67e15e | 2011-03-18 22:37:00 +0000 | [diff] [blame] | 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 | |
Chris Mumford | 803d692 | 2014-09-16 14:19:52 -0700 | [diff] [blame] | 25 | // Return the sequence number for the start of this batch. |
jorlow@chromium.org | f67e15e | 2011-03-18 22:37:00 +0000 | [diff] [blame] | 26 | static SequenceNumber Sequence(const WriteBatch* batch); |
| 27 | |
Chris Mumford | 803d692 | 2014-09-16 14:19:52 -0700 | [diff] [blame] | 28 | // Store the specified number as the sequence number for the start of |
jorlow@chromium.org | f67e15e | 2011-03-18 22:37:00 +0000 | [diff] [blame] | 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); |
Sanjay Ghemawat | d79762e | 2012-03-08 16:23:21 -0800 | [diff] [blame] | 43 | |
| 44 | static void Append(WriteBatch* dst, const WriteBatch* src); |
jorlow@chromium.org | f67e15e | 2011-03-18 22:37:00 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Hans Wennborg | 36a5f8e | 2011-10-31 17:22:06 +0000 | [diff] [blame] | 47 | } // namespace leveldb |
jorlow@chromium.org | f67e15e | 2011-03-18 22:37:00 +0000 | [diff] [blame] | 48 | |
| 49 | |
| 50 | #endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ |