|
Covalent Bond
0.0.1-alpha
'covalent bond' is a data middle office. As a 2022-2023 Fall SWE final project.
|
Go to the documentation of this file.
12 #include <workflow/MySQLResult.h>
54 if (cursor->get_cursor_status() == MYSQL_STATUS_GET_RESULT) {
58 const protocol::MySQLField*
const* __tmpCursorFieldPtr =
59 cursor->fetch_fields();
66 std::vector<std::vector<protocol::MySQLCell>> __data;
67 cursor->fetch_all(__data);
68 m_shape[0] = cursor->get_rows_count();
69 m_shape[1] =
static_cast<int32_t
>(__data[0].size());
71 for (int32_t i = 0; i <
m_shape[0]; ++i) {
72 for (int32_t j = 0; j <
m_shape[1]; ++j) {
m_data[i][j] = __data[i][j]; }
84 for (
auto& item :
m_data) {
102 for (
auto& item :
m_data) {
104 item.shrink_to_fit();
135 if (i >= 0 && i <
m_shape[0]) [[likely]] {
138 for (int32_t c = 0; c < col; ++c) { tmp.
atPtrRef(0, c) = this->
atPtrRef(i, c); }
146 if (i >= 0 && i <
m_shape[1]) [[likely]] {
149 for (int32_t r = 0; r < row; ++r) { tmp.
atPtrRef(r, 0) = this->
atPtrRef(r, i); }
157 std::map<int32_t, int32_t> tmp;
162 std::hash<std::string> hash_string;
163 [[maybe_unused]] std::hash<float> hash_float;
164 [[maybe_unused]] std::hash<double> hash_double;
165 [[maybe_unused]] std::hash<int> hash_int;
166 [[maybe_unused]] std::hash<unsigned long long> hash_ull;
169 for (atCol = 0; atCol < col; ++atCol) {
170 if (
m_info[atCol]->getName() == colName)
break;
172 if (atCol == col) [[unlikely]] {
return tmp; }
173 for (int32_t r = 0; r < row; ++r) {
174 switch (
m_data[r][atCol]->getType()) {
190 if (row.size() !=
m_shape[1]) [[unlikely]] {
return; }
200 fmt::print(fg(fmt::color::hot_pink) | fmt::emphasis::italic,
"<Table, row={}, col={}>\n",
227 std::stringstream ss;
228 ss <<
m_info[col].getTable() <<
":" << row <<
":" <<
m_info[col].getName();
234 int32_t row = virtualT->
getShape()[0];
235 int32_t col = virtualT->
getShape()[1];
240 for (int32_t i = 0; i < row; ++i) {
241 for (int32_t j = 0; j < col; ++j) { virtualT->
atPtrRef(i, j) = sharedT->
atPtr(i, j); }
248 m_name = wfPtr->get_name();
252 m_db = wfPtr->get_db();
254 m_def = wfPtr->get_def();
310 }
else if (m.is_datetime()) {
313 }
else if (m.is_time()) {
316 }
else if (m.is_float()) {
319 }
else if (m.is_double()) {
322 }
else if (m.is_int()) {
325 }
else if (m.is_string()) {
328 }
else if (m.is_ulonglong()) {
330 m_data = m.as_ulonglong();
339 default:
return false;
break;
346 default:
return false;
break;
356 default:
return false;
break;
363 default:
return false;
break;
370 default:
return false;
break;
377 default:
return false;
break;
384 default:
return false;
break;
391 default:
return false;
break;
398 default:
return false;
break;
423 if (
isULL()) {
return std::get<unsigned long long>(
m_data); }
std::vector< cbMySQLField > m_info
std::vector< std::string > __luaPackedStringAsVec()
cbVirtualSharedTable()=default
Construct a new cb Virtual Shared Table object.
std::string getName() const
std::string genKey4Redis(int32_t row, int32_t col)
void setDataType(int32_t value)
void setAsCppBool(bool rhs)
std::string colTypeAt(int32_t i)
std::string asDate() const
cbMySQLCell * atPtr(int32_t i, int32_t j)
row major
cbMySQLField * getInfoAt(int32_t i)
Get the Info At object.
cbMySQLField ** getInfo()
Get the Info object.
cbVirtualTable works as a reference from shared memory. It only use a shape and SqlCell to define dif...
void setDate(const std::string &value)
std::string getTable() const
cbVirtualTable getRow(int32_t i)
Get the Row object.
the virtual table and shared table.
cbMySQLField()
Construct a new cb My S Q L Field object.
void setTime(const std::string &value)
void setAsCppInt(int32_t rhs)
A copy move from workflow MySQLResult.h and .inl file.
cbMySQLCell * atPtr(int32_t i, int32_t j)
void setAsLuaBool(sol::object rhs)
void resetShape(cbShape< 2 > &shape)
std::string asTime() const
void setPtrAt(int32_t i, int32_t j, cbMySQLCell *v)
Set the Ptr At object.
void setAsCppFloat(float rhs)
cbMySQLCell * atPtrRef(int32_t i, int32_t j)
void update(const cbShape< 2 > &shape, cbMySQLField **info)
void resetShapeH(const cbShape< 2 > &shape)
void setDatetime(const std::string &value)
void mapShared2Virtual(cbVirtualSharedTable *sharedT, cbVirtualTable *virtualT)
void pushRow(const std::vector< cbMySQLCell * > &row)
void setInfoAt(int32_t i, cbMySQLField *v)
Set the Info At object.
cbVirtualTable getCol(int32_t i)
Get the Col object.
unsigned long long asULL() const
void setTable(const std::string &value)
void setOrgName(const std::string &value)
void setDef(const std::string &value)
std::string getOrgTable() const
void setDB(const std::string &value)
std::string getDef() const
void setFloat(float value)
void setLength(int32_t value)
std::string getOrgName() const
std::vector< std::vector< cbMySQLCell * > > m_data
void setName(const std::string &value)
~cbVirtualSharedTable()
Destroy the cb Virtual Shared Table object.
void setCatalog(const std::string &value)
cbMySQLField ** getInfo()
Get the Info object.
cbVirtualSharedTable is a container of shared memory.
void setString(const std::string &value)
const cbShape< 2 > getShape() const
Get the Shape object.
void resetFieldInfo(int32_t fieldCount, cbMySQLField **info)
cbMySQLCell *& atPtrRef(int32_t i, int32_t j)
void setAsCppString(std::string rhs)
void setDecimals(int32_t value)
std::vector< std::vector< cbMySQLCell * > > & getData()
Get the Data object.
std::string getDB() const
std::string colNameAt(int32_t i)
std::vector< std::vector< cbMySQLCell > > m_data
void resetShape(const cbShape< 2 > &shape)
std::string asDatetime() const
cbShape< 2 > makeShapeFull(int32_t a, int32_t b)
void setCharsetnr(int32_t value)
void setAsLuaInt(sol::object rhs)
void setAsLuaString(sol::object rhs)
void setFlags(int32_t value)
void setAsLuaFloat(sol::object rhs)
cbOutputTableStruct()=delete
void setDouble(double value)
std::vector< cbMySQLCell * > __luaPackedCellAsVec(cbMySQLCell *v)
void setOrgTable(const std::string &value)
cbShape< 2 > getShape()
Get the Shape object.
std::map< int32_t, int32_t > keyBy(const std::string &colName) const
std::string asString() const
std::string getCatalog() const
void setInfo(cbMySQLField **v)
Set the Info object.
void setULL(unsigned long long value)