leveldb
Public Member Functions | Private Member Functions | Private Attributes | List of all members
leveldb::TableConstructor Class Reference
Inheritance diagram for leveldb::TableConstructor:
Inheritance graph
[legend]
Collaboration diagram for leveldb::TableConstructor:
Collaboration graph
[legend]

Public Member Functions

 TableConstructor (const Comparator *cmp)
 
 ~TableConstructor ()
 
virtual Status FinishImpl (const Options &options, const KVMap &data)
 
virtual IteratorNewIterator () const
 
uint64_t ApproximateOffsetOf (const Slice &key) const
 
- Public Member Functions inherited from leveldb::Constructor
 Constructor (const Comparator *cmp)
 
virtual ~Constructor ()
 
void Add (const std::string &key, const Slice &value)
 
void Finish (const Options &options, std::vector< std::string > *keys, KVMap *kvmap)
 
virtual const KVMapdata ()
 
virtual DBdb () const
 

Private Member Functions

void Reset ()
 
 TableConstructor ()
 

Private Attributes

StringSourcesource_
 
Tabletable_
 

Detailed Description

Definition at line 221 of file table_test.cc.

Constructor & Destructor Documentation

§ TableConstructor() [1/2]

leveldb::TableConstructor::TableConstructor ( const Comparator cmp)
inline

Definition at line 223 of file table_test.cc.

224  : Constructor(cmp),
225  source_(NULL), table_(NULL) {
226  }
Constructor(const Comparator *cmp)
Definition: table_test.cc:143
StringSource * source_
Definition: table_test.cc:269

§ ~TableConstructor()

leveldb::TableConstructor::~TableConstructor ( )
inline

Definition at line 227 of file table_test.cc.

227  {
228  Reset();
229  }

§ TableConstructor() [2/2]

leveldb::TableConstructor::TableConstructor ( )
private

Member Function Documentation

§ ApproximateOffsetOf()

uint64_t leveldb::TableConstructor::ApproximateOffsetOf ( const Slice key) const
inline

Definition at line 257 of file table_test.cc.

257  {
258  return table_->ApproximateOffsetOf(key);
259  }
uint64_t ApproximateOffsetOf(const Slice &key) const
Definition: table.cc:258
Here is the caller graph for this function:

§ FinishImpl()

virtual Status leveldb::TableConstructor::FinishImpl ( const Options options,
const KVMap data 
)
inlinevirtual

Implements leveldb::Constructor.

Definition at line 230 of file table_test.cc.

230  {
231  Reset();
232  StringSink sink;
233  TableBuilder builder(options, &sink);
234 
235  for (KVMap::const_iterator it = data.begin();
236  it != data.end();
237  ++it) {
238  builder.Add(it->first, it->second);
239  ASSERT_TRUE(builder.status().ok());
240  }
241  Status s = builder.Finish();
242  ASSERT_TRUE(s.ok()) << s.ToString();
243 
244  ASSERT_EQ(sink.contents().size(), builder.FileSize());
245 
246  // Open the table
247  source_ = new StringSource(sink.contents());
248  Options table_options;
249  table_options.comparator = options.comparator;
250  return Table::Open(table_options, source_, sink.contents().size(), &table_);
251  }
static Status Open(const Options &options, RandomAccessFile *file, uint64_t file_size, Table **table)
Definition: table.cc:38
#define ASSERT_EQ(a, b)
Definition: testharness.h:107
#define ASSERT_TRUE(c)
Definition: testharness.h:105
virtual const KVMap & data()
Definition: table_test.cc:173
StringSource * source_
Definition: table_test.cc:269
Here is the call graph for this function:

§ NewIterator()

virtual Iterator* leveldb::TableConstructor::NewIterator ( ) const
inlinevirtual

Implements leveldb::Constructor.

Definition at line 253 of file table_test.cc.

253  {
254  return table_->NewIterator(ReadOptions());
255  }
Iterator * NewIterator(const ReadOptions &) const
Definition: table.cc:220

§ Reset()

void leveldb::TableConstructor::Reset ( )
inlineprivate

Definition at line 262 of file table_test.cc.

262  {
263  delete table_;
264  delete source_;
265  table_ = NULL;
266  source_ = NULL;
267  }
StringSource * source_
Definition: table_test.cc:269

Member Data Documentation

§ source_

StringSource* leveldb::TableConstructor::source_
private

Definition at line 269 of file table_test.cc.

§ table_

Table* leveldb::TableConstructor::table_
private

Definition at line 270 of file table_test.cc.


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