作者: 韩晨旭 10225101440 李畅 10225102463
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 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_TABLE_BLOCK_H_
  5. #define STORAGE_LEVELDB_TABLE_BLOCK_H_
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include "leveldb/iterator.h"
  9. namespace leveldb {
  10. class Comparator;
  11. class Block {
  12. public:
  13. // Initialize the block with the specified contents.
  14. // Takes ownership of data[] and will delete[] it when done iff
  15. // "take_ownership is true.
  16. Block(const char* data, size_t size, bool take_ownership);
  17. ~Block();
  18. size_t size() const { return size_; }
  19. Iterator* NewIterator(const Comparator* comparator);
  20. private:
  21. uint32_t NumRestarts() const;
  22. const char* data_;
  23. size_t size_;
  24. uint32_t restart_offset_; // Offset in data_ of restart array
  25. bool owned_; // Block owns data_[]
  26. // No copying allowed
  27. Block(const Block&);
  28. void operator=(const Block&);
  29. class Iter;
  30. };
  31. } // namespace leveldb
  32. #endif // STORAGE_LEVELDB_TABLE_BLOCK_H_