1179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org// Use of this source code is governed by a BSD-style license that can be
3179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org// found in the LICENSE file. See the AUTHORS file for names of contributors.
4179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
5179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org#ifndef STORAGE_LEVELDB_TABLE_BLOCK_H_
6179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org#define STORAGE_LEVELDB_TABLE_BLOCK_H_
7179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
8179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org#include <stddef.h>
9179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org#include <stdint.h>
10fbd97aa4c5325eace57d24b89845b9581bac9324jorlow@chromium.org#include "leveldb/iterator.h"
11179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
12179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.orgnamespace leveldb {
13179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
1499a7585544fc162a5f8dd39a6add00776a981efesanjay@google.comstruct BlockContents;
15179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.orgclass Comparator;
16179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
17179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.orgclass Block {
18179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org public:
19179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  // Initialize the block with the specified contents.
2099a7585544fc162a5f8dd39a6add00776a981efesanjay@google.com  explicit Block(const BlockContents& contents);
21179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
22179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  ~Block();
23179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
24179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  size_t size() const { return size_; }
25179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  Iterator* NewIterator(const Comparator* comparator);
26179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
27179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org private:
28179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  uint32_t NumRestarts() const;
29179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
30179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  const char* data_;
31179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  size_t size_;
32179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  uint32_t restart_offset_;     // Offset in data_ of restart array
33e83668fa64e932a64712c99398be0acfe75367afsanjay@google.com  bool owned_;                  // Block owns data_[]
34179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
35179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  // No copying allowed
36179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  Block(const Block&);
37179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  void operator=(const Block&);
38179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
39179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org  class Iter;
40179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org};
41179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
4245b9940be332834440bd5299419f396e38085ebehans@chromium.org}  // namespace leveldb
43179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org
44179be588c25dccaa963df9c9c104fc6229435483jorlow@chromium.org#endif  // STORAGE_LEVELDB_TABLE_BLOCK_H_
45