write_batch_internal.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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) {
  24. return Slice(batch->rep_);
  25. }
  26. static size_t ByteSize(const WriteBatch* batch) {
  27. return batch->rep_.size();
  28. }
  29. static void SetContents(WriteBatch* batch, const Slice& contents);
  30. static Status InsertInto(const WriteBatch* batch, MemTable* memtable);
  31. static void Append(WriteBatch* dst, const WriteBatch* src);
  32. };
  33. } // namespace leveldb
  34. #endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_