1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -24,7 +24,7 @@
#ifndef DMLPACKAGEPROCESSOR_H
#define DMLPACKAGEPROCESSOR_H
#include <stdexcept>
#include <stdexcept>
#include <string>
#include <sstream>
#include <iostream>
@ -111,65 +111,80 @@ public:
logging::Message message;
/** @brief the rowCount
*/
long long rowCount;
long long rowCount;
std::string tableLockInfo;
// query stats;
std::string queryStats;
std::string extendedStats;
std::string miniStats;
querystats::QueryStats stats;
DMLResult():result(NO_ERROR),rowCount(0){};
DMLResult(): result(NO_ERROR), rowCount(0) {};
};
/** @brief a structure to hold a date
*/
struct Date
{
unsigned spare : 6;
unsigned day : 6;
unsigned month : 4;
unsigned year : 16;
// NULL column value = 0xFFFFFFFE
Date( ) { year = 0xFFFF; month = 0xF; day = 0x3F; spare = 0x3E;}
unsigned spare : 6;
unsigned day : 6;
unsigned month : 4;
unsigned year : 16;
// NULL column value = 0xFFFFFFFE
Date( )
{
year = 0xFFFF;
month = 0xF;
day = 0x3F;
spare = 0x3E;
}
};
/** @brief a structure to hold a datetime
*/
struct dateTime
{
unsigned msecond : 20;
unsigned second : 6;
unsigned minute : 6;
unsigned hour : 6;
unsigned day : 6;
unsigned month : 4;
unsigned year : 16;
// NULL column value = 0xFFFFFFFFFFFFFFFE
dateTime( ) { year = 0xFFFF; month = 0xF; day = 0x3F; hour = 0x3F; minute = 0x3F; second = 0x3F;
msecond = 0xFFFFE; }
unsigned msecond : 20;
unsigned second : 6;
unsigned minute : 6;
unsigned hour : 6;
unsigned day : 6;
unsigned month : 4;
unsigned year : 16;
// NULL column value = 0xFFFFFFFFFFFFFFFE
dateTime( )
{
year = 0xFFFF;
month = 0xF;
day = 0x3F;
hour = 0x3F;
minute = 0x3F;
second = 0x3F;
msecond = 0xFFFFE;
}
};
/** @brief ctor
*/
*/
DMLPackageProcessor(BRM::DBRM* aDbrm, uint32_t sid) : fEC(0), DMLLoggingId(21), fRollbackPending(false), fDebugLevel(NONE)
{
try {
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DMLPROC);
//std::cout << "In DMLPackageProcessor constructor " << this << std::endl;
fPMCount = fWEClient->getPmCount();
}
catch (...)
{
std::cout << "Cannot make connection to WES" << std::endl;
}
oam::OamCache * oamCache = oam::OamCache::makeOamCache();
fDbRootPMMap = oamCache->getDBRootToPMMap();
fDbrm = aDbrm;
fSessionID = sid;
fExeMgr = new execplan::ClientRotator(fSessionID, "ExeMgr");
//std::cout << " fSessionID is " << fSessionID << std::endl;
fExeMgr->connect(0.005);
}
{
try
{
fWEClient = new WriteEngine::WEClients(WriteEngine::WEClients::DMLPROC);
//std::cout << "In DMLPackageProcessor constructor " << this << std::endl;
fPMCount = fWEClient->getPmCount();
}
catch (...)
{
std::cout << "Cannot make connection to WES" << std::endl;
}
oam::OamCache* oamCache = oam::OamCache::makeOamCache();
fDbRootPMMap = oamCache->getDBRootToPMMap();
fDbrm = aDbrm;
fSessionID = sid;
fExeMgr = new execplan::ClientRotator(fSessionID, "ExeMgr");
//std::cout << " fSessionID is " << fSessionID << std::endl;
fExeMgr->connect(0.005);
}
@ -179,34 +194,49 @@ public:
/** @brief Is it required to debug
*/
inline const bool isDebug( const DebugLevel level ) const { return level <= fDebugLevel; }
inline const bool isDebug( const DebugLevel level ) const
{
return level <= fDebugLevel;
}
/**
* @brief Get debug level
*/
inline const DebugLevel getDebugLevel() const { return fDebugLevel; }
inline const DebugLevel getDebugLevel() const
{
return fDebugLevel;
}
//int rollBackTransaction(uint64_t uniqueId, uint32_t txnID, uint32_t sessionID, std::string & errorMsg);
/**
* @brief Set debug level
*/
inline void setDebugLevel( const DebugLevel level ) { fDebugLevel = level; }
inline void setDebugLevel( const DebugLevel level )
{
fDebugLevel = level;
}
/**
* @brief Set the Distributed Engine Comm object
*/
inline void setEngineComm(joblist::DistributedEngineComm* ec) { fEC = ec; }
inline void setEngineComm(joblist::DistributedEngineComm* ec)
{
fEC = ec;
}
/** @brief process the dml package
*
* @param cpackage the CalpontDMLPackage to process
*/
virtual DMLResult processPackage(dmlpackage::CalpontDMLPackage& cpackage) = 0;
inline void setRM ( joblist::ResourceManager* frm) { fRM = frm; };
EXPORT int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, std::string & errorMsg);
EXPORT int rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string & errorMsg);
inline void setRM ( joblist::ResourceManager* frm)
{
fRM = frm;
};
EXPORT int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, std::string& errorMsg);
EXPORT int rollBackBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string& errorMsg);
/**
* @brief convert a columns data, represnted as a string, to it's native
* data type
@ -222,7 +252,7 @@ public:
* @param type the columns database type
* @param data the columns string representation of it's data
*/
//static std::string dateToString( int datevalue );
//static std::string dateToString( int datevalue );
/** @brief validate numerical string
*
* @param result the result structure
@ -262,11 +292,17 @@ public:
/** @brief Access the rollback pending flag
*/
bool getRollbackPending() {return fRollbackPending;}
bool getRollbackPending()
{
return fRollbackPending;
}
/** @brief Set the rollback pending flag
*/
void setRollbackPending(bool rollback) {fRollbackPending = rollback;}
void setRollbackPending(bool rollback)
{
fRollbackPending = rollback;
}
protected:
/** @brief update the indexes on the target table
@ -279,7 +315,7 @@ protected:
* @param colNameList the updated column names, only valid for update SQL statement
*/
bool updateIndexes( uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const std::string& schema,
const std::string& table,const dmlpackage::RowList& rows, DMLResult& result,
const std::string& table, const dmlpackage::RowList& rows, DMLResult& result,
std::vector<WriteEngine::RID> ridList,
WriteEngine::ColValueList& colValuesList, std::vector<std::string>& colNameList, const char updateFlag,
std::vector<dicStrValues>& dicStrValCols );
@ -311,19 +347,19 @@ protected:
* @param result the result structure
*/
bool violatesUniqueConstraint( const dmlpackage::RowList& rows,
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
unsigned int sessionID,
DMLResult& result);
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
unsigned int sessionID,
DMLResult& result);
/** @brief validate that the column does not violate a check constraint
*
* @param column the column to validate
* @param result the result structure
*/
bool violatesCheckConstraint( const dmlpackage::RowList& rows,
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
unsigned int sessionID, unsigned int colOffset,
DMLResult& result );
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
unsigned int sessionID, unsigned int colOffset,
DMLResult& result );
/** @brief validate that the column does not violate a not null constraint
*
@ -333,19 +369,19 @@ protected:
*/
bool violatesNotNullConstraint( const dmlpackage::RowList& rows, unsigned int colOffset,
DMLResult& result );
/** @brief validate that the column does not violate a reference (foreign key) constraint
*
* @param rows the row set to validate
* @param colOffset the offset of this column in the row
* @param constraintInfo the column constraint infomation
* @param result the result structure
*/
bool violatesReferenceConstraint( const dmlpackage::RowList& rows,
/** @brief validate that the column does not violate a reference (foreign key) constraint
*
* @param rows the row set to validate
* @param colOffset the offset of this column in the row
* @param constraintInfo the column constraint infomation
* @param result the result structure
*/
bool violatesReferenceConstraint( const dmlpackage::RowList& rows,
unsigned int colOffset,
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
DMLResult& result );
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
DMLResult& result );
/** @brief validate that non of the rows deleted from this table violate a reference
* (foreign key) constraint of the reference table.
*
@ -353,53 +389,53 @@ protected:
* @param table the table name
* @param rows the lists of rows to check column constraints on
* @param result the result structure
*/
bool violatesPKRefConnstraint ( uint32_t sessionID,
const std::string& schema,
const std::string& table,
const dmlpackage::RowList& rows,
const WriteEngine::ColValueList& oldValueList,
DMLResult& result );
bool violatesPKRefConnstraint ( uint32_t sessionID,
const std::string& schema,
const std::string& table,
std::vector<WriteEngine::RID>& rowIDList,
std::vector<void *>& oldValueList,
DMLResult& result );
/** @brief validate that the rows deleted does not violate a reference (foreign key) constraint
*
* @param rows the row set to validate
* @param colOffset the offset of this column in the row
* @param constraintInfo the column constraint infomation
* @param result the result structure
*/
bool violatesReferenceConstraint_PK( const WriteEngine::ColValueList& oldValueList,
const execplan::CalpontSystemCatalog::ColType& colType,
unsigned int colOffset,
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
DMLResult& result );
bool violatesPKRefConnstraint ( uint32_t sessionID,
const std::string& schema,
const std::string& table,
const dmlpackage::RowList& rows,
const WriteEngine::ColValueList& oldValueList,
DMLResult& result );
bool violatesReferenceConstraint_PK( std::vector<void *>& oldValueList,
bool violatesPKRefConnstraint ( uint32_t sessionID,
const std::string& schema,
const std::string& table,
std::vector<WriteEngine::RID>& rowIDList,
std::vector<void*>& oldValueList,
DMLResult& result );
/** @brief validate that the rows deleted does not violate a reference (foreign key) constraint
*
* @param rows the row set to validate
* @param colOffset the offset of this column in the row
* @param constraintInfo the column constraint infomation
* @param result the result structure
*/
bool violatesReferenceConstraint_PK( const WriteEngine::ColValueList& oldValueList,
const execplan::CalpontSystemCatalog::ColType& colType,
unsigned int colOffset,
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
DMLResult& result );
bool violatesReferenceConstraint_PK( std::vector<void*>& oldValueList,
const int totalRows,
const execplan::CalpontSystemCatalog::ColType& colType,
unsigned int colOffset,
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
DMLResult& result );
/** @brief validate that none of the columns in the update row(s) violate
* any reference constraints of the foreign key table
*
* @param schema the schema name
* @param table the table name
* @param rows the lists of rows to check column constraints on
* @param result the result structure
*/
bool violatesUpdtRefConstraints( uint32_t sessionID,
const std::string& schema,
/** @brief validate that none of the columns in the update row(s) violate
* any reference constraints of the foreign key table
*
* @param schema the schema name
* @param table the table name
* @param rows the lists of rows to check column constraints on
* @param result the result structure
*/
bool violatesUpdtRefConstraints( uint32_t sessionID,
const std::string& schema,
const std::string& table,
const dmlpackage::RowList& rows,
const dmlpackage::RowList& rows,
DMLResult& result );
@ -409,13 +445,13 @@ protected:
* @param colOffset the offset of this column in the row
* @param constraintInfo the column constraint infomation
* @param result the result structure
*/
bool violatesReferenceConstraint_updt( const dmlpackage::RowList& rows,
*/
bool violatesReferenceConstraint_updt( const dmlpackage::RowList& rows,
unsigned int colOffset,
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
DMLResult& result );
const execplan::CalpontSystemCatalog::ConstraintInfo& constraintInfo,
DMLResult& result );
/** @brief get the column list for the supplied table
*
* @param schema the schema name
@ -423,8 +459,8 @@ protected:
* @param colList ColumnList to fill with the columns for the supplied table
*/
void getColumnsForTable( uint32_t sessionID, std::string schema, std::string table, dmlpackage::ColumnList& colList );
/** @brief convert absolute rid to relative rid in a segement file
/** @brief convert absolute rid to relative rid in a segement file
*
* @param rid in:the absolute rid out: relative rid in a segement file
* @param dbRoot,partition, segment the extent information obtained from rid
@ -432,25 +468,25 @@ protected:
* @param startDBRoot the dbroot this table starts
* @param dbrootCnt the number of dbroot in db
*/
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
unsigned& segment, unsigned filesPerColumnPartition,
unsigned extentsPerSegmentFile, unsigned extentRows,
unsigned startDBRoot, unsigned dbrootCnt,
const unsigned startPartitionNum );
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
unsigned& segment, unsigned filesPerColumnPartition,
unsigned extentsPerSegmentFile, unsigned extentRows,
unsigned startDBRoot, unsigned dbrootCnt,
const unsigned startPartitionNum );
inline bool isDictCol ( execplan::CalpontSystemCatalog::ColType colType )
{
if (((colType.colDataType == execplan::CalpontSystemCatalog::CHAR) && (colType.colWidth > 8))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::VARCHAR) && (colType.colWidth > 7))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::DECIMAL) && (colType.precision > 18))
|| (colType.colDataType == execplan::CalpontSystemCatalog::VARBINARY)
|| (colType.colDataType == execplan::CalpontSystemCatalog::BLOB)
|| (colType.colDataType == execplan::CalpontSystemCatalog::TEXT))
{
return true;
}
else
return false;
if (((colType.colDataType == execplan::CalpontSystemCatalog::CHAR) && (colType.colWidth > 8))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::VARCHAR) && (colType.colWidth > 7))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::DECIMAL) && (colType.precision > 18))
|| (colType.colDataType == execplan::CalpontSystemCatalog::VARBINARY)
|| (colType.colDataType == execplan::CalpontSystemCatalog::BLOB)
|| (colType.colDataType == execplan::CalpontSystemCatalog::TEXT))
{
return true;
}
else
return false;
}
@ -460,21 +496,21 @@ protected:
* @returns error string
*/
std::string projectTableErrCodeToMsg(uint32_t ec);
// bool validateNextValue(execplan::CalpontSystemCatalog::ColType colType, int64_t value, bool & offByOne);
bool validateVarbinaryVal( std::string & inStr);
bool validateVarbinaryVal( std::string& inStr);
int commitTransaction(uint64_t uniqueId, BRM::TxnID txnID);
int commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string & errorMsg);
int commitBatchAutoOffTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string & errorMsg);
int rollBackBatchAutoOffTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string & errorMsg);
int flushDataFiles (int rc, std::map<uint32_t,uint32_t> & columnOids, uint64_t uniqueId, BRM::TxnID txnID, uint32_t tableOid);
int endTransaction (uint64_t uniqueId, BRM::TxnID txnID, bool success);
int commitBatchAutoOnTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string& errorMsg);
int commitBatchAutoOffTransaction(uint64_t uniqueId, BRM::TxnID txnID, const uint32_t tableOid, std::string& errorMsg);
int rollBackBatchAutoOffTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID, const uint32_t tableOid, std::string& errorMsg);
int flushDataFiles (int rc, std::map<uint32_t, uint32_t>& columnOids, uint64_t uniqueId, BRM::TxnID txnID, uint32_t tableOid);
int endTransaction (uint64_t uniqueId, BRM::TxnID txnID, bool success);
/** @brief the Session Manager interface
*/
execplan::SessionManager fSessionManager;
joblist::DistributedEngineComm *fEC;
joblist::DistributedEngineComm* fEC;
joblist::ResourceManager* fRM;
char* strlower(char* in);
uint32_t fSessionID;
@ -485,14 +521,14 @@ protected:
boost::shared_ptr<std::map<int, int> > fDbRootPMMap;
oam::Oam fOam;
bool fRollbackPending; // When set, any derived object should stop what it's doing and cleanup in preparation for a Rollback
execplan::ClientRotator* fExeMgr;
execplan::ClientRotator* fExeMgr;
private:
/** @brief clean beginning and ending glitches and spaces from string
*
* @param s string to be cleaned
*/
/** @brief clean beginning and ending glitches and spaces from string
*
* @param s string to be cleaned
*/
void cleanString(std::string& s);
DebugLevel fDebugLevel; // internal use debug level
@ -505,7 +541,7 @@ private:
template <class T>
bool from_string(T& t,
const std::string& s,
std::ios_base& (*f)(std::ios_base&))
std::ios_base & (*f)(std::ios_base&))
{
std::istringstream iss(s);
return !(iss >> f >> t).fail();