NCBI C++ ToolKit
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
CBDB_CacheIWriter Class Reference

Search Toolkit Book for CBDB_CacheIWriter

+ Inheritance diagram for CBDB_CacheIWriter:
+ Collaboration diagram for CBDB_CacheIWriter:

Public Types

typedef CSimpleBufferT< unsigned char, CCacheBufferResizeStrategyTBuffer

Public Member Functions

 CBDB_CacheIWriter (CBDB_Cache &bdb_cache, const char *path, unsigned blob_id_ext, const string &blob_key, int version, const string &subkey, SCache_AttrDB &attr_db, unsigned int ttl, time_t request_time, const string &owner, CBDB_Cache::TBlobLock &blob_lock)
virtual ~CBDB_CacheIWriter ()
virtual ERW_Result Write (const void *buf, size_t count, size_t *bytes_written=0)
 Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device. More...
virtual ERW_Result Flush (void)
 Flush pending data (if any) down to output device. More...
- Public Member Functions inherited from IWriter
virtual ~IWriter ()

Private Member Functions

void OpenOverflowFile ()
void x_WriteOverflow (const char *buf, streamsize count)
 CBDB_CacheIWriter (const CBDB_CacheIWriter &)
CBDB_CacheIWriteroperator= (const CBDB_CacheIWriter &)

Private Attributes

const char * m_Path
unsigned m_BlobIdExt
string m_BlobKey
int m_Version
string m_SubKey
TBuffer m_Buffer
string m_OverflowFilePath
int m_StampSubKey
CBDB_Cache::EWriteSyncMode m_WSync
unsigned int m_TTL
time_t m_RequestTime
bool m_Flushed
 FALSE until Flush() called. More...
unsigned m_BlobSize
 Number of bytes written. More...
unsigned m_Overflow
 Overflow file created. More...
unsigned m_BlobStore
unsigned m_BlobUpdate
string m_Owner
CBDB_Cache::TBlobLock m_BlobLock

Detailed Description

Definition at line 251 of file bdb_blobcache.cpp.

Member Typedef Documentation

◆ TBuffer

Definition at line 255 of file bdb_blobcache.cpp.

Constructor & Destructor Documentation

◆ CBDB_CacheIWriter() [1/2]

CBDB_CacheIWriter::CBDB_CacheIWriter ( CBDB_Cache bdb_cache,
const char *  path,
unsigned  blob_id_ext,
const string blob_key,
int  version,
const string subkey,
SCache_AttrDB attr_db,
unsigned int  ttl,
time_t  request_time,
const string owner,
CBDB_Cache::TBlobLock blob_lock 

◆ ~CBDB_CacheIWriter()

virtual CBDB_CacheIWriter::~CBDB_CacheIWriter ( )

◆ CBDB_CacheIWriter() [2/2]

CBDB_CacheIWriter::CBDB_CacheIWriter ( const CBDB_CacheIWriter )

Member Function Documentation

◆ Flush()

virtual ERW_Result CBDB_CacheIWriter::Flush ( void  )

◆ OpenOverflowFile()

void CBDB_CacheIWriter::OpenOverflowFile ( )

◆ operator=()

CBDB_CacheIWriter& CBDB_CacheIWriter::operator= ( const CBDB_CacheIWriter )

◆ Write()

virtual ERW_Result CBDB_CacheIWriter::Write ( const void *  buf,
size_t  count,
size_t *  bytes_written = 0 

Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.

Always store the number of bytes actually written, or 0 if "count" has been passed as 0 ("buf" must be ignored in this case), via the "bytes_written" pointer, if provided non-NULL. Note that the method can return non-eRW_Success in case of an I/O error along with indicating (some) data delivered to the output device (and reflected in "*bytes_written").

Apparently, may not return eRW_Success if hasn't been able to write "count" bytes as requested, and "bytes_written" was passed as NULL.
When returning "*bytes_written" as zero for a non-zero "count" requested, the return status should not indicate eRW_Success.
"*bytes_written" may never be returned greater than "count".
It is implementation-dependent whether the call blocks until the entire buffer or only some data has been written out. In general, it is advised that this call is made within a loop that checks for errors and proceeds with the writing until the required amount of data has been sent.

Implements IWriter.

Definition at line 371 of file bdb_blobcache.cpp.

References _ASSERT, SBDB_CacheStatistics::AddBlobQuotaError(), BDB_THROW, buf, CSimpleBufferT< T, ResizeStrategy >::clear(), CSimpleBufferT< T, ResizeStrategy >::data(), eRW_Error, eRW_Success, CBDB_Cache::GetMaxBlobSize(), CBDB_Cache::GetOverflowLimit(), CBDB_Cache::IsSaveStatistics(), CBDB_Cache::KillBlob(), m_BlobKey, m_BlobSize, m_Buffer, m_Cache, CBDB_Cache::m_DB_Lock, m_Flushed, m_OverflowFile, m_Owner, CBDB_Cache::m_Statistics, m_SubKey, m_Version, OpenOverflowFile(), CSimpleBufferT< T, ResizeStrategy >::resize(), CSimpleBufferT< T, ResizeStrategy >::size(), NStr::UIntToString(), and x_WriteOverflow().

◆ x_WriteOverflow()

void CBDB_CacheIWriter::x_WriteOverflow ( const char *  buf,
streamsize  count 

Member Data Documentation

◆ m_AttrDB

SCache_AttrDB& CBDB_CacheIWriter::m_AttrDB

Definition at line 588 of file bdb_blobcache.cpp.

◆ m_BlobIdExt

unsigned CBDB_CacheIWriter::m_BlobIdExt

Definition at line 584 of file bdb_blobcache.cpp.

Referenced by Flush(), and ~CBDB_CacheIWriter().

◆ m_BlobKey

string CBDB_CacheIWriter::m_BlobKey

◆ m_BlobLock

CBDB_Cache::TBlobLock CBDB_CacheIWriter::m_BlobLock

Definition at line 608 of file bdb_blobcache.cpp.

Referenced by CBDB_CacheIWriter(), and Flush().

◆ m_BlobSize

unsigned CBDB_CacheIWriter::m_BlobSize

Number of bytes written.

Definition at line 603 of file bdb_blobcache.cpp.

Referenced by Write(), and ~CBDB_CacheIWriter().

◆ m_BlobStore

unsigned CBDB_CacheIWriter::m_BlobStore

Definition at line 605 of file bdb_blobcache.cpp.

Referenced by ~CBDB_CacheIWriter().

◆ m_BlobUpdate

unsigned CBDB_CacheIWriter::m_BlobUpdate

Definition at line 606 of file bdb_blobcache.cpp.

Referenced by ~CBDB_CacheIWriter().

◆ m_Buffer

TBuffer CBDB_CacheIWriter::m_Buffer

Definition at line 590 of file bdb_blobcache.cpp.

Referenced by CBDB_CacheIWriter(), Flush(), Write(), and ~CBDB_CacheIWriter().

◆ m_Cache

CBDB_Cache& CBDB_CacheIWriter::m_Cache

◆ m_Flushed

bool CBDB_CacheIWriter::m_Flushed

FALSE until Flush() called.

Definition at line 601 of file bdb_blobcache.cpp.

Referenced by Flush(), Write(), and ~CBDB_CacheIWriter().

◆ m_Overflow

unsigned CBDB_CacheIWriter::m_Overflow

Overflow file created.

Definition at line 604 of file bdb_blobcache.cpp.

Referenced by OpenOverflowFile(), and ~CBDB_CacheIWriter().

◆ m_OverflowFile

CNcbiOfstream* CBDB_CacheIWriter::m_OverflowFile

◆ m_OverflowFilePath

string CBDB_CacheIWriter::m_OverflowFilePath

Definition at line 594 of file bdb_blobcache.cpp.

Referenced by OpenOverflowFile(), and x_WriteOverflow().

◆ m_Owner

string CBDB_CacheIWriter::m_Owner

Definition at line 607 of file bdb_blobcache.cpp.

Referenced by Flush(), Write(), and ~CBDB_CacheIWriter().

◆ m_Path

const char* CBDB_CacheIWriter::m_Path

Definition at line 583 of file bdb_blobcache.cpp.

Referenced by OpenOverflowFile().

◆ m_RequestTime

time_t CBDB_CacheIWriter::m_RequestTime

Definition at line 600 of file bdb_blobcache.cpp.

Referenced by ~CBDB_CacheIWriter().

◆ m_StampSubKey

int CBDB_CacheIWriter::m_StampSubKey

Definition at line 596 of file bdb_blobcache.cpp.

◆ m_SubKey

string CBDB_CacheIWriter::m_SubKey

◆ m_TTL

unsigned int CBDB_CacheIWriter::m_TTL

Definition at line 599 of file bdb_blobcache.cpp.

Referenced by Flush(), and ~CBDB_CacheIWriter().

◆ m_Version

int CBDB_CacheIWriter::m_Version

◆ m_WSync

CBDB_Cache::EWriteSyncMode CBDB_CacheIWriter::m_WSync

Definition at line 598 of file bdb_blobcache.cpp.

The documentation for this class was generated from the following file:
Modified on Sun Apr 21 03:43:02 2024 by rev. 669887