You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
clang format apply
This commit is contained in:
@@ -38,17 +38,14 @@ namespace
|
||||
{
|
||||
const char* DATA_DIR_SUFFIX = "_data";
|
||||
const char* OLD_FILE_SUFFIX = ".old_bulk";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace WriteEngine
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// BulkRollbackFileCompressedHdfs constructor
|
||||
//------------------------------------------------------------------------------
|
||||
BulkRollbackFileCompressedHdfs::BulkRollbackFileCompressedHdfs(
|
||||
BulkRollbackMgr* mgr) :
|
||||
BulkRollbackFile(mgr)
|
||||
BulkRollbackFileCompressedHdfs::BulkRollbackFileCompressedHdfs(BulkRollbackMgr* mgr) : BulkRollbackFile(mgr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -58,7 +55,7 @@ BulkRollbackFileCompressedHdfs::BulkRollbackFileCompressedHdfs(
|
||||
BulkRollbackFileCompressedHdfs::~BulkRollbackFileCompressedHdfs()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Truncate the specified database segment file to the extent specified by
|
||||
// the given file offset. Also updates the header(s) as well.
|
||||
@@ -70,25 +67,18 @@ BulkRollbackFileCompressedHdfs::~BulkRollbackFileCompressedHdfs()
|
||||
// fileSizeBlocks - Number of raw data blocks to be left in the file.
|
||||
// Remainder of file is to be truncated.
|
||||
//------------------------------------------------------------------------------
|
||||
void BulkRollbackFileCompressedHdfs::truncateSegmentFile(
|
||||
OID columnOID,
|
||||
uint32_t dbRoot,
|
||||
uint32_t partNum,
|
||||
uint32_t segNum,
|
||||
long long fileSizeBlocks )
|
||||
void BulkRollbackFileCompressedHdfs::truncateSegmentFile(OID columnOID, uint32_t dbRoot, uint32_t partNum,
|
||||
uint32_t segNum, long long fileSizeBlocks)
|
||||
{
|
||||
std::ostringstream msgText;
|
||||
msgText << "Truncating compressed HDFS column file"
|
||||
": dbRoot-" << dbRoot <<
|
||||
"; part#-" << partNum <<
|
||||
"; seg#-" << segNum <<
|
||||
"; rawTotBlks-" << fileSizeBlocks;
|
||||
fMgr->logAMessage( logging::LOG_TYPE_INFO,
|
||||
logging::M0075, columnOID, msgText.str() );
|
||||
std::ostringstream msgText;
|
||||
msgText << "Truncating compressed HDFS column file"
|
||||
": dbRoot-"
|
||||
<< dbRoot << "; part#-" << partNum << "; seg#-" << segNum << "; rawTotBlks-" << fileSizeBlocks;
|
||||
fMgr->logAMessage(logging::LOG_TYPE_INFO, logging::M0075, columnOID, msgText.str());
|
||||
|
||||
restoreFromBackup( "column", columnOID, dbRoot, partNum, segNum );
|
||||
restoreFromBackup("column", columnOID, dbRoot, partNum, segNum);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Reinitialize a column segment extent (in the db file) to empty values,
|
||||
// following the HWM. Remaining extents in the file are truncated.
|
||||
@@ -105,32 +95,23 @@ void BulkRollbackFileCompressedHdfs::truncateSegmentFile(
|
||||
// colWidth - Width in bytes, of the applicable column
|
||||
// restoreHwmChk - Specifies whether HWM chunk is to be restored.
|
||||
//------------------------------------------------------------------------------
|
||||
void BulkRollbackFileCompressedHdfs::reInitTruncColumnExtent(
|
||||
OID columnOID,
|
||||
uint32_t dbRoot,
|
||||
uint32_t partNum,
|
||||
uint32_t segNum,
|
||||
long long startOffsetBlk,
|
||||
int nBlocks,
|
||||
CalpontSystemCatalog::ColDataType colType,
|
||||
uint32_t colWidth,
|
||||
bool restoreHwmChk )
|
||||
void BulkRollbackFileCompressedHdfs::reInitTruncColumnExtent(OID columnOID, uint32_t dbRoot, uint32_t partNum,
|
||||
uint32_t segNum, long long startOffsetBlk,
|
||||
int nBlocks,
|
||||
CalpontSystemCatalog::ColDataType colType,
|
||||
uint32_t colWidth, bool restoreHwmChk)
|
||||
{
|
||||
long long startOffset = startOffsetBlk * BYTE_PER_BLOCK;
|
||||
long long startOffset = startOffsetBlk * BYTE_PER_BLOCK;
|
||||
|
||||
std::ostringstream msgText;
|
||||
msgText << "Reinit HWM compressed column extent in HDFS db file" <<
|
||||
": dbRoot-" << dbRoot <<
|
||||
"; part#-" << partNum <<
|
||||
"; seg#-" << segNum <<
|
||||
"; rawOffset(bytes)-" << startOffset <<
|
||||
"; rawFreeBlks-" << nBlocks;
|
||||
fMgr->logAMessage( logging::LOG_TYPE_INFO,
|
||||
logging::M0075, columnOID, msgText.str() );
|
||||
std::ostringstream msgText;
|
||||
msgText << "Reinit HWM compressed column extent in HDFS db file"
|
||||
<< ": dbRoot-" << dbRoot << "; part#-" << partNum << "; seg#-" << segNum << "; rawOffset(bytes)-"
|
||||
<< startOffset << "; rawFreeBlks-" << nBlocks;
|
||||
fMgr->logAMessage(logging::LOG_TYPE_INFO, logging::M0075, columnOID, msgText.str());
|
||||
|
||||
restoreFromBackup( "column", columnOID, dbRoot, partNum, segNum );
|
||||
restoreFromBackup("column", columnOID, dbRoot, partNum, segNum);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Reinitialize a dictionary segment extent (in the db file) to empty blocks,
|
||||
// following the HWM. Remaining extents in the file are truncated.
|
||||
@@ -144,42 +125,33 @@ void BulkRollbackFileCompressedHdfs::reInitTruncColumnExtent(
|
||||
// to be reinitialized. Value is in raw data blocks.
|
||||
// nBlocks - Number of blocks to be reinitialized
|
||||
//------------------------------------------------------------------------------
|
||||
void BulkRollbackFileCompressedHdfs::reInitTruncDctnryExtent(
|
||||
OID dStoreOID,
|
||||
uint32_t dbRoot,
|
||||
uint32_t partNum,
|
||||
uint32_t segNum,
|
||||
long long startOffsetBlk,
|
||||
int nBlocks )
|
||||
void BulkRollbackFileCompressedHdfs::reInitTruncDctnryExtent(OID dStoreOID, uint32_t dbRoot, uint32_t partNum,
|
||||
uint32_t segNum, long long startOffsetBlk,
|
||||
int nBlocks)
|
||||
{
|
||||
long long startOffset = startOffsetBlk * BYTE_PER_BLOCK;
|
||||
long long startOffset = startOffsetBlk * BYTE_PER_BLOCK;
|
||||
|
||||
std::ostringstream msgText;
|
||||
msgText << "Reinit HWM compressed dictionary store extent in HDFS db file"
|
||||
": dbRoot-" << dbRoot <<
|
||||
"; part#-" << partNum <<
|
||||
"; seg#-" << segNum <<
|
||||
"; rawOffset(bytes)-" << startOffset <<
|
||||
"; rawFreeBlks-" << nBlocks;
|
||||
fMgr->logAMessage( logging::LOG_TYPE_INFO,
|
||||
logging::M0075, dStoreOID, msgText.str() );
|
||||
std::ostringstream msgText;
|
||||
msgText << "Reinit HWM compressed dictionary store extent in HDFS db file"
|
||||
": dbRoot-"
|
||||
<< dbRoot << "; part#-" << partNum << "; seg#-" << segNum << "; rawOffset(bytes)-" << startOffset
|
||||
<< "; rawFreeBlks-" << nBlocks;
|
||||
fMgr->logAMessage(logging::LOG_TYPE_INFO, logging::M0075, dStoreOID, msgText.str());
|
||||
|
||||
restoreFromBackup( "dictionary store", dStoreOID, dbRoot, partNum, segNum );
|
||||
restoreFromBackup("dictionary store", dStoreOID, dbRoot, partNum, segNum);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// For HDFS system, just always return true.
|
||||
// Let ConfirmHdfsDbFile later determine when/if/how to restore from any
|
||||
// existing backup file.
|
||||
//------------------------------------------------------------------------------
|
||||
bool BulkRollbackFileCompressedHdfs::doWeReInitExtent( OID columnOID,
|
||||
uint32_t dbRoot,
|
||||
uint32_t partNum,
|
||||
uint32_t segNum) const
|
||||
bool BulkRollbackFileCompressedHdfs::doWeReInitExtent(OID columnOID, uint32_t dbRoot, uint32_t partNum,
|
||||
uint32_t segNum) const
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Replace the currently specified db file with it's corresponding backup file.
|
||||
// The backup file is a complete backup, not just a backup of a single chunk.
|
||||
@@ -193,96 +165,79 @@ bool BulkRollbackFileCompressedHdfs::doWeReInitExtent( OID columnOID,
|
||||
// in case the user did not upgrade cleanly, and we have to restore using an
|
||||
// old leftover backup file.
|
||||
//------------------------------------------------------------------------------
|
||||
void BulkRollbackFileCompressedHdfs::restoreFromBackup(const char* colType,
|
||||
OID columnOID,
|
||||
uint32_t dbRoot,
|
||||
uint32_t partNum,
|
||||
uint32_t segNum)
|
||||
void BulkRollbackFileCompressedHdfs::restoreFromBackup(const char* colType, OID columnOID, uint32_t dbRoot,
|
||||
uint32_t partNum, uint32_t segNum)
|
||||
{
|
||||
// Construct file name for db file to be restored
|
||||
char dbFileName[FILE_NAME_SIZE];
|
||||
int rc = fDbFile.getFileName( columnOID, dbFileName,
|
||||
dbRoot, partNum, segNum );
|
||||
// Construct file name for db file to be restored
|
||||
char dbFileName[FILE_NAME_SIZE];
|
||||
int rc = fDbFile.getFileName(columnOID, dbFileName, dbRoot, partNum, segNum);
|
||||
|
||||
if (rc != NO_ERROR)
|
||||
if (rc != NO_ERROR)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Error restoring " << colType << " HDFS file for OID " << columnOID
|
||||
<< "; Can't construct file name for DBRoot" << dbRoot << "; partition-" << partNum << "; segment-"
|
||||
<< segNum;
|
||||
throw WeException(oss.str(), rc);
|
||||
}
|
||||
|
||||
// Construct file name for backup copy of db file
|
||||
std::ostringstream ossFile;
|
||||
ossFile << "/" << columnOID << ".p" << partNum << ".s" << segNum;
|
||||
std::string backupFileName(fMgr->getMetaFileName());
|
||||
backupFileName += DATA_DIR_SUFFIX;
|
||||
backupFileName += ossFile.str();
|
||||
|
||||
std::string dbFileNameTmp = dbFileName;
|
||||
dbFileNameTmp += OLD_FILE_SUFFIX;
|
||||
|
||||
// For backwards compatibility...
|
||||
// Restore from backup file used in initial HDFS release, in case the user
|
||||
// upgraded without going down cleanly. In that case we might need to
|
||||
// rollback using an old backup file left from previous release.
|
||||
if (IDBPolicy::exists(backupFileName.c_str()))
|
||||
{
|
||||
// Rename current db file to make room for restored file
|
||||
rc = IDBPolicy::rename(dbFileName, dbFileNameTmp.c_str());
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Error restoring " << colType <<
|
||||
" HDFS file for OID " << columnOID <<
|
||||
"; Can't construct file name for DBRoot" << dbRoot <<
|
||||
"; partition-" << partNum <<
|
||||
"; segment-" << segNum;
|
||||
throw WeException( oss.str(), rc );
|
||||
std::ostringstream oss;
|
||||
oss << "Error restoring " << colType << " HDFS file for OID " << columnOID
|
||||
<< "; Can't move old file for DBRoot" << dbRoot << "; partition-" << partNum << "; segment-"
|
||||
<< segNum;
|
||||
throw WeException(oss.str(), ERR_COMP_RENAME_FILE);
|
||||
}
|
||||
|
||||
// Construct file name for backup copy of db file
|
||||
std::ostringstream ossFile;
|
||||
ossFile << "/" << columnOID << ".p" << partNum << ".s" << segNum;
|
||||
std::string backupFileName( fMgr->getMetaFileName() );
|
||||
backupFileName += DATA_DIR_SUFFIX;
|
||||
backupFileName += ossFile.str();
|
||||
// Rename backup file to replace current db file
|
||||
rc = IDBPolicy::rename(backupFileName.c_str(), dbFileName);
|
||||
|
||||
std::string dbFileNameTmp = dbFileName;
|
||||
dbFileNameTmp += OLD_FILE_SUFFIX;
|
||||
|
||||
// For backwards compatibility...
|
||||
// Restore from backup file used in initial HDFS release, in case the user
|
||||
// upgraded without going down cleanly. In that case we might need to
|
||||
// rollback using an old backup file left from previous release.
|
||||
if ( IDBPolicy::exists(backupFileName.c_str()) )
|
||||
if (rc != 0)
|
||||
{
|
||||
// Rename current db file to make room for restored file
|
||||
rc = IDBPolicy::rename( dbFileName, dbFileNameTmp.c_str() );
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Error restoring " << colType <<
|
||||
" HDFS file for OID " << columnOID <<
|
||||
"; Can't move old file for DBRoot" << dbRoot <<
|
||||
"; partition-" << partNum <<
|
||||
"; segment-" << segNum;
|
||||
throw WeException( oss.str(), ERR_COMP_RENAME_FILE );
|
||||
}
|
||||
|
||||
// Rename backup file to replace current db file
|
||||
rc = IDBPolicy::rename( backupFileName.c_str(), dbFileName );
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Error restoring " << colType <<
|
||||
" HDFS file for OID " << columnOID <<
|
||||
"; Can't rename backup file for DBRoot" << dbRoot <<
|
||||
"; partition-" << partNum <<
|
||||
"; segment-" << segNum;
|
||||
throw WeException( oss.str(), ERR_METADATABKUP_COMP_RENAME );
|
||||
}
|
||||
|
||||
// Delete db file we just replaced with backup
|
||||
IDBPolicy::remove( dbFileNameTmp.c_str() );
|
||||
std::ostringstream oss;
|
||||
oss << "Error restoring " << colType << " HDFS file for OID " << columnOID
|
||||
<< "; Can't rename backup file for DBRoot" << dbRoot << "; partition-" << partNum << "; segment-"
|
||||
<< segNum;
|
||||
throw WeException(oss.str(), ERR_METADATABKUP_COMP_RENAME);
|
||||
}
|
||||
else // Restore from HDFS temp swap backup file; This is the normal case
|
||||
|
||||
// Delete db file we just replaced with backup
|
||||
IDBPolicy::remove(dbFileNameTmp.c_str());
|
||||
}
|
||||
else // Restore from HDFS temp swap backup file; This is the normal case
|
||||
{
|
||||
std::string errMsg;
|
||||
ConfirmHdfsDbFile confirmHdfs;
|
||||
rc = confirmHdfs.endDbFileChange(std::string("tmp"), dbFileName, false, errMsg);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
std::string errMsg;
|
||||
ConfirmHdfsDbFile confirmHdfs;
|
||||
rc = confirmHdfs.endDbFileChange( std::string("tmp"),
|
||||
dbFileName,
|
||||
false,
|
||||
errMsg);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Error restoring " << colType <<
|
||||
" HDFS file for OID " << columnOID <<
|
||||
"; DBRoot" << dbRoot <<
|
||||
"; partition-" << partNum <<
|
||||
"; segment-" << segNum <<
|
||||
"; " << errMsg;
|
||||
throw WeException( oss.str(), rc );
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << "Error restoring " << colType << " HDFS file for OID " << columnOID << "; DBRoot" << dbRoot
|
||||
<< "; partition-" << partNum << "; segment-" << segNum << "; " << errMsg;
|
||||
throw WeException(oss.str(), rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //end of namespace
|
||||
} // namespace WriteEngine
|
||||
|
Reference in New Issue
Block a user