CatapultServer  v0.5.0.1 (Elephant)
catapult::mongo::MongoBulkWriter Class Referencefinal
Inheritance diagram for catapult::mongo::MongoBulkWriter:
Collaboration diagram for catapult::mongo::MongoBulkWriter:

Classes

struct  BulkWriteContext
 
struct  BulkWriteParams
 

Public Member Functions

template<typename TContainer >
BulkWriteResultFuture bulkInsert (const std::string &collectionName, const TContainer &entities, const CreateDocument< typename TContainer::value_type > &createDocument)
 
template<typename TContainer >
BulkWriteResultFuture bulkInsert (const std::string &collectionName, const TContainer &entities, const CreateDocuments< typename TContainer::value_type > &createDocuments)
 
template<typename TContainer >
BulkWriteResultFuture bulkUpsert (const std::string &collectionName, const TContainer &entities, const CreateDocument< typename TContainer::value_type > &createDocument, const CreateFilter< typename TContainer::value_type > &createFilter)
 
template<typename TContainer >
BulkWriteResultFuture bulkDelete (const std::string &collectionName, const TContainer &entities, const CreateFilter< typename TContainer::value_type > &createFilter)
 Deletes entities from the collection named collectionName matching the specified entity filter (createFilter). More...
 

Static Public Member Functions

static std::shared_ptr< MongoBulkWriterCreate (const mongocxx::uri &uri, const std::string &dbName, const std::shared_ptr< thread::IoThreadPool > &pPool)
 

Private Types

using AccountStates = std::unordered_set< std::shared_ptr< const state::AccountState > >
 
using BulkWriteResultFuture = thread::future< std::vector< thread::future< BulkWriteResult > >>
 
template<typename TEntity >
using AppendOperation = consumer< mongocxx::bulk_write &, const TEntity &, uint32_t >
 
template<typename TEntity >
using CreateDocument = std::function< bsoncxx::document::value(const TEntity &, uint32_t)>
 
template<typename TEntity >
using CreateDocuments = std::function< std::vector< bsoncxx::document::value >(const TEntity &, uint32_t)>
 
template<typename TEntity >
using CreateFilter = std::function< bsoncxx::document::value(const TEntity &)>
 

Private Member Functions

 MongoBulkWriter (const mongocxx::uri &uri, const std::string &dbName, const std::shared_ptr< thread::IoThreadPool > &pPool)
 
thread::future< BulkWriteResulthandleBulkOperation (std::shared_ptr< BulkWriteParams > &&pBulkWriteParams)
 
void bulkWrite (BulkWriteParams &bulkWriteParams, thread::promise< BulkWriteResult > &promise)
 
template<typename TEntity , typename TContainer >
BulkWriteResultFuture bulkWrite (const std::string &collectionName, const TContainer &entities, const AppendOperation< typename TContainer::value_type > &appendOperation)
 

Private Attributes

std::string m_dbName
 
std::shared_ptr< const thread::IoThreadPoolm_pPool
 
boost::asio::io_context & m_ioContext
 
mongocxx::pool m_connectionPool
 

Detailed Description

Class for writing bulk data to the mongo database.

Note
The bulk writer supports inserting, upserting and deleting documents.

Member Typedef Documentation

◆ AccountStates

using catapult::mongo::MongoBulkWriter::AccountStates = std::unordered_set<std::shared_ptr<const state::AccountState> >
private

◆ AppendOperation

template<typename TEntity >
using catapult::mongo::MongoBulkWriter::AppendOperation = consumer<mongocxx::bulk_write&, const TEntity&, uint32_t>
private

◆ BulkWriteResultFuture

◆ CreateDocument

template<typename TEntity >
using catapult::mongo::MongoBulkWriter::CreateDocument = std::function<bsoncxx::document::value (const TEntity&, uint32_t)>
private

◆ CreateDocuments

template<typename TEntity >
using catapult::mongo::MongoBulkWriter::CreateDocuments = std::function<std::vector<bsoncxx::document::value> (const TEntity&, uint32_t)>
private

◆ CreateFilter

template<typename TEntity >
using catapult::mongo::MongoBulkWriter::CreateFilter = std::function<bsoncxx::document::value (const TEntity&)>
private

Constructor & Destructor Documentation

◆ MongoBulkWriter()

catapult::mongo::MongoBulkWriter::MongoBulkWriter ( const mongocxx::uri &  uri,
const std::string &  dbName,
const std::shared_ptr< thread::IoThreadPool > &  pPool 
)
inlineprivate
Here is the caller graph for this function:

Member Function Documentation

◆ bulkDelete()

template<typename TContainer >
BulkWriteResultFuture catapult::mongo::MongoBulkWriter::bulkDelete ( const std::string &  collectionName,
const TContainer &  entities,
const CreateFilter< typename TContainer::value_type > &  createFilter 
)
inline

Deletes entities from the collection named collectionName matching the specified entity filter (createFilter).

Here is the caller graph for this function:

◆ bulkInsert() [1/2]

template<typename TContainer >
BulkWriteResultFuture catapult::mongo::MongoBulkWriter::bulkInsert ( const std::string &  collectionName,
const TContainer &  entities,
const CreateDocument< typename TContainer::value_type > &  createDocument 
)
inline

Inserts entities into the collection named collectionName using a one-to-one mapping of entities to documents (createDocument).

Here is the caller graph for this function:

◆ bulkInsert() [2/2]

template<typename TContainer >
BulkWriteResultFuture catapult::mongo::MongoBulkWriter::bulkInsert ( const std::string &  collectionName,
const TContainer &  entities,
const CreateDocuments< typename TContainer::value_type > &  createDocuments 
)
inline

Inserts entities into the collection named collectionName using a one-to-many mapping of entities to documents (createDocuments).

◆ bulkUpsert()

template<typename TContainer >
BulkWriteResultFuture catapult::mongo::MongoBulkWriter::bulkUpsert ( const std::string &  collectionName,
const TContainer &  entities,
const CreateDocument< typename TContainer::value_type > &  createDocument,
const CreateFilter< typename TContainer::value_type > &  createFilter 
)
inline

Upserts entities into the collection named collectionName using a one-to-one mapping of entities to documents (createDocument) matching the specified entity filter (createFilter).

Here is the caller graph for this function:

◆ bulkWrite() [1/2]

void catapult::mongo::MongoBulkWriter::bulkWrite ( BulkWriteParams bulkWriteParams,
thread::promise< BulkWriteResult > &  promise 
)
inlineprivate
Here is the call graph for this function:

◆ bulkWrite() [2/2]

template<typename TEntity , typename TContainer >
BulkWriteResultFuture catapult::mongo::MongoBulkWriter::bulkWrite ( const std::string &  collectionName,
const TContainer &  entities,
const AppendOperation< typename TContainer::value_type > &  appendOperation 
)
inlineprivate
Here is the call graph for this function:

◆ Create()

static std::shared_ptr<MongoBulkWriter> catapult::mongo::MongoBulkWriter::Create ( const mongocxx::uri &  uri,
const std::string &  dbName,
const std::shared_ptr< thread::IoThreadPool > &  pPool 
)
inlinestatic

Creates a mongo bulk writer connected to uri that will use database dbName for bulk writes.

Note
Concurrent writes are performed using the specified thread pool (pPool).
Here is the call graph for this function:

◆ handleBulkOperation()

thread::future<BulkWriteResult> catapult::mongo::MongoBulkWriter::handleBulkOperation ( std::shared_ptr< BulkWriteParams > &&  pBulkWriteParams)
inlineprivate

Member Data Documentation

◆ m_connectionPool

mongocxx::pool catapult::mongo::MongoBulkWriter::m_connectionPool
private

◆ m_dbName

std::string catapult::mongo::MongoBulkWriter::m_dbName
private

◆ m_ioContext

boost::asio::io_context& catapult::mongo::MongoBulkWriter::m_ioContext
private

◆ m_pPool

std::shared_ptr<const thread::IoThreadPool> catapult::mongo::MongoBulkWriter::m_pPool
private

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