作者: 韩晨旭 10225101440 李畅 10225102463
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

49 rader
1.5 KiB

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