// Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. #ifndef STORAGE_LEVELDB_TABLE_FORMAT_H_ #define STORAGE_LEVELDB_TABLE_FORMAT_H_ #include <cstdint> #include <string> #include "leveldb/slice.h" #include "leveldb/status.h" #include "leveldb/table_builder.h" namespace leveldb { class Block; class RandomAccessFile; struct ReadOptions; // BlockHandle is a pointer to the extent of a file that stores a data // block or a meta block. class BlockHandle { … }; // Footer encapsulates the fixed information stored at the tail // end of every table file. class Footer { … }; // kTableMagicNumber was picked by running // echo http://code.google.com/p/leveldb/ | sha1sum // and taking the leading 64 bits. static const uint64_t kTableMagicNumber = …; // 1-byte type + 32-bit crc static const size_t kBlockTrailerSize = …; struct BlockContents { … }; // Read the block identified by "handle" from "file". On failure // return non-OK. On success fill *result and return OK. Status ReadBlock(RandomAccessFile* file, const ReadOptions& options, const BlockHandle& handle, BlockContents* result); // Implementation details follow. Clients should ignore, inline BlockHandle::BlockHandle() : … { … } } // namespace leveldb #endif // STORAGE_LEVELDB_TABLE_FORMAT_H_