You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -50,7 +50,7 @@ DbFileOp::~DbFileOp()
|
||||
{}
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* flush the cache
|
||||
* PARAMETERS:
|
||||
* none
|
||||
@ -61,11 +61,12 @@ int DbFileOp::flushCache()
|
||||
{
|
||||
BlockBuffer* curBuf;
|
||||
|
||||
if( !Cache::getUseCache() )
|
||||
if ( !Cache::getUseCache() )
|
||||
return NO_ERROR;
|
||||
|
||||
for( CacheMapIt it = Cache::m_writeList->begin();
|
||||
it != Cache::m_writeList->end(); it++ ) {
|
||||
for ( CacheMapIt it = Cache::m_writeList->begin();
|
||||
it != Cache::m_writeList->end(); it++ )
|
||||
{
|
||||
curBuf = it->second;
|
||||
RETURN_ON_ERROR( writeDBFile( (*curBuf).cb.file.pFile,
|
||||
(*curBuf).block.data,
|
||||
@ -78,7 +79,7 @@ int DbFileOp::flushCache()
|
||||
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* get an entry within a sub block
|
||||
* NOTE: the difference with readSubBlockEntry is that
|
||||
* getSubBlockEntry only works for buffer while
|
||||
@ -93,17 +94,17 @@ int DbFileOp::flushCache()
|
||||
* none
|
||||
***********************************************************/
|
||||
void DbFileOp::getSubBlockEntry( unsigned char* blockBuf,
|
||||
const int sbid, const int entryNo,
|
||||
const int sbid, const int entryNo,
|
||||
const int width, void* pStruct )
|
||||
{
|
||||
unsigned char* pBlock;
|
||||
|
||||
pBlock = blockBuf + BYTE_PER_SUBBLOCK * sbid + entryNo *MAX_COLUMN_BOUNDARY;
|
||||
pBlock = blockBuf + BYTE_PER_SUBBLOCK * sbid + entryNo * MAX_COLUMN_BOUNDARY;
|
||||
memcpy( pStruct, pBlock, width );
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* Read a block from a file at specified location
|
||||
* PARAMETERS:
|
||||
* pFile - file handle
|
||||
@ -120,11 +121,13 @@ int DbFileOp::readDBFile( IDBDataFile* pFile,
|
||||
{
|
||||
long long fboOffset = 0;
|
||||
|
||||
if( !isFbo ) {
|
||||
if ( !isFbo )
|
||||
{
|
||||
RETURN_ON_ERROR( setFileOffsetBlock( pFile, lbid ) );
|
||||
}
|
||||
else {
|
||||
fboOffset = (lbid)*(long)BYTE_PER_BLOCK;
|
||||
else
|
||||
{
|
||||
fboOffset = (lbid) * (long)BYTE_PER_BLOCK;
|
||||
RETURN_ON_ERROR( setFileOffset( pFile, fboOffset ) );
|
||||
}
|
||||
|
||||
@ -136,31 +139,33 @@ int DbFileOp::readDBFile( IDBDataFile* pFile,
|
||||
const uint64_t lbid,
|
||||
const bool isFbo )
|
||||
{
|
||||
block->dirty = false;
|
||||
block->no = lbid;
|
||||
block->dirty = false;
|
||||
block->no = lbid;
|
||||
|
||||
Stats::incIoBlockRead();
|
||||
Stats::incIoBlockRead();
|
||||
|
||||
return readDBFile( pFile, block->data, lbid, isFbo );
|
||||
return readDBFile( pFile, block->data, lbid, isFbo );
|
||||
}
|
||||
|
||||
int DbFileOp::readDBFile( CommBlock& cb,
|
||||
unsigned char* readBuf,
|
||||
const uint64_t lbid )
|
||||
{
|
||||
const uint64_t lbid )
|
||||
{
|
||||
CacheKey key;
|
||||
|
||||
if( Cache::getUseCache() )
|
||||
if ( Cache::getUseCache() )
|
||||
{
|
||||
if( Cache::cacheKeyExist( cb.file.oid, lbid ) ) {
|
||||
if ( Cache::cacheKeyExist( cb.file.oid, lbid ) )
|
||||
{
|
||||
key = Cache::getCacheKey( cb.file.oid, lbid );
|
||||
RETURN_ON_ERROR( Cache::loadCacheBlock( key, readBuf ) );
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_ON_ERROR( readDBFile( cb.file.pFile, readBuf, lbid ) );
|
||||
if( Cache::getUseCache() )
|
||||
RETURN_ON_ERROR( readDBFile( cb.file.pFile, readBuf, lbid ) );
|
||||
|
||||
if ( Cache::getUseCache() )
|
||||
{
|
||||
int fbo = lbid;
|
||||
|
||||
@ -168,21 +173,26 @@ int DbFileOp::readDBFile( CommBlock& cb,
|
||||
uint32_t partition;
|
||||
uint16_t segment;
|
||||
RETURN_ON_ERROR( BRMWrapper::getInstance()->getFboOffset(
|
||||
lbid, dbRoot, partition, segment, fbo ) );
|
||||
|
||||
if( Cache::getListSize( FREE_LIST ) == 0 ) {
|
||||
if ( isDebug( DEBUG_1 ) ) {
|
||||
lbid, dbRoot, partition, segment, fbo ) );
|
||||
|
||||
if ( Cache::getListSize( FREE_LIST ) == 0 )
|
||||
{
|
||||
if ( isDebug( DEBUG_1 ) )
|
||||
{
|
||||
printf( "\nBefore flushing cache " );
|
||||
Cache::printCacheList();
|
||||
}
|
||||
|
||||
// flush cache to give up more space
|
||||
RETURN_ON_ERROR( flushCache() );
|
||||
if ( isDebug( DEBUG_1 ) ) {
|
||||
|
||||
if ( isDebug( DEBUG_1 ) )
|
||||
{
|
||||
printf( "\nAfter flushing cache " );
|
||||
Cache::printCacheList();
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_ON_ERROR( Cache::insertLRUList( cb, lbid, fbo, readBuf ) );
|
||||
}
|
||||
|
||||
@ -208,8 +218,8 @@ int DbFileOp::readDBFile( CommBlock& cb,
|
||||
* other number if something wrong
|
||||
***********************************************************/
|
||||
const int DbFileOp::readSubBlockEntry( IDBDataFile* pFile, DataBlock* block,
|
||||
const uint64_t lbid, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
const uint64_t lbid, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
void* pStruct )
|
||||
{
|
||||
RETURN_ON_ERROR( readDBFile( pFile, block->data, lbid ) );
|
||||
@ -219,9 +229,9 @@ const int DbFileOp::readSubBlockEntry( IDBDataFile* pFile, DataBlock* block,
|
||||
}
|
||||
|
||||
|
||||
const int DbFileOp::readSubBlockEntry( CommBlock& cb, DataBlock* block,
|
||||
const uint64_t lbid, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
const int DbFileOp::readSubBlockEntry( CommBlock& cb, DataBlock* block,
|
||||
const uint64_t lbid, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
void* pStruct )
|
||||
{
|
||||
RETURN_ON_ERROR( readDBFile( cb, block->data, lbid ) );
|
||||
@ -232,7 +242,7 @@ const int DbFileOp::readSubBlockEntry( CommBlock& cb, DataBlock* block,
|
||||
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* Set an entry within a sub block
|
||||
* NOTE: the difference with writeSubBlockEntry is that
|
||||
* setSubBlockEntry only works for buffer while
|
||||
@ -246,18 +256,18 @@ const int DbFileOp::readSubBlockEntry( CommBlock& cb, DataBlock* block,
|
||||
* RETURN:
|
||||
* none
|
||||
***********************************************************/
|
||||
void DbFileOp::setSubBlockEntry( unsigned char* blockBuf, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
void DbFileOp::setSubBlockEntry( unsigned char* blockBuf, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
const void* pStruct )
|
||||
{
|
||||
unsigned char* pBlock;
|
||||
|
||||
pBlock = blockBuf + BYTE_PER_SUBBLOCK * sbid + entryNo *MAX_COLUMN_BOUNDARY;
|
||||
pBlock = blockBuf + BYTE_PER_SUBBLOCK * sbid + entryNo * MAX_COLUMN_BOUNDARY;
|
||||
memcpy( pBlock, pStruct, width );
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* Write a number of blocks to the file at specified location
|
||||
* PARAMETERS:
|
||||
* pFile - file handle
|
||||
@ -268,48 +278,52 @@ void DbFileOp::setSubBlockEntry( unsigned char* blockBuf, const int sbid,
|
||||
* NO_ERROR if success
|
||||
* other number if something wrong
|
||||
***********************************************************/
|
||||
int DbFileOp::writeDBFile( CommBlock& cb, const unsigned char* writeBuf,
|
||||
const uint64_t lbid, const int numOfBlock )
|
||||
{
|
||||
int DbFileOp::writeDBFile( CommBlock& cb, const unsigned char* writeBuf,
|
||||
const uint64_t lbid, const int numOfBlock )
|
||||
{
|
||||
CacheKey key;
|
||||
int ret;
|
||||
|
||||
if( Cache::getUseCache() )
|
||||
if ( Cache::getUseCache() )
|
||||
{
|
||||
if( Cache::cacheKeyExist( cb.file.oid, lbid ) ) {
|
||||
if ( Cache::cacheKeyExist( cb.file.oid, lbid ) )
|
||||
{
|
||||
key = Cache::getCacheKey( cb.file.oid, lbid );
|
||||
RETURN_ON_ERROR( Cache::modifyCacheBlock( key, writeBuf ) );
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
if (BRMWrapper::getUseVb())
|
||||
{
|
||||
RETURN_ON_ERROR( writeVB( cb.file.pFile, cb.file.oid, lbid ) );
|
||||
}
|
||||
|
||||
if (BRMWrapper::getUseVb())
|
||||
{
|
||||
RETURN_ON_ERROR( writeVB( cb.file.pFile, cb.file.oid, lbid ) );
|
||||
}
|
||||
|
||||
ret = writeDBFile( cb.file.pFile, writeBuf, lbid, numOfBlock );
|
||||
if (BRMWrapper::getUseVb())
|
||||
{
|
||||
LBIDRange_v ranges;
|
||||
LBIDRange range;
|
||||
range.start = lbid;
|
||||
range.size = 1;
|
||||
ranges.push_back(range);
|
||||
BRMWrapper::getInstance()->writeVBEnd(getTransId(), ranges);
|
||||
}
|
||||
|
||||
if (BRMWrapper::getUseVb())
|
||||
{
|
||||
LBIDRange_v ranges;
|
||||
LBIDRange range;
|
||||
range.start = lbid;
|
||||
range.size = 1;
|
||||
ranges.push_back(range);
|
||||
BRMWrapper::getInstance()->writeVBEnd(getTransId(), ranges);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DbFileOp::writeDBFileNoVBCache(CommBlock & cb,
|
||||
const unsigned char * writeBuf,
|
||||
int DbFileOp::writeDBFileNoVBCache(CommBlock& cb,
|
||||
const unsigned char* writeBuf,
|
||||
const int fbo,
|
||||
const int numOfBlock)
|
||||
{
|
||||
return writeDBFileNoVBCache( cb.file.pFile, writeBuf, fbo, numOfBlock );
|
||||
return writeDBFileNoVBCache( cb.file.pFile, writeBuf, fbo, numOfBlock );
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* Core function for writing data w/o using VB cache
|
||||
* (bulk load dictionary store inserts)
|
||||
***********************************************************/
|
||||
@ -324,7 +338,8 @@ int DbFileOp::writeDBFileNoVBCache( IDBDataFile* pFile,
|
||||
Stats::startParseEvent(WE_STATS_WRITE_DCT);
|
||||
#endif
|
||||
|
||||
for( int i = 0; i < numOfBlock; i++ ) {
|
||||
for ( int i = 0; i < numOfBlock; i++ )
|
||||
{
|
||||
Stats::incIoBlockWrite();
|
||||
RETURN_ON_ERROR( writeFile( pFile, writeBuf, BYTE_PER_BLOCK ) );
|
||||
}
|
||||
@ -337,7 +352,7 @@ int DbFileOp::writeDBFileNoVBCache( IDBDataFile* pFile,
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* Core function for writing data using VB cache
|
||||
***********************************************************/
|
||||
int DbFileOp::writeDBFile( IDBDataFile* pFile, const unsigned char* writeBuf,
|
||||
@ -345,7 +360,8 @@ int DbFileOp::writeDBFile( IDBDataFile* pFile, const unsigned char* writeBuf,
|
||||
{
|
||||
RETURN_ON_ERROR( setFileOffsetBlock( pFile, lbid ) );
|
||||
|
||||
for( int i = 0; i < numOfBlock; i++ ) {
|
||||
for ( int i = 0; i < numOfBlock; i++ )
|
||||
{
|
||||
Stats::incIoBlockWrite();
|
||||
RETURN_ON_ERROR( writeFile( pFile, writeBuf, BYTE_PER_BLOCK ) );
|
||||
}
|
||||
@ -360,10 +376,11 @@ int DbFileOp::writeDBFileFbo(IDBDataFile* pFile, const unsigned char* writeBuf,
|
||||
{
|
||||
long long fboOffset = 0;
|
||||
|
||||
fboOffset = (fbo)*(long)BYTE_PER_BLOCK;
|
||||
fboOffset = (fbo) * (long)BYTE_PER_BLOCK;
|
||||
RETURN_ON_ERROR( setFileOffset( pFile, fboOffset ) );
|
||||
|
||||
for( int i = 0; i < numOfBlock; i++ ) {
|
||||
for ( int i = 0; i < numOfBlock; i++ )
|
||||
{
|
||||
Stats::incIoBlockWrite();
|
||||
RETURN_ON_ERROR( writeFile( pFile, writeBuf, BYTE_PER_BLOCK ) );
|
||||
}
|
||||
@ -372,7 +389,7 @@ int DbFileOp::writeDBFileFbo(IDBDataFile* pFile, const unsigned char* writeBuf,
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* Write an entry within a sub block to a file
|
||||
* NOTE: the difference with getSubBlockEntry is that
|
||||
* setSubBlockEntry only works for buffer while
|
||||
@ -390,8 +407,8 @@ int DbFileOp::writeDBFileFbo(IDBDataFile* pFile, const unsigned char* writeBuf,
|
||||
* other number if something wrong
|
||||
***********************************************************/
|
||||
const int DbFileOp::writeSubBlockEntry( IDBDataFile* pFile, DataBlock* block,
|
||||
const uint64_t lbid, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
const uint64_t lbid, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
void* pStruct )
|
||||
{
|
||||
setSubBlockEntry( block->data, sbid, entryNo, width, pStruct );
|
||||
@ -400,9 +417,9 @@ const int DbFileOp::writeSubBlockEntry( IDBDataFile* pFile, DataBlock* block,
|
||||
return writeDBFile( pFile, block->data, lbid );
|
||||
}
|
||||
|
||||
const int DbFileOp::writeSubBlockEntry( CommBlock& cb, DataBlock* block,
|
||||
const uint64_t lbid, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
const int DbFileOp::writeSubBlockEntry( CommBlock& cb, DataBlock* block,
|
||||
const uint64_t lbid, const int sbid,
|
||||
const int entryNo, const int width,
|
||||
void* pStruct )
|
||||
{
|
||||
setSubBlockEntry( block->data, sbid, entryNo, width, pStruct );
|
||||
@ -412,7 +429,7 @@ const int DbFileOp::writeSubBlockEntry( CommBlock& cb, DataBlock* block,
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION:
|
||||
* Write to version buffer
|
||||
* PARAMETERS:
|
||||
* oid - file oid
|
||||
@ -423,42 +440,42 @@ const int DbFileOp::writeSubBlockEntry( CommBlock& cb, DataBlock* block,
|
||||
***********************************************************/
|
||||
const int DbFileOp::writeVB( IDBDataFile* pFile, const OID oid, const uint64_t lbid )
|
||||
{
|
||||
if( !BRMWrapper::getUseVb() )
|
||||
if ( !BRMWrapper::getUseVb() )
|
||||
return NO_ERROR;
|
||||
|
||||
int rc;
|
||||
TxnID transId = getTransId();
|
||||
TxnID transId = getTransId();
|
||||
|
||||
if (transId !=((TxnID)INVALID_NUM))
|
||||
{
|
||||
rc= BRMWrapper::getInstance()->writeVB( pFile,
|
||||
(const VER_t)transId,
|
||||
oid, lbid, this );
|
||||
if (transId != ((TxnID)INVALID_NUM))
|
||||
{
|
||||
rc = BRMWrapper::getInstance()->writeVB( pFile,
|
||||
(const VER_t)transId,
|
||||
oid, lbid, this );
|
||||
//@Bug 4671. The error is already logged by worker node.
|
||||
/* if (rc != NO_ERROR)
|
||||
{
|
||||
char msg[2048];
|
||||
snprintf(msg, 2048,
|
||||
"we_dbfileop->BRMWrapper::getInstance()->writeVB "
|
||||
"transId %i oid %i lbid "
|
||||
#if __LP64__
|
||||
"%lu"
|
||||
#else
|
||||
"%llu"
|
||||
#endif
|
||||
" Error Code %i", transId, oid, lbid, rc);
|
||||
puts(msg);
|
||||
{
|
||||
logging::MessageLog ml(logging::LoggingID(19));
|
||||
logging::Message m;
|
||||
logging::Message::Args args;
|
||||
args.add(msg);
|
||||
m.format(args);
|
||||
ml.logCriticalMessage(m);
|
||||
}
|
||||
return rc;
|
||||
} */
|
||||
return rc;
|
||||
/* if (rc != NO_ERROR)
|
||||
{
|
||||
char msg[2048];
|
||||
snprintf(msg, 2048,
|
||||
"we_dbfileop->BRMWrapper::getInstance()->writeVB "
|
||||
"transId %i oid %i lbid "
|
||||
#if __LP64__
|
||||
"%lu"
|
||||
#else
|
||||
"%llu"
|
||||
#endif
|
||||
" Error Code %i", transId, oid, lbid, rc);
|
||||
puts(msg);
|
||||
{
|
||||
logging::MessageLog ml(logging::LoggingID(19));
|
||||
logging::Message m;
|
||||
logging::Message::Args args;
|
||||
args.add(msg);
|
||||
m.format(args);
|
||||
ml.logCriticalMessage(m);
|
||||
}
|
||||
return rc;
|
||||
} */
|
||||
return rc;
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
@ -469,12 +486,14 @@ int DbFileOp::readDbBlocks(IDBDataFile* pFile,
|
||||
uint64_t fbo,
|
||||
size_t n)
|
||||
{
|
||||
if (m_chunkManager) {
|
||||
if (m_chunkManager)
|
||||
{
|
||||
return m_chunkManager->readBlocks(pFile, readBuf, fbo, n);
|
||||
}
|
||||
}
|
||||
|
||||
if (setFileOffset(pFile, fbo*BYTE_PER_BLOCK, SEEK_SET) != NO_ERROR)
|
||||
if (setFileOffset(pFile, fbo * BYTE_PER_BLOCK, SEEK_SET) != NO_ERROR)
|
||||
return -1;
|
||||
|
||||
return pFile->read(readBuf, BYTE_PER_BLOCK * n) / BYTE_PER_BLOCK;
|
||||
}
|
||||
|
||||
@ -483,7 +502,7 @@ int DbFileOp::restoreBlock(IDBDataFile* pFile, const unsigned char* writeBuf, ui
|
||||
if (m_chunkManager)
|
||||
return m_chunkManager->restoreBlock(pFile, writeBuf, fbo);
|
||||
|
||||
if (setFileOffset(pFile, fbo*BYTE_PER_BLOCK, SEEK_SET) != NO_ERROR)
|
||||
if (setFileOffset(pFile, fbo * BYTE_PER_BLOCK, SEEK_SET) != NO_ERROR)
|
||||
return -1;
|
||||
|
||||
return pFile->write(writeBuf, BYTE_PER_BLOCK);
|
||||
|
Reference in New Issue
Block a user