leveldb
Public Types | Public Member Functions | Private Attributes | List of all members
leveldb::Footer Class Reference

#include <format.h>

Collaboration diagram for leveldb::Footer:
Collaboration graph
[legend]

Public Types

enum  { kEncodedLength = 2*BlockHandle::kMaxEncodedLength + 8 }
 

Public Member Functions

 Footer ()
 
const BlockHandlemetaindex_handle () const
 
void set_metaindex_handle (const BlockHandle &h)
 
const BlockHandleindex_handle () const
 
void set_index_handle (const BlockHandle &h)
 
void EncodeTo (std::string *dst) const
 
Status DecodeFrom (Slice *input)
 

Private Attributes

BlockHandle metaindex_handle_
 
BlockHandle index_handle_
 

Detailed Description

Definition at line 47 of file format.h.

Member Enumeration Documentation

§ anonymous enum

anonymous enum
Enumerator
kEncodedLength 

Definition at line 69 of file format.h.

Constructor & Destructor Documentation

§ Footer()

leveldb::Footer::Footer ( )
inline

Definition at line 49 of file format.h.

49 { }

Member Function Documentation

§ DecodeFrom()

Status leveldb::Footer::DecodeFrom ( Slice input)

Definition at line 43 of file format.cc.

43  {
44  const char* magic_ptr = input->data() + kEncodedLength - 8;
45  const uint32_t magic_lo = DecodeFixed32(magic_ptr);
46  const uint32_t magic_hi = DecodeFixed32(magic_ptr + 4);
47  const uint64_t magic = ((static_cast<uint64_t>(magic_hi) << 32) |
48  (static_cast<uint64_t>(magic_lo)));
49  if (magic != kTableMagicNumber) {
50  return Status::Corruption("not an sstable (bad magic number)");
51  }
52 
53  Status result = metaindex_handle_.DecodeFrom(input);
54  if (result.ok()) {
55  result = index_handle_.DecodeFrom(input);
56  }
57  if (result.ok()) {
58  // We skip over any leftover data (just padding for now) in "input"
59  const char* end = magic_ptr + 8;
60  *input = Slice(end, input->data() + input->size() - end);
61  }
62  return result;
63 }
static const uint64_t kTableMagicNumber
Definition: format.h:81
uint32_t DecodeFixed32(const char *ptr)
Definition: coding.h:58
BlockHandle index_handle_
Definition: format.h:75
static Status Corruption(const Slice &msg, const Slice &msg2=Slice())
Definition: status.h:38
BlockHandle metaindex_handle_
Definition: format.h:74
Status DecodeFrom(Slice *input)
Definition: format.cc:23
Here is the call graph for this function:
Here is the caller graph for this function:

§ EncodeTo()

void leveldb::Footer::EncodeTo ( std::string *  dst) const

Definition at line 32 of file format.cc.

32  {
33  const size_t original_size = dst->size();
36  dst->resize(2 * BlockHandle::kMaxEncodedLength); // Padding
37  PutFixed32(dst, static_cast<uint32_t>(kTableMagicNumber & 0xffffffffu));
38  PutFixed32(dst, static_cast<uint32_t>(kTableMagicNumber >> 32));
39  assert(dst->size() == original_size + kEncodedLength);
40  (void)original_size; // Disable unused variable warning.
41 }
void PutFixed32(std::string *dst, uint32_t value)
Definition: coding.cc:35
static const uint64_t kTableMagicNumber
Definition: format.h:81
BlockHandle index_handle_
Definition: format.h:75
void EncodeTo(std::string *dst) const
Definition: format.cc:15
BlockHandle metaindex_handle_
Definition: format.h:74
Here is the call graph for this function:
Here is the caller graph for this function:

§ index_handle()

const BlockHandle& leveldb::Footer::index_handle ( ) const
inline

Definition at line 56 of file format.h.

56  {
57  return index_handle_;
58  }
BlockHandle index_handle_
Definition: format.h:75
Here is the caller graph for this function:

§ metaindex_handle()

const BlockHandle& leveldb::Footer::metaindex_handle ( ) const
inline

Definition at line 52 of file format.h.

52 { return metaindex_handle_; }
BlockHandle metaindex_handle_
Definition: format.h:74
Here is the caller graph for this function:

§ set_index_handle()

void leveldb::Footer::set_index_handle ( const BlockHandle h)
inline

Definition at line 59 of file format.h.

59  {
60  index_handle_ = h;
61  }
BlockHandle index_handle_
Definition: format.h:75
Here is the call graph for this function:
Here is the caller graph for this function:

§ set_metaindex_handle()

void leveldb::Footer::set_metaindex_handle ( const BlockHandle h)
inline

Definition at line 53 of file format.h.

53 { metaindex_handle_ = h; }
BlockHandle metaindex_handle_
Definition: format.h:74
Here is the caller graph for this function:

Member Data Documentation

§ index_handle_

BlockHandle leveldb::Footer::index_handle_
private

Definition at line 75 of file format.h.

§ metaindex_handle_

BlockHandle leveldb::Footer::metaindex_handle_
private

Definition at line 74 of file format.h.


The documentation for this class was generated from the following files: