109 bool merger_empty =
true;
114 for (
size_t i = 0;
i < vol_exclude.size(); ++
i) {
121 size_t processed_volumes = 0;
122 while (pending_volumes != processed_volumes)
127 vol_exclude = vol_eof;
132 complete_scan =
true;
135 if (vol_exclude[
i])
continue;
141 "Input volume failed. Volume merge cannot recover.");
144 if (volume->
IsEof()) {
146 vol_exclude[
i] = vol_eof[
i] = 1;
157 if (!merger_empty && (new_key ==
m_MergeKey)) {
161 complete_scan =
false;
171 "Input volume failed. Volume merge cannot recover.");
177 vol_exclude[
i] = vol_eof[
i] = 1;
180 complete_scan =
false;
186 }
while (!complete_scan);
200 merger_empty =
false;
229 "Store device failed. Volume merge cannot recover.");
242 if (store_blob_buffer) {
259 "Store device failed. Volume merge cannot recover.");
275 blob_buffer->
resize(buf_size);
276 ::memcpy(&((*blob_buffer)[0]),
buf, buf_size);
291 size_t vol_idx = *it;
void SetMergeStore(IMergeStore *store, EOwnership own=eTakeOwnership)
Set merge store (destination)
void x_MergeVolume(IMergeVolumeWalker *volume)
void SetVolumes(const vector< IMergeVolumeWalker * > &vol_vector, EOwnership own=eTakeOwnership)
Set merge volumes.
AutoPtr< IMergeBlob > m_Merger
TBufResourcePool m_BufResourcePool
void Run()
Execute merge process (main merge loop)
vector< size_t > m_MinKeyCandidates
min-key volumes
void x_MergeCandidates()
Merge all discovered min key candidates.
EOwnership m_OwnVolumeVect
AutoPtr< IMergeStore > m_Store
unsigned m_MergeKey
key in the merger
void x_EvaluateMinKey(unsigned new_key, size_t volume_idx)
check if volume key is new minimum or equals to old minimum
void SetMergeAccumulator(IMergeBlob *merger, EOwnership own=eTakeOwnership)
Set merge accumulator component.
vector< IMergeVolumeWalker * > m_VolumeVect
void x_ResetMinKey()
Reset min. evaluation.
unsigned m_MinKey
min key value
Base Merge algorithms exception class.
Reallocable memory buffer (no memory copy overhead) Mimics vector<>, without the overhead of explicit...
void resize(size_type new_size)
BLOB merge interface, merges one or more BLOBs together.
void SetResourcePool(CMergeVolumes::TBufResourcePool &res_pool)
Set resource pool for BLOB buffer memory management.
virtual void Reset()=0
Reset merging, forget all the accumulated buffers.
virtual CMergeVolumes::TRawBuffer * GetMergeBuffer()=0
Returns destination (merged) buffer Caller MUST return the buffer to the buffer pool.
virtual void Merge(CMergeVolumes::TRawBuffer *buffer)=0
Merge request Implementation MUST return the buffer to the pool.
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
element_type * get(void) const
Get pointer.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
@ eTakeOwnership
An object can take ownership of another.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
uint32_t Uint4
4-byte (32-bit) unsigned integer
Value * Get()
Get object from the pool.
Pool::TValue * Release()
Return the pointer to the caller, not to the pool.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
virtual EStatus GetStatus() const =0
Get current interface async. status.
@ eNoMoreData
Interface reached the end (EOF)
@ eFailed
Last operation failed and interface cannot recover.
@ eNotReady
Last request did not finish yet.
virtual EStatus WaitReady() const =0
Wait until interface is ready (or operation fails) (On failure volume is free to throw an exception)
Interface to store merged BLOBs.
virtual void Close()=0
Close storage (when it ends) Method is responsible for finalization of store procedure,...
virtual IAsyncInterface * QueryIAsync()=0
Get pointer to async.
virtual CMergeVolumes::TRawBuffer * ReadBlob(Uint4 blob_id)=0
Read buffer with the specified blob_id This method is for store update, when we are merging into an e...
virtual void Store(Uint4 blob_id, CMergeVolumes::TRawBuffer *buffer)=0
Store BLOB request This request can be asyncronous caller needs to check status using IAsyncInterface...
virtual bool IsGood() const =0
Return TRUE if storage device is in good shape.
void SetResourcePool(CMergeVolumes::TBufResourcePool &res_pool)
Set resource pool for BLOB buffer memory management.
Interface to traverse volume for merge.
virtual bool IsEof() const =0
Return TRUE when volume traverse reaches the end.
virtual bool IsGood() const =0
Return TRUE if volume is in good condition (not failed)
virtual Uint4 GetUint4Key() const =0
Get access to the key as unsigned integer (if this type is supported)
virtual void Fetch()=0
Request to get next record This request can be asyncronous caller needs to check status using IAsyncI...
virtual IAsyncInterface * QueryIAsync()=0
Get pointer to async.
virtual const unsigned char * GetBufferPtr(size_t *buf_size) const =0
Get low level access to the merge BLOB buffer and buffer size (next Fetch call invalidates this point...
virtual void SetRecordMoved()=0
Signals that current record moved to merged storage (volume manager may decide to delete it later) Vo...
static IAsyncInterface::EStatus s_GetAsyncStatus(IAsyncInterface *iasync)