rippled
Public Member Functions | Private Types | Private Attributes | List of all members
ripple::NodeStore::MemoryBackend Class Reference
Inheritance diagram for ripple::NodeStore::MemoryBackend:
Inheritance graph
[legend]
Collaboration diagram for ripple::NodeStore::MemoryBackend:
Collaboration graph
[legend]

Public Member Functions

 MemoryBackend (size_t keyBytes, Section const &keyValues, Scheduler &scheduler, beast::Journal journal)
 
 ~MemoryBackend () override
 
std::string getName () override
 Get the human-readable name of this backend. More...
 
void open (bool createIfMissing) override
 Open the backend. More...
 
void close () override
 Close the backend. More...
 
Status fetch (void const *key, std::shared_ptr< NodeObject > *pObject) override
 Fetch a single object. More...
 
bool canFetchBatch () override
 Return true if batch fetches are optimized. More...
 
std::vector< std::shared_ptr< NodeObject > > fetchBatch (std::size_t n, void const *const *keys) override
 Fetch a batch synchronously. More...
 
void store (std::shared_ptr< NodeObject > const &object) override
 Store a single object. More...
 
void storeBatch (Batch const &batch) override
 Store a group of objects. More...
 
void for_each (std::function< void(std::shared_ptr< NodeObject >)> f) override
 Visit every object in the database This is usually called during import. More...
 
int getWriteLoad () override
 Estimate the number of write operations pending. More...
 
void setDeletePath () override
 Remove contents on disk upon destruction. More...
 
void verify () override
 Perform consistency checks on database. More...
 
int fdRequired () const override
 Returns the number of file descriptors the backend expects to need. More...
 
bool backed () const
 Returns true if the backend uses permanent storage. More...
 

Private Types

using Map = std::map< uint256 const, std::shared_ptr< NodeObject > >
 

Private Attributes

std::string name_
 
const beast::Journal journal_
 
MemoryDBdb_ {nullptr}
 

Detailed Description

Definition at line 78 of file MemoryFactory.cpp.

Member Typedef Documentation

◆ Map

Definition at line 81 of file MemoryFactory.cpp.

Constructor & Destructor Documentation

◆ MemoryBackend()

ripple::NodeStore::MemoryBackend::MemoryBackend ( size_t  keyBytes,
Section const &  keyValues,
Scheduler scheduler,
beast::Journal  journal 
)

Definition at line 88 of file MemoryFactory.cpp.

◆ ~MemoryBackend()

ripple::NodeStore::MemoryBackend::~MemoryBackend ( )
override

Definition at line 100 of file MemoryFactory.cpp.

Member Function Documentation

◆ getName()

std::string ripple::NodeStore::MemoryBackend::getName ( )
overridevirtual

Get the human-readable name of this backend.

This is used for diagnostic output.

Implements ripple::NodeStore::Backend.

Definition at line 106 of file MemoryFactory.cpp.

◆ open()

void ripple::NodeStore::MemoryBackend::open ( bool  createIfMissing)
overridevirtual

Open the backend.

Parameters
createIfMissingCreate the database files if necessary. This allows the caller to catch exceptions.

Implements ripple::NodeStore::Backend.

Definition at line 112 of file MemoryFactory.cpp.

◆ close()

void ripple::NodeStore::MemoryBackend::close ( )
overridevirtual

Close the backend.

This allows the caller to catch exceptions.

Implements ripple::NodeStore::Backend.

Definition at line 118 of file MemoryFactory.cpp.

◆ fetch()

Status ripple::NodeStore::MemoryBackend::fetch ( void const *  key,
std::shared_ptr< NodeObject > *  pObject 
)
overridevirtual

Fetch a single object.

If the object is not found or an error is encountered, the result will indicate the condition.

Note
This will be called concurrently.
Parameters
keyA pointer to the key data.
pObject[out] The created object if successful.
Returns
The result of the operation.

Implements ripple::NodeStore::Backend.

Definition at line 126 of file MemoryFactory.cpp.

◆ canFetchBatch()

bool ripple::NodeStore::MemoryBackend::canFetchBatch ( )
overridevirtual

Return true if batch fetches are optimized.

Implements ripple::NodeStore::Backend.

Definition at line 144 of file MemoryFactory.cpp.

◆ fetchBatch()

std::vector<std::shared_ptr<NodeObject> > ripple::NodeStore::MemoryBackend::fetchBatch ( std::size_t  n,
void const *const *  keys 
)
overridevirtual

Fetch a batch synchronously.

Implements ripple::NodeStore::Backend.

Definition at line 150 of file MemoryFactory.cpp.

◆ store()

void ripple::NodeStore::MemoryBackend::store ( std::shared_ptr< NodeObject > const &  object)
overridevirtual

Store a single object.

Depending on the implementation this may happen immediately or deferred using a scheduled task.

Note
This will be called concurrently.
Parameters
objectThe object to store.

Implements ripple::NodeStore::Backend.

Definition at line 157 of file MemoryFactory.cpp.

◆ storeBatch()

void ripple::NodeStore::MemoryBackend::storeBatch ( Batch const &  batch)
overridevirtual

Store a group of objects.

Note
This function will not be called concurrently with itself or store.

Implements ripple::NodeStore::Backend.

Definition at line 165 of file MemoryFactory.cpp.

◆ for_each()

void ripple::NodeStore::MemoryBackend::for_each ( std::function< void(std::shared_ptr< NodeObject >)>  f)
overridevirtual

Visit every object in the database This is usually called during import.

Note
This routine will not be called concurrently with itself or other methods.
See also
import

Implements ripple::NodeStore::Backend.

Definition at line 172 of file MemoryFactory.cpp.

◆ getWriteLoad()

int ripple::NodeStore::MemoryBackend::getWriteLoad ( )
overridevirtual

Estimate the number of write operations pending.

Implements ripple::NodeStore::Backend.

Definition at line 180 of file MemoryFactory.cpp.

◆ setDeletePath()

void ripple::NodeStore::MemoryBackend::setDeletePath ( )
overridevirtual

Remove contents on disk upon destruction.

Implements ripple::NodeStore::Backend.

Definition at line 186 of file MemoryFactory.cpp.

◆ verify()

void ripple::NodeStore::MemoryBackend::verify ( )
overridevirtual

Perform consistency checks on database.

Implements ripple::NodeStore::Backend.

Definition at line 191 of file MemoryFactory.cpp.

◆ fdRequired()

int ripple::NodeStore::MemoryBackend::fdRequired ( ) const
overridevirtual

Returns the number of file descriptors the backend expects to need.

Implements ripple::NodeStore::Backend.

Definition at line 196 of file MemoryFactory.cpp.

◆ backed()

bool ripple::NodeStore::Backend::backed ( ) const
inherited

Returns true if the backend uses permanent storage.

Definition at line 129 of file Backend.h.

Member Data Documentation

◆ name_

std::string ripple::NodeStore::MemoryBackend::name_
private

Definition at line 83 of file MemoryFactory.cpp.

◆ journal_

const beast::Journal ripple::NodeStore::MemoryBackend::journal_
private

Definition at line 84 of file MemoryFactory.cpp.

◆ db_

MemoryDB* ripple::NodeStore::MemoryBackend::db_ {nullptr}
private

Definition at line 85 of file MemoryFactory.cpp.