MarkLogic Connect
MarkLogic Connect Client API Collection
Public Member Functions | List of all members
mlclient::utilities::DocumentBatchWriter Class Reference

Manages a batched document upload/write operation. More...

#include <DocumentBatchWriter.hpp>

Public Member Functions

MLCLIENT_API DocumentBatchWriter (IConnection *conn)
 Constructs a DocumentBatchWriter that wraps the provided IConnection instance. More...
 
MLCLIENT_API DocumentBatchWriter (const DocumentBatchWriter &other)=delete
 The DELETED copy constructor.
 
MLCLIENT_API ~DocumentBatchWriter ()
 The destructor.
 
MLCLIENT_API void assignDocuments (DocumentSet &&set)
 Assigns a set of documents ready for upload. More...
 
MLCLIENT_API void setBatchParameters (const int parallelTasks, const int batchSize, const TransactionMode &mode)
 Sets the parameters for this batch. More...
 
MLCLIENT_API const int getParallelTasks () const
 Returns the number of parallel tasks being used. More...
 
MLCLIENT_API const int getBatchSize () const
 Returns the number of documents sent per batch. More...
 
MLCLIENT_API const TransactionMode getMode () const
 Returns the transaction mode used. More...
 
MLCLIENT_API void addBatchListener (IBatchNotifiable *notifiable)
 Adds a listener for batch events. More...
 
MLCLIENT_API void removeBatchListener (IBatchNotifiable *notifiable)
 Removes a listener for batch events. More...
 
MLCLIENT_API void send ()
 Begins the batch operation. More...
 
MLCLIENT_API void stop ()
 Cancels the batch operation. More...
 
MLCLIENT_API void wait () const
 Causes the calling thread to wait for the completion of all batches assigned to all parallel tasks. More...
 
MLCLIENT_API const bool isComplete () const
 Has this class ran to completion? More...
 
MLCLIENT_API const bool isCancelled () const
 Has this class been cancelled? More...
 
MLCLIENT_API const bool isFinished () const
 Are all asynchronous operations completed? More...
 
MLCLIENT_API const Progress getProgress () const
 Returns the current progress data for this class. More...
 

Detailed Description

Manages a batched document upload/write operation.

Since
8.0.2

Constructor & Destructor Documentation

MLCLIENT_API mlclient::utilities::DocumentBatchWriter::DocumentBatchWriter ( IConnection conn)

Constructs a DocumentBatchWriter that wraps the provided IConnection instance.

Since
8.0.2
Parameters
connThe pointer to an IConnection subclass instance. In, but not OWNS. (This class never delete's this pointer)

Member Function Documentation

MLCLIENT_API void mlclient::utilities::DocumentBatchWriter::addBatchListener ( IBatchNotifiable notifiable)

Adds a listener for batch events.

Parameters
notifiablethe IBatchNotifiable listener to add
MLCLIENT_API void mlclient::utilities::DocumentBatchWriter::assignDocuments ( DocumentSet &&  set)

Assigns a set of documents ready for upload.

Note
These can hold FileDocumentContent instances, and thus are only loaded during batch request creation (efficient)
Since
8.0.2
Parameters
setThe DocumentSet to upload to MarkLogic
MLCLIENT_API const int mlclient::utilities::DocumentBatchWriter::getBatchSize ( ) const

Returns the number of documents sent per batch.

Returns
Documents per batch
MLCLIENT_API const TransactionMode mlclient::utilities::DocumentBatchWriter::getMode ( ) const

Returns the transaction mode used.

Returns
The TransactionMode in use
MLCLIENT_API const int mlclient::utilities::DocumentBatchWriter::getParallelTasks ( ) const

Returns the number of parallel tasks being used.

Returns
The number of parallel tasks
MLCLIENT_API const Progress mlclient::utilities::DocumentBatchWriter::getProgress ( ) const

Returns the current progress data for this class.

Note
This is currently an Overall progress, not for the last X seconds.
Returns
The current Progress of the batch upload.
MLCLIENT_API const bool mlclient::utilities::DocumentBatchWriter::isCancelled ( ) const

Has this class been cancelled?

Returns
A boolean as to whether we were cancelled (true) or not
MLCLIENT_API const bool mlclient::utilities::DocumentBatchWriter::isComplete ( ) const

Has this class ran to completion?

Returns
A boolean as to whether we ran to completion (true) or not
MLCLIENT_API const bool mlclient::utilities::DocumentBatchWriter::isFinished ( ) const

Are all asynchronous operations completed?

Note
This class can still be working after stop() has been called. E.g. if a batch upload request is in progress
Returns
A boolean as to whether this class is now finished
MLCLIENT_API void mlclient::utilities::DocumentBatchWriter::removeBatchListener ( IBatchNotifiable notifiable)

Removes a listener for batch events.

Parameters
notifiablethe IBatchNotifiable listener to remove
MLCLIENT_API void mlclient::utilities::DocumentBatchWriter::send ( )

Begins the batch operation.

Note
This is where the underlying tasks are created and allocated to threads
MLCLIENT_API void mlclient::utilities::DocumentBatchWriter::setBatchParameters ( const int  parallelTasks,
const int  batchSize,
const TransactionMode mode 
)

Sets the parameters for this batch.

Note
Defaults to 5 parallel tasks, each holding 10 documents, with mode of PER_BATCH transactions.
parallelTasks performs a lot of work before the (thin) call to perform a REST request. Each Connection instance only ever executes one REST request at a time - never in parallel - so be aware of that when loading content. This restriction may be removed in future versions.
Since
8.0.2
Parameters
parallelTasksThe number of paralleltasks to use
batchSizeThe number of documents to submit in each batch (also submits their metadata)
modeThe batch mode to use
MLCLIENT_API void mlclient::utilities::DocumentBatchWriter::stop ( )

Cancels the batch operation.

Note
Some tasks may be in flight still when this is called. They still run to completion.
MLCLIENT_API void mlclient::utilities::DocumentBatchWriter::wait ( ) const

Causes the calling thread to wait for the completion of all batches assigned to all parallel tasks.

Useful for simple synchronous batch updates


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