You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-02 17:22:27 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -40,56 +40,96 @@ using namespace funcexp;
|
||||
|
||||
long long dateGet( uint64_t time, IntervalColumn::interval_type unit, bool dateType )
|
||||
{
|
||||
uint64_t year = 0,
|
||||
month = 0,
|
||||
day = 0,
|
||||
hour = 0,
|
||||
min = 0,
|
||||
sec = 0,
|
||||
msec = 0;
|
||||
uint64_t year = 0,
|
||||
month = 0,
|
||||
day = 0,
|
||||
hour = 0,
|
||||
min = 0,
|
||||
sec = 0,
|
||||
msec = 0;
|
||||
|
||||
if (dateType)
|
||||
{
|
||||
year = (uint32_t)((time >> 16) & 0xffff);
|
||||
month = (uint32_t)((time >> 12) & 0xf);
|
||||
day = (uint32_t)((time >> 6) & 0x3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
msec = (uint32_t)((time & 0xfffff));
|
||||
}
|
||||
if (dateType)
|
||||
{
|
||||
year = (uint32_t)((time >> 16) & 0xffff);
|
||||
month = (uint32_t)((time >> 12) & 0xf);
|
||||
day = (uint32_t)((time >> 6) & 0x3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
msec = (uint32_t)((time & 0xfffff));
|
||||
}
|
||||
|
||||
switch ( unit )
|
||||
{
|
||||
case IntervalColumn::INTERVAL_YEAR:
|
||||
return year;
|
||||
|
||||
case IntervalColumn::INTERVAL_MONTH:
|
||||
return month;
|
||||
|
||||
case IntervalColumn::INTERVAL_DAY:
|
||||
return day;
|
||||
|
||||
case IntervalColumn::INTERVAL_HOUR:
|
||||
return hour;
|
||||
|
||||
case IntervalColumn::INTERVAL_MINUTE:
|
||||
return min;
|
||||
|
||||
case IntervalColumn::INTERVAL_SECOND:
|
||||
return sec;
|
||||
|
||||
case IntervalColumn::INTERVAL_MICROSECOND:
|
||||
return msec;
|
||||
|
||||
case IntervalColumn::INTERVAL_QUARTER:
|
||||
return month / 4 + 1;
|
||||
|
||||
switch( unit ) {
|
||||
case IntervalColumn::INTERVAL_YEAR: return year;
|
||||
case IntervalColumn::INTERVAL_MONTH: return month;
|
||||
case IntervalColumn::INTERVAL_DAY: return day;
|
||||
case IntervalColumn::INTERVAL_HOUR: return hour;
|
||||
case IntervalColumn::INTERVAL_MINUTE: return min;
|
||||
case IntervalColumn::INTERVAL_SECOND: return sec;
|
||||
case IntervalColumn::INTERVAL_MICROSECOND: return msec;
|
||||
case IntervalColumn::INTERVAL_QUARTER: return month/4+1;
|
||||
case IntervalColumn::INTERVAL_WEEK:
|
||||
return helpers::calc_mysql_week(year, month, day, 0);
|
||||
case IntervalColumn::INTERVAL_YEAR_MONTH: return (year*100)+month;
|
||||
case IntervalColumn::INTERVAL_DAY_HOUR: return (day*100)+hour;
|
||||
case IntervalColumn::INTERVAL_DAY_MINUTE: return (day*10000)+(hour*100)+min;
|
||||
case IntervalColumn::INTERVAL_DAY_SECOND: return (day*1000000)+(hour*10000)+(min*100)+sec;
|
||||
case IntervalColumn::INTERVAL_HOUR_MINUTE: return (hour*100)+min;
|
||||
case IntervalColumn::INTERVAL_HOUR_SECOND: return (hour*10000)+(min*100)+sec;
|
||||
case IntervalColumn::INTERVAL_MINUTE_SECOND: return (min*100)+sec;
|
||||
case IntervalColumn::INTERVAL_DAY_MICROSECOND: return (((day*1000000)+(hour*10000)+(min*100)+sec)*1000000)+msec;
|
||||
case IntervalColumn::INTERVAL_HOUR_MICROSECOND: return (((hour*10000)+(min*100)+sec)*1000000)+msec;
|
||||
case IntervalColumn::INTERVAL_MINUTE_MICROSECOND: return (((min*100)+sec)*1000000)+msec;
|
||||
case IntervalColumn::INTERVAL_SECOND_MICROSECOND: return (sec*1000000)+msec;
|
||||
return helpers::calc_mysql_week(year, month, day, 0);
|
||||
|
||||
case IntervalColumn::INTERVAL_YEAR_MONTH:
|
||||
return (year * 100) + month;
|
||||
|
||||
case IntervalColumn::INTERVAL_DAY_HOUR:
|
||||
return (day * 100) + hour;
|
||||
|
||||
case IntervalColumn::INTERVAL_DAY_MINUTE:
|
||||
return (day * 10000) + (hour * 100) + min;
|
||||
|
||||
case IntervalColumn::INTERVAL_DAY_SECOND:
|
||||
return (day * 1000000) + (hour * 10000) + (min * 100) + sec;
|
||||
|
||||
case IntervalColumn::INTERVAL_HOUR_MINUTE:
|
||||
return (hour * 100) + min;
|
||||
|
||||
case IntervalColumn::INTERVAL_HOUR_SECOND:
|
||||
return (hour * 10000) + (min * 100) + sec;
|
||||
|
||||
case IntervalColumn::INTERVAL_MINUTE_SECOND:
|
||||
return (min * 100) + sec;
|
||||
|
||||
case IntervalColumn::INTERVAL_DAY_MICROSECOND:
|
||||
return (((day * 1000000) + (hour * 10000) + (min * 100) + sec) * 1000000) + msec;
|
||||
|
||||
case IntervalColumn::INTERVAL_HOUR_MICROSECOND:
|
||||
return (((hour * 10000) + (min * 100) + sec) * 1000000) + msec;
|
||||
|
||||
case IntervalColumn::INTERVAL_MINUTE_MICROSECOND:
|
||||
return (((min * 100) + sec) * 1000000) + msec;
|
||||
|
||||
case IntervalColumn::INTERVAL_SECOND_MICROSECOND:
|
||||
return (sec * 1000000) + msec;
|
||||
|
||||
default:
|
||||
throw runtime_error("unit type is not supported: " + unit);
|
||||
};
|
||||
throw runtime_error("unit type is not supported: " + unit);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,49 +138,52 @@ namespace funcexp
|
||||
|
||||
CalpontSystemCatalog::ColType Func_extract::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
|
||||
{
|
||||
return resultType;
|
||||
return resultType;
|
||||
}
|
||||
|
||||
int64_t Func_extract::getIntVal(rowgroup::Row& row,
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
IntervalColumn::interval_type unit = static_cast<IntervalColumn::interval_type>(parm[1]->data()->getIntVal(row, isNull));
|
||||
uint64_t time;
|
||||
|
||||
//@bug4678 handle conversion from non date/datetime datatype
|
||||
switch (parm[0]->data()->resultType().colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::DATE:
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
time = parm[0]->data()->getDatetimeIntVal(row, isNull);
|
||||
break;
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
const string& val = parm[0]->data()->getStrVal(row, isNull);
|
||||
time = dataconvert::DataConvert::stringToDatetime(val);
|
||||
break;
|
||||
}
|
||||
case CalpontSystemCatalog::INT:
|
||||
case CalpontSystemCatalog::TINYINT:
|
||||
case CalpontSystemCatalog::MEDINT:
|
||||
case CalpontSystemCatalog::BIGINT:
|
||||
case CalpontSystemCatalog::SMALLINT:
|
||||
{
|
||||
int64_t val = parm[0]->data()->getIntVal(row, isNull);
|
||||
time = dataconvert::DataConvert::intToDatetime(val);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
time = parm[0]->data()->getIntVal(row, isNull);
|
||||
}
|
||||
uint64_t time;
|
||||
|
||||
long long value = dateGet( time, unit, false );
|
||||
//@bug4678 handle conversion from non date/datetime datatype
|
||||
switch (parm[0]->data()->resultType().colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::DATE:
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
time = parm[0]->data()->getDatetimeIntVal(row, isNull);
|
||||
break;
|
||||
|
||||
return value;
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
const string& val = parm[0]->data()->getStrVal(row, isNull);
|
||||
time = dataconvert::DataConvert::stringToDatetime(val);
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::INT:
|
||||
case CalpontSystemCatalog::TINYINT:
|
||||
case CalpontSystemCatalog::MEDINT:
|
||||
case CalpontSystemCatalog::BIGINT:
|
||||
case CalpontSystemCatalog::SMALLINT:
|
||||
{
|
||||
int64_t val = parm[0]->data()->getIntVal(row, isNull);
|
||||
time = dataconvert::DataConvert::intToDatetime(val);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
time = parm[0]->data()->getIntVal(row, isNull);
|
||||
}
|
||||
|
||||
long long value = dateGet( time, unit, false );
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user