leveldb
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
leveldb::DB Class Referenceabstract

#include <db.h>

Inheritance diagram for leveldb::DB:
Inheritance graph
[legend]

Public Member Functions

 DB ()
 
virtual ~DB ()
 
virtual Status Put (const WriteOptions &options, const Slice &key, const Slice &value)=0
 
virtual Status Delete (const WriteOptions &options, const Slice &key)=0
 
virtual Status Write (const WriteOptions &options, WriteBatch *updates)=0
 
virtual Status Get (const ReadOptions &options, const Slice &key, std::string *value)=0
 
virtual IteratorNewIterator (const ReadOptions &options)=0
 
virtual const SnapshotGetSnapshot ()=0
 
virtual void ReleaseSnapshot (const Snapshot *snapshot)=0
 
virtual bool GetProperty (const Slice &property, std::string *value)=0
 
virtual void GetApproximateSizes (const Range *range, int n, uint64_t *sizes)=0
 
virtual void CompactRange (const Slice *begin, const Slice *end)=0
 

Static Public Member Functions

static Status Open (const Options &options, const std::string &name, DB **dbptr)
 

Private Member Functions

 DB (const DB &)
 
void operator= (const DB &)
 

Detailed Description

Definition at line 44 of file db.h.

Constructor & Destructor Documentation

§ DB() [1/2]

leveldb::DB::DB ( )
inline

Definition at line 55 of file db.h.

55 { }
Here is the call graph for this function:

§ ~DB()

leveldb::DB::~DB ( )
virtual

Definition at line 1488 of file db_impl.cc.

1488 { }

§ DB() [2/2]

leveldb::DB::DB ( const DB )
private

Member Function Documentation

§ CompactRange()

virtual void leveldb::DB::CompactRange ( const Slice begin,
const Slice end 
)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Here is the caller graph for this function:

§ Delete()

Status leveldb::DB::Delete ( const WriteOptions options,
const Slice key 
)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Definition at line 1482 of file db_impl.cc.

1482  {
1483  WriteBatch batch;
1484  batch.Delete(key);
1485  return Write(opt, &batch);
1486 }
virtual Status Write(const WriteOptions &options, WriteBatch *updates)=0
Here is the call graph for this function:
Here is the caller graph for this function:

§ Get()

virtual Status leveldb::DB::Get ( const ReadOptions options,
const Slice key,
std::string *  value 
)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Here is the caller graph for this function:

§ GetApproximateSizes()

virtual void leveldb::DB::GetApproximateSizes ( const Range range,
int  n,
uint64_t *  sizes 
)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Here is the caller graph for this function:

§ GetProperty()

virtual bool leveldb::DB::GetProperty ( const Slice property,
std::string *  value 
)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Here is the caller graph for this function:

§ GetSnapshot()

virtual const Snapshot* leveldb::DB::GetSnapshot ( )
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Here is the caller graph for this function:

§ NewIterator()

virtual Iterator* leveldb::DB::NewIterator ( const ReadOptions options)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Here is the caller graph for this function:

§ Open()

Status leveldb::DB::Open ( const Options options,
const std::string &  name,
DB **  dbptr 
)
static

Definition at line 1490 of file db_impl.cc.

1491  {
1492  *dbptr = NULL;
1493 
1494  DBImpl* impl = new DBImpl(options, dbname);
1495  impl->mutex_.Lock();
1496  VersionEdit edit;
1497  // Recover handles create_if_missing, error_if_exists
1498  bool save_manifest = false;
1499  Status s = impl->Recover(&edit, &save_manifest);
1500  if (s.ok() && impl->mem_ == NULL) {
1501  // Create new log and a corresponding memtable.
1502  uint64_t new_log_number = impl->versions_->NewFileNumber();
1503  WritableFile* lfile;
1504  s = options.env->NewWritableFile(LogFileName(dbname, new_log_number),
1505  &lfile);
1506  if (s.ok()) {
1507  edit.SetLogNumber(new_log_number);
1508  impl->logfile_ = lfile;
1509  impl->logfile_number_ = new_log_number;
1510  impl->log_ = new log::Writer(lfile);
1511  impl->mem_ = new MemTable(impl->internal_comparator_);
1512  impl->mem_->Ref();
1513  }
1514  }
1515  if (s.ok() && save_manifest) {
1516  edit.SetPrevLogNumber(0); // No older logs needed after recovery.
1517  edit.SetLogNumber(impl->logfile_number_);
1518  s = impl->versions_->LogAndApply(&edit, &impl->mutex_);
1519  }
1520  if (s.ok()) {
1521  impl->DeleteObsoleteFiles();
1522  impl->MaybeScheduleCompaction();
1523  }
1524  impl->mutex_.Unlock();
1525  if (s.ok()) {
1526  assert(impl->mem_ != NULL);
1527  *dbptr = impl;
1528  } else {
1529  delete impl;
1530  }
1531  return s;
1532 }
static char dbname[200]
Definition: c_test.c:15
std::string LogFileName(const std::string &name, uint64_t number)
Definition: filename.cc:27
Here is the call graph for this function:
Here is the caller graph for this function:

§ operator=()

void leveldb::DB::operator= ( const DB )
private

§ Put()

Status leveldb::DB::Put ( const WriteOptions options,
const Slice key,
const Slice value 
)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Definition at line 1476 of file db_impl.cc.

1476  {
1477  WriteBatch batch;
1478  batch.Put(key, value);
1479  return Write(opt, &batch);
1480 }
virtual Status Write(const WriteOptions &options, WriteBatch *updates)=0
Here is the call graph for this function:
Here is the caller graph for this function:

§ ReleaseSnapshot()

virtual void leveldb::DB::ReleaseSnapshot ( const Snapshot snapshot)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Here is the caller graph for this function:

§ Write()

virtual Status leveldb::DB::Write ( const WriteOptions options,
WriteBatch updates 
)
pure virtual

Implemented in leveldb::ModelDB, and leveldb::DBImpl.

Here is the caller graph for this function:

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