write_batch_internal.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
  5. #define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
  6. #include "db/dbformat.h"
  7. #include "leveldb/write_batch.h"
  8. namespace leveldb {
  9. class MemTable;
  10. // WriteBatchInternal provides static methods for manipulating a
  11. // WriteBatch that we don't want in the public WriteBatch interface.
  12. class WriteBatchInternal {
  13. public:
  14. // Return the number of entries in the batch.
  15. static int Count(const WriteBatch* batch);
  16. // Set the count for the number of entries in the batch.
  17. static void SetCount(WriteBatch* batch, int n);
  18. // Return the sequence number for the start of this batch.
  19. static SequenceNumber Sequence(const WriteBatch* batch);
  20. // Store the specified number as the sequence number for the start of
  21. // this batch.
  22. static void SetSequence(WriteBatch* batch, SequenceNumber seq);
  23. static Slice Contents(const WriteBatch* batch) { return Slice(batch->rep_); }
  24. static size_t ByteSize(const WriteBatch* batch) { return batch->rep_.size(); }
  25. static void SetContents(WriteBatch* batch, const Slice& contents);
  26. static Status InsertInto(const WriteBatch* batch, MemTable* memtable);
  27. static void Append(WriteBatch* dst, const WriteBatch* src);
  28. };
  29. } // namespace leveldb
  30. #endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_