block.h raw
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
5 #ifndef STORAGE_LEVELDB_TABLE_BLOCK_H_
6 #define STORAGE_LEVELDB_TABLE_BLOCK_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include "leveldb/iterator.h"
12
13 namespace leveldb {
14
15 struct BlockContents;
16 class Comparator;
17
18 class Block {
19 public:
20 // Initialize the block with the specified contents.
21 explicit Block(const BlockContents& contents);
22
23 Block(const Block&) = delete;
24 Block& operator=(const Block&) = delete;
25
26 ~Block();
27
28 size_t size() const { return size_; }
29 Iterator* NewIterator(const Comparator* comparator);
30
31 private:
32 class Iter;
33
34 uint32_t NumRestarts() const;
35
36 const char* data_;
37 size_t size_;
38 uint32_t restart_offset_; // Offset in data_ of restart array
39 bool owned_; // Block owns data_[]
40 };
41
42 } // namespace leveldb
43
44 #endif // STORAGE_LEVELDB_TABLE_BLOCK_H_
45