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 #include "leveldb/iterator.h"
11 
12 namespace leveldb {
13 
14 class Comparator;
15 
16 class Block {
17  public:
18   // Initialize the block with the specified contents.
19   // Takes ownership of data[] and will delete[] it when done.
20   Block(const char* data, size_t size);
21 
22   ~Block();
23 
size()24   size_t size() const { return size_; }
25   Iterator* NewIterator(const Comparator* comparator);
26 
27  private:
28   uint32_t NumRestarts() const;
29 
30   const char* data_;
31   size_t size_;
32   uint32_t restart_offset_;     // Offset in data_ of restart array
33 
34   // No copying allowed
35   Block(const Block&);
36   void operator=(const Block&);
37 
38   class Iter;
39 };
40 
41 }
42 
43 #endif  // STORAGE_LEVELDB_TABLE_BLOCK_H_
44