libfoedus-core
FOEDUS Core Library
foedus::storage::Storage< CONTROL_BLOCK > Class Template Reference

Represents one key-value store. More...

Detailed Description

template<typename CONTROL_BLOCK>
class foedus::storage::Storage< CONTROL_BLOCK >

Represents one key-value store.

This pure virtual class represents a set of key-value pairs. The individual storage class defines how they are stored.

Storage vs Tables/Indexes
One storage corresponds to one set of key-value pairs. A relational Table consists of one or more storages, primary storage and zero or more secondary storages (secondary indexes). However, libfoedus-core is agnostic to relational layer. It only knows about key-value store. The relation between primary and secondary storages are controlled by higher layers.
Instantiating Storage
Storage object is instantiated in two ways. To newly create a storage, the user invokes storage manager's create_xxx, which instantiates this object and calls create(). To retrieve an existing storage, bluh bluh
No virtual methods
As storages are placed in shared memory, everything is just data bits without RTTI. There is no point to use storage objects in polymorphoc way. Thus, no virtual methods.

Definition at line 116 of file storage.hpp.

#include <storage.hpp>

Inheritance diagram for foedus::storage::Storage< CONTROL_BLOCK >:
Collaboration diagram for foedus::storage::Storage< CONTROL_BLOCK >:

Public Member Functions

 Storage ()
 
 Storage (Engine *engine, CONTROL_BLOCK *control_block)
 
 Storage (Engine *engine, StorageControlBlock *control_block)
 
 Storage (Engine *engine, StorageId id)
 Shorthand for engine->get_storage_manager()->get_storage(id) More...
 
 Storage (Engine *engine, const StorageName &name)
 Shorthand for engine->get_storage_manager()->get_storage(name) More...
 
 Storage (const Storage &other)
 
Storageoperator= (const Storage &other)
 
StorageId get_id () const
 Returns the unique ID of this storage. More...
 
StorageType get_type () const
 Returns the type of this storage. More...
 
const StorageNameget_name () const
 Returns the unique name of this storage. More...
 
const Metadataget_metadata () const
 Returns the metadata of this storage. More...
 
bool exists () const
 Returns whether this storage is already created. More...
 
- Public Member Functions inherited from foedus::Attachable< CONTROL_BLOCK >
 Attachable ()
 
 Attachable (Engine *engine)
 
 Attachable (Engine *engine, CONTROL_BLOCK *control_block)
 
 Attachable (CONTROL_BLOCK *control_block)
 
virtual ~Attachable ()
 
 Attachable (const Attachable &other)
 
Attachableoperator= (const Attachable &other)
 
virtual void attach (CONTROL_BLOCK *control_block)
 Attaches to the given shared memory. More...
 
bool is_attached () const
 Returns whether the object has been already attached to some shared memory. More...
 
CONTROL_BLOCK * get_control_block () const
 
Engineget_engine () const
 
void set_engine (Engine *engine)
 

Additional Inherited Members

- Protected Attributes inherited from foedus::Attachable< CONTROL_BLOCK >
Engineengine_
 Most attachable object stores an engine pointer (local engine), so we define it here. More...
 
CONTROL_BLOCK * control_block_
 The shared data on shared memory that has been initialized in some SOC or master engine. More...
 

Constructor & Destructor Documentation

template<typename CONTROL_BLOCK>
foedus::storage::Storage< CONTROL_BLOCK >::Storage ( )
inline

Definition at line 118 of file storage.hpp.

118 : Attachable<CONTROL_BLOCK>() {}
template<typename CONTROL_BLOCK>
foedus::storage::Storage< CONTROL_BLOCK >::Storage ( Engine engine,
CONTROL_BLOCK *  control_block 
)
inline

Definition at line 119 of file storage.hpp.

120  : Attachable<CONTROL_BLOCK>(engine, control_block) {}
template<typename CONTROL_BLOCK>
foedus::storage::Storage< CONTROL_BLOCK >::Storage ( Engine engine,
StorageControlBlock control_block 
)
inline

Definition at line 121 of file storage.hpp.

122  : Attachable<CONTROL_BLOCK>(engine, reinterpret_cast<CONTROL_BLOCK*>(control_block)) {}
template<typename CONTROL_BLOCK>
foedus::storage::Storage< CONTROL_BLOCK >::Storage ( Engine engine,
StorageId  id 
)
inline

Shorthand for engine->get_storage_manager()->get_storage(id)

Definition at line 124 of file storage.hpp.

125  : Attachable<CONTROL_BLOCK>(
126  engine,
127  reinterpret_cast<CONTROL_BLOCK*>(get_storage_control_block(engine, id))) {}
StorageControlBlock * get_storage_control_block(Engine *engine, StorageId id)
Definition: storage.cpp:26
template<typename CONTROL_BLOCK>
foedus::storage::Storage< CONTROL_BLOCK >::Storage ( Engine engine,
const StorageName name 
)
inline

Shorthand for engine->get_storage_manager()->get_storage(name)

Definition at line 129 of file storage.hpp.

130  : Attachable<CONTROL_BLOCK>(
131  engine,
132  reinterpret_cast<CONTROL_BLOCK*>(get_storage_control_block(engine, name))) {}
StorageControlBlock * get_storage_control_block(Engine *engine, StorageId id)
Definition: storage.cpp:26
template<typename CONTROL_BLOCK>
foedus::storage::Storage< CONTROL_BLOCK >::Storage ( const Storage< CONTROL_BLOCK > &  other)
inline

Definition at line 134 of file storage.hpp.

135  : Attachable<CONTROL_BLOCK>(other.engine_, other.control_block_) {}

Member Function Documentation

template<typename CONTROL_BLOCK>
bool foedus::storage::Storage< CONTROL_BLOCK >::exists ( ) const
inline

Returns whether this storage is already created.

Definition at line 169 of file storage.hpp.

Referenced by foedus::storage::array::array_volatile_page_init(), foedus::storage::array::ArrayComposer::ArrayComposer(), foedus::storage::hash::HashPartitioner::design_partition(), foedus::storage::array::ArrayPartitioner::design_partition(), foedus::storage::Storage< MasstreeStorageControlBlock >::exists(), foedus::storage::hash::HashComposer::HashComposer(), and foedus::storage::masstree::MasstreeComposer::MasstreeComposer().

169  {
170  return this->control_block_ != CXX11_NULLPTR &&
171  reinterpret_cast<const StorageControlBlock*>(this->control_block_)->exists();
172  }
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
CONTROL_BLOCK * control_block_
The shared data on shared memory that has been initialized in some SOC or master engine.
Definition: attachable.hpp:111
bool exists() const
Returns whether this storage is already created.
Definition: storage.hpp:169

Here is the caller graph for this function:

template<typename CONTROL_BLOCK>
StorageId foedus::storage::Storage< CONTROL_BLOCK >::get_id ( ) const
inline

Returns the unique ID of this storage.

Definition at line 145 of file storage.hpp.

Referenced by foedus::storage::array::operator<<(), foedus::storage::masstree::operator<<(), foedus::storage::sequential::operator<<(), and foedus::storage::hash::operator<<().

145 { return get_metadata()->id_; }
const Metadata * get_metadata() const
Returns the metadata of this storage.
Definition: storage.hpp:162
StorageId id_
the unique ID of this storage.
Definition: metadata.hpp:103

Here is the caller graph for this function:

template<typename CONTROL_BLOCK>
const Metadata* foedus::storage::Storage< CONTROL_BLOCK >::get_metadata ( ) const
inline

Returns the metadata of this storage.

Returns
metadata for the individual storage instance. You can dynamic_cast it to derived metadata object.

Definition at line 162 of file storage.hpp.

Referenced by foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::hash::HashComposer::construct_root(), foedus::storage::sequential::SequentialComposer::construct_root(), foedus::storage::Storage< MasstreeStorageControlBlock >::get_id(), foedus::storage::Storage< MasstreeStorageControlBlock >::get_name(), and foedus::storage::Storage< MasstreeStorageControlBlock >::get_type().

162  {
163  return &(reinterpret_cast<const StorageControlBlock*>(this->control_block_)->meta_);
164  }
CONTROL_BLOCK * control_block_
The shared data on shared memory that has been initialized in some SOC or master engine.
Definition: attachable.hpp:111

Here is the caller graph for this function:

template<typename CONTROL_BLOCK>
StorageType foedus::storage::Storage< CONTROL_BLOCK >::get_type ( ) const
inline

Returns the type of this storage.

Definition at line 150 of file storage.hpp.

150 { return get_metadata()->type_; }
const Metadata * get_metadata() const
Returns the metadata of this storage.
Definition: storage.hpp:162
StorageType type_
type of the storage.
Definition: metadata.hpp:105
template<typename CONTROL_BLOCK>
Storage& foedus::storage::Storage< CONTROL_BLOCK >::operator= ( const Storage< CONTROL_BLOCK > &  other)
inline

Definition at line 136 of file storage.hpp.

136  {
137  this->engine_ = other.engine_;
138  this->control_block_ = other.control_block_;
139  return *this;
140  }
Engine * engine_
Most attachable object stores an engine pointer (local engine), so we define it here.
Definition: attachable.hpp:107
CONTROL_BLOCK * control_block_
The shared data on shared memory that has been initialized in some SOC or master engine.
Definition: attachable.hpp:111

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