diff options
author | jorlow@chromium.org <jorlow@chromium.org@62dab493-f737-651d-591e-8d6aee1b9529> | 2011-03-18 22:37:00 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@62dab493-f737-651d-591e-8d6aee1b9529> | 2011-03-18 22:37:00 +0000 |
commit | f67e15e50f392625b4097caf22e8be1b0fe96013 (patch) | |
tree | 1cb1764c7627f9bac27ed0e0abf27010156e5007 /db/write_batch_internal.h | |
parent | 54f1fd7eef101db1dfb2bb66a59083c45a38aa4a (diff) | |
download | leveldb-f67e15e50f392625b4097caf22e8be1b0fe96013.tar.gz |
Initial checkin.
git-svn-id: https://leveldb.googlecode.com/svn/trunk@2 62dab493-f737-651d-591e-8d6aee1b9529
Diffstat (limited to 'db/write_batch_internal.h')
-rw-r--r-- | db/write_batch_internal.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/db/write_batch_internal.h b/db/write_batch_internal.h new file mode 100644 index 0000000..df750c7 --- /dev/null +++ b/db/write_batch_internal.h @@ -0,0 +1,73 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ +#define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ + +#include "include/write_batch.h" + +namespace leveldb { + +// WriteBatchInternal provides static methods for manipulating a +// WriteBatch that we don't want in the public WriteBatch interface. +class WriteBatchInternal { + public: + static void PutLargeValueRef(WriteBatch* batch, + const Slice& key, + const LargeValueRef& large_ref); + + // Return the number of entries in the batch. + static int Count(const WriteBatch* batch); + + // Set the count for the number of entries in the batch. + static void SetCount(WriteBatch* batch, int n); + + // Return the seqeunce number for the start of this batch. + static SequenceNumber Sequence(const WriteBatch* batch); + + // Store the specified number as the seqeunce number for the start of + // this batch. + static void SetSequence(WriteBatch* batch, SequenceNumber seq); + + static Slice Contents(const WriteBatch* batch) { + return Slice(batch->rep_); + } + + static size_t ByteSize(const WriteBatch* batch) { + return batch->rep_.size(); + } + + static void SetContents(WriteBatch* batch, const Slice& contents); + + static Status InsertInto(const WriteBatch* batch, MemTable* memtable); + + // Iterate over the contents of a write batch. + class Iterator { + public: + explicit Iterator(const WriteBatch& batch); + bool Done() const { return done_; } + void Next(); + ValueType op() const { return op_; } + const Slice& key() const { return key_; } + const Slice& value() const { return value_; } + SequenceNumber sequence_number() const { return seq_; } + Status status() const { return status_; } + + private: + void GetNextEntry(); + + Slice input_; + bool done_; + ValueType op_; + Slice key_; + Slice value_; + SequenceNumber seq_; + Status status_; + }; +}; + +} + + +#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ |