You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-10-22 22:32:34 +03:00
Reformat all code to coding standard
This commit is contained in:
@@ -44,130 +44,137 @@ namespace funcexp
|
||||
|
||||
CalpontSystemCatalog::ColType Func_bitand::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
|
||||
{
|
||||
return resultType;
|
||||
return resultType;
|
||||
}
|
||||
|
||||
int64_t Func_bitand::getIntVal(Row& row,
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& operationColType)
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& operationColType)
|
||||
{
|
||||
|
||||
vector<int64_t> values;
|
||||
vector<int64_t> values;
|
||||
|
||||
if ( parm.size() < 2 ) {
|
||||
isNull = true;
|
||||
return 0;
|
||||
}
|
||||
if ( parm.size() < 2 )
|
||||
{
|
||||
isNull = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < parm.size(); i++)
|
||||
{
|
||||
switch (parm[i]->data()->resultType().colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
for (uint32_t i = 0; i < parm.size(); i++)
|
||||
{
|
||||
switch (parm[i]->data()->resultType().colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
case execplan::CalpontSystemCatalog::UTINYINT:
|
||||
case execplan::CalpontSystemCatalog::USMALLINT:
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||
case execplan::CalpontSystemCatalog::UFLOAT:
|
||||
{
|
||||
values.push_back(parm[i]->data()->getIntVal(row, isNull));
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
int64_t value = parm[i]->data()->getIntVal(row, isNull);
|
||||
if (isNull)
|
||||
{
|
||||
isNull = true;
|
||||
return value;
|
||||
}
|
||||
values.push_back(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
IDB_Decimal d = parm[i]->data()->getDecimalVal(row, isNull);
|
||||
int64_t value = d.value / power(d.scale);
|
||||
int lefto = (d.value - value * power(d.scale)) / power(d.scale-1);
|
||||
if ( value >= 0 && lefto > 4 )
|
||||
value++;
|
||||
if ( value < 0 && lefto < -4 )
|
||||
value--;
|
||||
values.push_back(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
{
|
||||
int64_t time = parm[i]->data()->getDateIntVal(row, isNull);
|
||||
|
||||
int32_t year = 0,
|
||||
month = 0,
|
||||
day = 0;
|
||||
|
||||
year = (uint32_t)((time >> 16) & 0xffff);
|
||||
month = (uint32_t)((time >> 12) & 0xf);
|
||||
day = (uint32_t)((time >> 6) & 0x3f);
|
||||
|
||||
values.push_back((year*10000)+(month*100)+day);
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATETIME:
|
||||
{
|
||||
int64_t time = parm[i]->data()->getDatetimeIntVal(row, isNull);
|
||||
|
||||
int32_t year = 0,
|
||||
month = 0,
|
||||
day = 0,
|
||||
hour = 0,
|
||||
min = 0,
|
||||
sec = 0;
|
||||
|
||||
year = (uint32_t)((time >> 48) & 0xffff);
|
||||
month = (uint32_t)((time >> 44) & 0xf);
|
||||
day = (uint32_t)((time >> 38) & 0x3f);
|
||||
hour = (uint32_t)((time >> 32) & 0x3f);
|
||||
min = (uint32_t)((time >> 26) & 0x3f);
|
||||
sec = (uint32_t)((time >> 20) & 0x3f);
|
||||
|
||||
// return (int64_t) (year*1000000000000)+(month*100000000)+(day*1000000)+(hour*10000)+(min*100)+sec;
|
||||
values.push_back((month*100000000)+(day*1000000)+(hour*10000)+(min*100)+sec);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "bitand: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
|
||||
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
values.push_back(parm[i]->data()->getIntVal(row, isNull));
|
||||
}
|
||||
break;
|
||||
|
||||
vector<int64_t>::iterator p = values.begin();
|
||||
int64_t retValue = *p;
|
||||
p++;
|
||||
while ( p != values.end() )
|
||||
{
|
||||
retValue = retValue & *p;
|
||||
p++;
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
int64_t value = parm[i]->data()->getIntVal(row, isNull);
|
||||
|
||||
return retValue;
|
||||
if (isNull)
|
||||
{
|
||||
isNull = true;
|
||||
return value;
|
||||
}
|
||||
|
||||
values.push_back(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
IDB_Decimal d = parm[i]->data()->getDecimalVal(row, isNull);
|
||||
int64_t value = d.value / power(d.scale);
|
||||
int lefto = (d.value - value * power(d.scale)) / power(d.scale - 1);
|
||||
|
||||
if ( value >= 0 && lefto > 4 )
|
||||
value++;
|
||||
|
||||
if ( value < 0 && lefto < -4 )
|
||||
value--;
|
||||
|
||||
values.push_back(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
{
|
||||
int64_t time = parm[i]->data()->getDateIntVal(row, isNull);
|
||||
|
||||
int32_t year = 0,
|
||||
month = 0,
|
||||
day = 0;
|
||||
|
||||
year = (uint32_t)((time >> 16) & 0xffff);
|
||||
month = (uint32_t)((time >> 12) & 0xf);
|
||||
day = (uint32_t)((time >> 6) & 0x3f);
|
||||
|
||||
values.push_back((year * 10000) + (month * 100) + day);
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATETIME:
|
||||
{
|
||||
int64_t time = parm[i]->data()->getDatetimeIntVal(row, isNull);
|
||||
|
||||
int32_t year = 0,
|
||||
month = 0,
|
||||
day = 0,
|
||||
hour = 0,
|
||||
min = 0,
|
||||
sec = 0;
|
||||
|
||||
year = (uint32_t)((time >> 48) & 0xffff);
|
||||
month = (uint32_t)((time >> 44) & 0xf);
|
||||
day = (uint32_t)((time >> 38) & 0x3f);
|
||||
hour = (uint32_t)((time >> 32) & 0x3f);
|
||||
min = (uint32_t)((time >> 26) & 0x3f);
|
||||
sec = (uint32_t)((time >> 20) & 0x3f);
|
||||
|
||||
// return (int64_t) (year*1000000000000)+(month*100000000)+(day*1000000)+(hour*10000)+(min*100)+sec;
|
||||
values.push_back((month * 100000000) + (day * 1000000) + (hour * 10000) + (min * 100) + sec);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "bitand: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
|
||||
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<int64_t>::iterator p = values.begin();
|
||||
int64_t retValue = *p;
|
||||
p++;
|
||||
|
||||
while ( p != values.end() )
|
||||
{
|
||||
retValue = retValue & *p;
|
||||
p++;
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user