You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
clang format apply
This commit is contained in:
343
dbcon/mysql/sm.h
343
dbcon/mysql/sm.h
@ -47,9 +47,14 @@
|
||||
|
||||
#if IDB_SM_PROFILE
|
||||
#include <sys/time.h>
|
||||
#define GET_PF_TIME(n) {gettimeofday(&n, NULL);}
|
||||
#define GET_PF_TIME(n) \
|
||||
{ \
|
||||
gettimeofday(&n, NULL); \
|
||||
}
|
||||
#else
|
||||
#define GET_PF_TIME(n) {}
|
||||
#define GET_PF_TIME(n) \
|
||||
{ \
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace sm
|
||||
@ -60,10 +65,12 @@ const int SQL_KILLED = -1001;
|
||||
const int CALPONT_INTERNAL_ERROR = -1007;
|
||||
|
||||
//#if IDB_SM_DEBUG
|
||||
//extern std::ofstream smlog;
|
||||
// extern std::ofstream smlog;
|
||||
//#define SMDEBUGLOG smlog
|
||||
//#else
|
||||
#define SMDEBUGLOG if (false) std::cout
|
||||
#define SMDEBUGLOG \
|
||||
if (false) \
|
||||
std::cout
|
||||
//#endif
|
||||
extern const std::string DEFAULT_SAVE_PATH;
|
||||
|
||||
@ -72,206 +79,219 @@ typedef int32_t status_t;
|
||||
|
||||
enum QueryState
|
||||
{
|
||||
NO_QUERY = 0,
|
||||
QUERY_IN_PROCESS
|
||||
NO_QUERY = 0,
|
||||
QUERY_IN_PROCESS
|
||||
};
|
||||
|
||||
typedef struct Column
|
||||
{
|
||||
Column(): tableID(-1) {}
|
||||
~Column() {}
|
||||
int tableID;
|
||||
int colPos;
|
||||
int dataType;
|
||||
std::vector <std::string> data;
|
||||
Column() : tableID(-1)
|
||||
{
|
||||
}
|
||||
~Column()
|
||||
{
|
||||
}
|
||||
int tableID;
|
||||
int colPos;
|
||||
int dataType;
|
||||
std::vector<std::string> data;
|
||||
} Column;
|
||||
|
||||
typedef std::map <int, Column*> ResultMap;
|
||||
typedef std::map<int, Column*> ResultMap;
|
||||
|
||||
struct Profiler
|
||||
{
|
||||
struct timeval login;
|
||||
struct timeval beforePlan;
|
||||
struct timeval afterPlan;
|
||||
struct timeval resultArrival;
|
||||
struct timeval resultReady;
|
||||
struct timeval endProcess;
|
||||
long prePlan()
|
||||
{
|
||||
return (beforePlan.tv_sec - login.tv_sec) * 1000 +
|
||||
(beforePlan.tv_usec - login.tv_usec) / 1000;
|
||||
}
|
||||
long buildPlan()
|
||||
{
|
||||
return (afterPlan.tv_sec - beforePlan.tv_sec) * 1000 +
|
||||
(afterPlan.tv_usec - beforePlan.tv_usec) / 1000;
|
||||
}
|
||||
long jobProcess()
|
||||
{
|
||||
return (resultArrival.tv_sec - afterPlan.tv_sec) * 1000 +
|
||||
(resultArrival.tv_usec - afterPlan.tv_usec) / 1000;
|
||||
}
|
||||
long buildResult()
|
||||
{
|
||||
return (resultReady.tv_sec - resultArrival.tv_sec) * 1000 +
|
||||
(resultReady.tv_usec - resultArrival.tv_usec) / 1000;
|
||||
}
|
||||
long tableFetch ()
|
||||
{
|
||||
return (endProcess.tv_sec - resultReady.tv_sec) * 1000 +
|
||||
(endProcess.tv_usec - resultReady.tv_usec) / 1000;
|
||||
}
|
||||
struct timeval login;
|
||||
struct timeval beforePlan;
|
||||
struct timeval afterPlan;
|
||||
struct timeval resultArrival;
|
||||
struct timeval resultReady;
|
||||
struct timeval endProcess;
|
||||
long prePlan()
|
||||
{
|
||||
return (beforePlan.tv_sec - login.tv_sec) * 1000 + (beforePlan.tv_usec - login.tv_usec) / 1000;
|
||||
}
|
||||
long buildPlan()
|
||||
{
|
||||
return (afterPlan.tv_sec - beforePlan.tv_sec) * 1000 + (afterPlan.tv_usec - beforePlan.tv_usec) / 1000;
|
||||
}
|
||||
long jobProcess()
|
||||
{
|
||||
return (resultArrival.tv_sec - afterPlan.tv_sec) * 1000 +
|
||||
(resultArrival.tv_usec - afterPlan.tv_usec) / 1000;
|
||||
}
|
||||
long buildResult()
|
||||
{
|
||||
return (resultReady.tv_sec - resultArrival.tv_sec) * 1000 +
|
||||
(resultReady.tv_usec - resultArrival.tv_usec) / 1000;
|
||||
}
|
||||
long tableFetch()
|
||||
{
|
||||
return (endProcess.tv_sec - resultReady.tv_sec) * 1000 +
|
||||
(endProcess.tv_usec - resultReady.tv_usec) / 1000;
|
||||
}
|
||||
};
|
||||
|
||||
/** @brief Calpont table scan handle */
|
||||
struct cpsm_tplsch_t
|
||||
{
|
||||
cpsm_tplsch_t() : tableid(0), rowsreturned(0), rowGroup(0), traceFlags(0), bandID(0), saveFlag(0), bandsReturned(0),
|
||||
ctp(0) {}
|
||||
~cpsm_tplsch_t()
|
||||
{
|
||||
delete rowGroup;
|
||||
}
|
||||
cpsm_tplsch_t()
|
||||
: tableid(0), rowsreturned(0), rowGroup(0), traceFlags(0), bandID(0), saveFlag(0), bandsReturned(0), ctp(0)
|
||||
{
|
||||
}
|
||||
~cpsm_tplsch_t()
|
||||
{
|
||||
delete rowGroup;
|
||||
}
|
||||
|
||||
tableid_t tableid;
|
||||
uint64_t rowsreturned;
|
||||
rowgroup::RowGroup* rowGroup;
|
||||
messageqcpp::ByteStream bs; // rowgroup bytestream. need to stay with the life span of rowgroup
|
||||
uint32_t traceFlags;
|
||||
// @bug 649
|
||||
int bandID; // the band that being read from the disk
|
||||
int key; // unique key for the table's scan context
|
||||
// @bug 626
|
||||
uint16_t saveFlag;
|
||||
uint32_t bandsReturned;
|
||||
std::vector<execplan::CalpontSystemCatalog::ColType> ctp;
|
||||
std::string errMsg;
|
||||
rowgroup::RGData rgData;
|
||||
void deserializeTable(messageqcpp::ByteStream& bs)
|
||||
tableid_t tableid;
|
||||
uint64_t rowsreturned;
|
||||
rowgroup::RowGroup* rowGroup;
|
||||
messageqcpp::ByteStream bs; // rowgroup bytestream. need to stay with the life span of rowgroup
|
||||
uint32_t traceFlags;
|
||||
// @bug 649
|
||||
int bandID; // the band that being read from the disk
|
||||
int key; // unique key for the table's scan context
|
||||
// @bug 626
|
||||
uint16_t saveFlag;
|
||||
uint32_t bandsReturned;
|
||||
std::vector<execplan::CalpontSystemCatalog::ColType> ctp;
|
||||
std::string errMsg;
|
||||
rowgroup::RGData rgData;
|
||||
void deserializeTable(messageqcpp::ByteStream& bs)
|
||||
{
|
||||
if (!rowGroup)
|
||||
{
|
||||
if (!rowGroup)
|
||||
{
|
||||
rowGroup = new rowgroup::RowGroup();
|
||||
rowGroup->deserialize(bs);
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXXST: the 'true' is to ease the transition to RGDatas. Take it out when the
|
||||
// transition is done.
|
||||
rgData.deserialize(bs, true);
|
||||
rowGroup->setData(&rgData);
|
||||
//rowGroup->setData(const_cast<uint8_t*>(bs.buf()));
|
||||
}
|
||||
rowGroup = new rowgroup::RowGroup();
|
||||
rowGroup->deserialize(bs);
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXXST: the 'true' is to ease the transition to RGDatas. Take it out when the
|
||||
// transition is done.
|
||||
rgData.deserialize(bs, true);
|
||||
rowGroup->setData(&rgData);
|
||||
// rowGroup->setData(const_cast<uint8_t*>(bs.buf()));
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t getStatus()
|
||||
{
|
||||
idbassert(rowGroup != 0);
|
||||
return rowGroup->getStatus();
|
||||
}
|
||||
uint16_t getStatus()
|
||||
{
|
||||
idbassert(rowGroup != 0);
|
||||
return rowGroup->getStatus();
|
||||
}
|
||||
|
||||
uint64_t getRowCount()
|
||||
{
|
||||
if (rowGroup)
|
||||
return rowGroup->getRowCount();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
uint64_t getRowCount()
|
||||
{
|
||||
if (rowGroup)
|
||||
return rowGroup->getRowCount();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setErrMsg()
|
||||
void setErrMsg()
|
||||
{
|
||||
if (rowGroup && getStatus())
|
||||
{
|
||||
if (rowGroup && getStatus())
|
||||
{
|
||||
//bs.advance(rowGroup->getDataSize());
|
||||
bs >> errMsg;
|
||||
}
|
||||
else
|
||||
{
|
||||
errMsg = "NOERROR";
|
||||
}
|
||||
// bs.advance(rowGroup->getDataSize());
|
||||
bs >> errMsg;
|
||||
}
|
||||
else
|
||||
{
|
||||
errMsg = "NOERROR";
|
||||
}
|
||||
}
|
||||
};
|
||||
typedef boost::shared_ptr<cpsm_tplsch_t> sp_cpsm_tplsch_t;
|
||||
|
||||
/** @brief Calpont connection handle structure */
|
||||
class cpsm_conhdl_t
|
||||
{
|
||||
public:
|
||||
cpsm_conhdl_t(time_t v, const uint32_t sid, bool columnstore_local_query) :
|
||||
value(v), sessionID(sid), queryState (NO_QUERY),
|
||||
exeMgr( new execplan::ClientRotator(sid, "ExeMgr", columnstore_local_query)),
|
||||
tblinfo_idx(0), idxinfo_idx(0), curFetchTb (0)
|
||||
{ }
|
||||
public:
|
||||
cpsm_conhdl_t(time_t v, const uint32_t sid, bool columnstore_local_query)
|
||||
: value(v)
|
||||
, sessionID(sid)
|
||||
, queryState(NO_QUERY)
|
||||
, exeMgr(new execplan::ClientRotator(sid, "ExeMgr", columnstore_local_query))
|
||||
, tblinfo_idx(0)
|
||||
, idxinfo_idx(0)
|
||||
, curFetchTb(0)
|
||||
{
|
||||
}
|
||||
|
||||
/** @brief connnect ExeMgr
|
||||
*
|
||||
* Try connecting to ExeMgr. If no connection, try ExeMgr1,
|
||||
* ExeMgr2... until timeout lapses. Then throw exception.
|
||||
*/
|
||||
void connect(double timeout = 0.005)
|
||||
{
|
||||
exeMgr->connect(timeout);
|
||||
}
|
||||
EXPORT void write(messageqcpp::ByteStream bs);
|
||||
|
||||
/** @brief connnect ExeMgr
|
||||
*
|
||||
* Try connecting to ExeMgr. If no connection, try ExeMgr1,
|
||||
* ExeMgr2... until timeout lapses. Then throw exception.
|
||||
*/
|
||||
void connect(double timeout = 0.005)
|
||||
{
|
||||
exeMgr->connect(timeout);
|
||||
}
|
||||
EXPORT void write(messageqcpp::ByteStream bs);
|
||||
~cpsm_conhdl_t()
|
||||
{
|
||||
delete exeMgr;
|
||||
}
|
||||
EXPORT const std::string toString() const;
|
||||
time_t value;
|
||||
uint32_t sessionID;
|
||||
short queryState; // 0 -- NO_QUERY; 1 -- QUERY_IN_PROCESS
|
||||
execplan::ClientRotator* exeMgr;
|
||||
ResultMap resultSet;
|
||||
Profiler pf;
|
||||
int tblinfo_idx;
|
||||
int idxinfo_idx;
|
||||
std::string schemaname;
|
||||
std::string tablename;
|
||||
int tboid;
|
||||
short requestType; // 0 -- ID2NAME; 1 -- NAME2ID
|
||||
boost::shared_ptr<execplan::CalpontSystemCatalog> csc;
|
||||
// @bug 649; @bug 626
|
||||
std::map<int, int> tidMap; // tableid-tableStartCount map
|
||||
std::map<int, sp_cpsm_tplsch_t> tidScanMap;
|
||||
std::map<int, int> keyBandMap; // key-savedBandCount map
|
||||
int curFetchTb; // current fetching table key
|
||||
std::string queryStats;
|
||||
std::string extendedStats;
|
||||
std::string miniStats;
|
||||
|
||||
~cpsm_conhdl_t()
|
||||
{
|
||||
delete exeMgr;
|
||||
}
|
||||
EXPORT const std::string toString() const;
|
||||
time_t value;
|
||||
uint32_t sessionID;
|
||||
short queryState; // 0 -- NO_QUERY; 1 -- QUERY_IN_PROCESS
|
||||
execplan::ClientRotator* exeMgr;
|
||||
ResultMap resultSet;
|
||||
Profiler pf;
|
||||
int tblinfo_idx;
|
||||
int idxinfo_idx;
|
||||
std::string schemaname;
|
||||
std::string tablename;
|
||||
int tboid;
|
||||
short requestType; // 0 -- ID2NAME; 1 -- NAME2ID
|
||||
boost::shared_ptr<execplan::CalpontSystemCatalog> csc;
|
||||
// @bug 649; @bug 626
|
||||
std::map <int, int> tidMap; // tableid-tableStartCount map
|
||||
std::map <int, sp_cpsm_tplsch_t> tidScanMap;
|
||||
std::map <int, int> keyBandMap; // key-savedBandCount map
|
||||
int curFetchTb; // current fetching table key
|
||||
std::string queryStats;
|
||||
std::string extendedStats;
|
||||
std::string miniStats;
|
||||
private:
|
||||
private:
|
||||
};
|
||||
std::ostream& operator<<(std::ostream& output, const cpsm_conhdl_t& rhs);
|
||||
|
||||
// @bug 626 save table bands to avoid sending plan too many times
|
||||
enum SavingFlag
|
||||
{
|
||||
NO_SAVE = 0,
|
||||
SAVING,
|
||||
SAVED
|
||||
NO_SAVE = 0,
|
||||
SAVING,
|
||||
SAVED
|
||||
};
|
||||
|
||||
/** @brief Calpont table handle */
|
||||
struct cpsm_tplh_t
|
||||
{
|
||||
cpsm_tplh_t() : tableid(0), rowsintable(0), bandID(0), saveFlag(NO_SAVE), bandsInTable(0) {}
|
||||
tableid_t tableid;
|
||||
int rowsintable;
|
||||
// @bug 649
|
||||
int bandID; // the band that being read from the disk
|
||||
int key; // unique key for the table's scan context
|
||||
// @bug 626
|
||||
uint16_t saveFlag;
|
||||
int bandsInTable;
|
||||
cpsm_tplh_t() : tableid(0), rowsintable(0), bandID(0), saveFlag(NO_SAVE), bandsInTable(0)
|
||||
{
|
||||
}
|
||||
tableid_t tableid;
|
||||
int rowsintable;
|
||||
// @bug 649
|
||||
int bandID; // the band that being read from the disk
|
||||
int key; // unique key for the table's scan context
|
||||
// @bug 626
|
||||
uint16_t saveFlag;
|
||||
int bandsInTable;
|
||||
};
|
||||
|
||||
struct cpsm_tid_t
|
||||
{
|
||||
cpsm_tid_t() : valid(false), value(0) {}
|
||||
bool valid;
|
||||
int value;
|
||||
cpsm_tid_t() : valid(false), value(0)
|
||||
{
|
||||
}
|
||||
bool valid;
|
||||
int value;
|
||||
};
|
||||
|
||||
extern status_t sm_init(uint32_t, cpsm_conhdl_t**, uint32_t columnstore_local_query = false);
|
||||
@ -281,10 +301,9 @@ extern status_t tpl_open(tableid_t, cpsm_tplh_t*, cpsm_conhdl_t*);
|
||||
extern status_t tpl_scan_open(tableid_t, sp_cpsm_tplsch_t&, cpsm_conhdl_t*);
|
||||
extern status_t tpl_scan_fetch(sp_cpsm_tplsch_t&, cpsm_conhdl_t*, int* k = 0);
|
||||
extern status_t tpl_scan_close(sp_cpsm_tplsch_t&);
|
||||
extern status_t tpl_close(cpsm_tplh_t*, cpsm_conhdl_t**, querystats::QueryStats& stats, bool ask_4_stats, bool clear_scan_ctx = false);
|
||||
extern status_t tpl_close(cpsm_tplh_t*, cpsm_conhdl_t**, querystats::QueryStats& stats, bool ask_4_stats,
|
||||
bool clear_scan_ctx = false);
|
||||
|
||||
}
|
||||
} // namespace sm
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user