1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-04 04:42:30 +03:00

MCOL-392 Apply astyle

Make this branch apply our style guidelines
This commit is contained in:
Andrew Hutchings
2018-05-01 09:52:26 +01:00
parent 4ef4286022
commit c40903de9b
31 changed files with 176 additions and 123 deletions

View File

@ -606,6 +606,7 @@ void SimpleFilter::convertConstant()
result.intVal = dataconvert::DataConvert::timeToInt(result.strVal); result.intVal = dataconvert::DataConvert::timeToInt(result.strVal);
} }
} }
rcc->result(result); rcc->result(result);
} }
} }

View File

@ -995,6 +995,7 @@ inline int64_t TreeNode::getDatetimeIntVal()
int day = 0; int day = 0;
memcpy(&tt, &fResult.intVal, 8); memcpy(&tt, &fResult.intVal, 8);
// Note, this should probably be current date +/- time // Note, this should probably be current date +/- time
if ((tt.hour > 23) && (!tt.is_neg)) if ((tt.hour > 23) && (!tt.is_neg))
{ {
@ -1005,6 +1006,7 @@ inline int64_t TreeNode::getDatetimeIntVal()
{ {
tt.hour = 0; tt.hour = 0;
} }
dataconvert::DateTime dt(0, 0, day, tt.hour, tt.minute, tt.second, tt.msecond); dataconvert::DateTime dt(0, 0, day, tt.hour, tt.minute, tt.second, tt.msecond);
memcpy(&fResult.intVal, &dt, 8); memcpy(&fResult.intVal, &dt, 8);
return fResult.intVal; return fResult.intVal;

View File

@ -648,10 +648,12 @@ int64_t GroupConcator::lengthEstimate(const rowgroup::Row& row)
fieldLen = 19; // YYYY-MM-DD HH24:MI:SS fieldLen = 19; // YYYY-MM-DD HH24:MI:SS
// Decimal point and milliseconds // Decimal point and milliseconds
uint64_t colPrecision = row.getPrecision(*i); uint64_t colPrecision = row.getPrecision(*i);
if (colPrecision > 0 && colPrecision < 7) if (colPrecision > 0 && colPrecision < 7)
{ {
fieldLen += colPrecision + 1; fieldLen += colPrecision + 1;
} }
break; break;
} }
@ -660,10 +662,12 @@ int64_t GroupConcator::lengthEstimate(const rowgroup::Row& row)
fieldLen = 10; // -HHH:MI:SS fieldLen = 10; // -HHH:MI:SS
// Decimal point and milliseconds // Decimal point and milliseconds
uint64_t colPrecision = row.getPrecision(*i); uint64_t colPrecision = row.getPrecision(*i);
if (colPrecision > 0 && colPrecision < 7) if (colPrecision > 0 && colPrecision < 7)
{ {
fieldLen += colPrecision + 1; fieldLen += colPrecision + 1;
} }
break; break;
} }

View File

@ -842,6 +842,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_
const uchar* pos = buf; const uchar* pos = buf;
longlong tmp = my_datetime_packed_from_binary(pos, table->field[colpos]->decimals()); longlong tmp = my_datetime_packed_from_binary(pos, table->field[colpos]->decimals());
TIME_from_longlong_datetime_packed(&ltime, tmp); TIME_from_longlong_datetime_packed(&ltime, tmp);
if (!ltime.second_part) if (!ltime.second_part)
{ {
fprintf(ci.filePtr, "%04d-%02d-%02d %02d:%02d:%02d%c", fprintf(ci.filePtr, "%04d-%02d-%02d %02d:%02d:%02d%c",
@ -855,6 +856,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_
ltime.hour, ltime.minute, ltime.second, ltime.hour, ltime.minute, ltime.second,
ltime.second_part, ci.delimiter); ltime.second_part, ci.delimiter);
} }
buf += table->field[colpos]->pack_length(); buf += table->field[colpos]->pack_length();
} }
else else
@ -892,6 +894,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_
const uchar* pos = buf; const uchar* pos = buf;
longlong tmp = my_time_packed_from_binary(pos, table->field[colpos]->decimals()); longlong tmp = my_time_packed_from_binary(pos, table->field[colpos]->decimals());
TIME_from_longlong_time_packed(&ltime, tmp); TIME_from_longlong_time_packed(&ltime, tmp);
if (!ltime.second_part) if (!ltime.second_part)
{ {
fprintf(ci.filePtr, "%02d:%02d:%02d%c", fprintf(ci.filePtr, "%02d:%02d:%02d%c",
@ -903,6 +906,7 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_
ltime.hour, ltime.minute, ltime.second, ltime.hour, ltime.minute, ltime.second,
ltime.second_part, ci.delimiter); ltime.second_part, ci.delimiter);
} }
buf += table->field[colpos]->pack_length(); buf += table->field[colpos]->pack_length();
} }

View File

@ -1020,6 +1020,7 @@ bool mysql_str_to_time( const string& input, Time& output )
{ {
output.reset(); output.reset();
} }
return false; return false;
} }
@ -1918,6 +1919,7 @@ int64_t DataConvert::convertColumnTime(
inSecond = 0; inSecond = 0;
inMicrosecond = 0; inMicrosecond = 0;
bool isNeg = false; bool isNeg = false;
if ( datetimeFormat != CALPONTTIME_ENUM ) if ( datetimeFormat != CALPONTTIME_ENUM )
{ {
status = -1; status = -1;
@ -1941,6 +1943,7 @@ int64_t DataConvert::convertColumnTime(
} }
p = strtok_r(NULL, ":.", &savePoint); p = strtok_r(NULL, ":.", &savePoint);
if (p == NULL) if (p == NULL)
{ {
status = -1; status = -1;
@ -1976,6 +1979,7 @@ int64_t DataConvert::convertColumnTime(
if (p != NULL) if (p != NULL)
{ {
inMicrosecond = strtol(p, 0, 10); inMicrosecond = strtol(p, 0, 10);
if (errno) if (errno)
{ {
status = -1; status = -1;
@ -2017,6 +2021,7 @@ int64_t DataConvert::convertColumnTime(
atime.is_neg = false; atime.is_neg = false;
memcpy( &value, &atime, 8); memcpy( &value, &atime, 8);
} }
// If neither of the above match then we return a 0 time // If neither of the above match then we return a 0 time
status = -1; status = -1;
@ -2067,21 +2072,25 @@ std::string DataConvert::datetimeToString( long long datetimevalue, long decima
{ {
decimals = 0; decimals = 0;
} }
// @bug 4703 abandon multiple ostringstream's for conversion // @bug 4703 abandon multiple ostringstream's for conversion
DateTime dt(datetimevalue); DateTime dt(datetimevalue);
const int DATETIMETOSTRING_LEN = 28; // YYYY-MM-DD HH:MM:SS.mmmmmm\0 const int DATETIMETOSTRING_LEN = 28; // YYYY-MM-DD HH:MM:SS.mmmmmm\0
char buf[DATETIMETOSTRING_LEN]; char buf[DATETIMETOSTRING_LEN];
sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second); sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
if (dt.msecond && decimals) if (dt.msecond && decimals)
{ {
snprintf(buf + strlen(buf), 21 + decimals, ".%d", dt.msecond); snprintf(buf + strlen(buf), 21 + decimals, ".%d", dt.msecond);
// Pad end with zeros // Pad end with zeros
if (strlen(buf) < (size_t)(21 + decimals)) if (strlen(buf) < (size_t)(21 + decimals))
{ {
sprintf(buf + strlen(buf), "%0*d", (int)(21 + decimals - strlen(buf)), 0); sprintf(buf + strlen(buf), "%0*d", (int)(21 + decimals - strlen(buf)), 0);
} }
} }
return buf; return buf;
} }
@ -2092,6 +2101,7 @@ std::string DataConvert::timeToString( long long timevalue, long decimals )
{ {
decimals = 0; decimals = 0;
} }
// @bug 4703 abandon multiple ostringstream's for conversion // @bug 4703 abandon multiple ostringstream's for conversion
Time dt(timevalue); Time dt(timevalue);
const int TIMETOSTRING_LEN = 19; // (-H)HH:MM:SS.mmmmmm\0 const int TIMETOSTRING_LEN = 19; // (-H)HH:MM:SS.mmmmmm\0
@ -2105,16 +2115,19 @@ std::string DataConvert::timeToString( long long timevalue, long decimals )
} }
sprintf(outbuf, "%02d:%02d:%02d", dt.hour, dt.minute, dt.second); sprintf(outbuf, "%02d:%02d:%02d", dt.hour, dt.minute, dt.second);
if (dt.msecond && decimals) if (dt.msecond && decimals)
{ {
size_t start = strlen(buf); size_t start = strlen(buf);
snprintf(buf + strlen(buf), 12 + decimals, ".%d", dt.msecond); snprintf(buf + strlen(buf), 12 + decimals, ".%d", dt.msecond);
// Pad end with zeros // Pad end with zeros
if (strlen(buf) - start < (size_t)decimals) if (strlen(buf) - start < (size_t)decimals)
{ {
sprintf(buf + strlen(buf), "%0*d", (int)(decimals - (strlen(buf) - start) + 1), 0); sprintf(buf + strlen(buf), "%0*d", (int)(decimals - (strlen(buf) - start) + 1), 0);
} }
} }
return buf; return buf;
} }

View File

@ -277,6 +277,7 @@ inline uint32_t getDaysInMonth(uint32_t month, int year)
return 0; return 0;
uint32_t days = daysInMonth[month - 1]; uint32_t days = daysInMonth[month - 1];
if ((month == 2) && isLeapYear(year)) if ((month == 2) && isLeapYear(year))
days++; days++;
@ -567,11 +568,14 @@ inline void DataConvert::datetimeToString( long long datetimevalue, char* buf, u
{ {
decimals = 0; decimals = 0;
} }
int msec = 0; int msec = 0;
if ((datetimevalue & 0xfffff) > 0) if ((datetimevalue & 0xfffff) > 0)
{ {
msec = (unsigned)((datetimevalue) & 0xfffff); msec = (unsigned)((datetimevalue) & 0xfffff);
} }
snprintf( buf, buflen, "%04d-%02d-%02d %02d:%02d:%02d", snprintf( buf, buflen, "%04d-%02d-%02d %02d:%02d:%02d",
(unsigned)((datetimevalue >> 48) & 0xffff), (unsigned)((datetimevalue >> 48) & 0xffff),
(unsigned)((datetimevalue >> 44) & 0xf), (unsigned)((datetimevalue >> 44) & 0xf),
@ -585,6 +589,7 @@ inline void DataConvert::datetimeToString( long long datetimevalue, char* buf, u
{ {
size_t start = strlen(buf); size_t start = strlen(buf);
snprintf(buf + strlen(buf), buflen - start, ".%d", msec); snprintf(buf + strlen(buf), buflen - start, ".%d", msec);
// Pad end with zeros // Pad end with zeros
if (strlen(buf) - start < (size_t)decimals) if (strlen(buf) - start < (size_t)decimals)
{ {
@ -600,8 +605,10 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
{ {
decimals = 0; decimals = 0;
} }
// Handle negative correctly // Handle negative correctly
int hour = 0, msec = 0; int hour = 0, msec = 0;
if ((timevalue >> 40) & 0x800) if ((timevalue >> 40) & 0x800)
{ {
hour = 0xfffff000; hour = 0xfffff000;
@ -613,12 +620,14 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
{ {
msec = (unsigned)((timevalue) & 0xffffff); msec = (unsigned)((timevalue) & 0xffffff);
} }
if ((hour >= 0) && (timevalue >> 63)) if ((hour >= 0) && (timevalue >> 63))
{ {
buf[0] = '-'; buf[0] = '-';
buf++; buf++;
buflen--; buflen--;
} }
snprintf( buf, buflen, "%02d:%02d:%02d", snprintf( buf, buflen, "%02d:%02d:%02d",
hour, hour,
(unsigned)((timevalue >> 32) & 0xff), (unsigned)((timevalue >> 32) & 0xff),
@ -629,6 +638,7 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
{ {
size_t start = strlen(buf); size_t start = strlen(buf);
snprintf(buf + strlen(buf), buflen - start, ".%d", msec); snprintf(buf + strlen(buf), buflen - start, ".%d", msec);
// Pad end with zeros // Pad end with zeros
if (strlen(buf) - start < (size_t)decimals) if (strlen(buf) - start < (size_t)decimals)
{ {
@ -662,6 +672,7 @@ inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned
{ {
// Handle negative correctly // Handle negative correctly
int hour = 0; int hour = 0;
if ((timevalue >> 40) & 0x800) if ((timevalue >> 40) & 0x800)
{ {
hour = 0xfffff000; hour = 0xfffff000;

View File

@ -165,6 +165,7 @@ int64_t Func_bitand::getIntVal(Row& row,
min = 0, min = 0,
sec = 0, sec = 0,
msec = 0; msec = 0;
// Handle negative correctly // Handle negative correctly
if ((time >> 40) & 0x800) if ((time >> 40) & 0x800)
{ {
@ -172,8 +173,10 @@ int64_t Func_bitand::getIntVal(Row& row,
} }
hour |= ((time >> 40) & 0xfff); hour |= ((time >> 40) & 0xfff);
if ((hour >= 0) && (time >> 63)) if ((hour >= 0) && (time >> 63))
hour *= -1; hour *= -1;
min = (uint32_t)((time >> 32) & 0xff); min = (uint32_t)((time >> 32) & 0xff);
sec = (uint32_t)((time >> 24) & 0xff); sec = (uint32_t)((time >> 24) & 0xff);
msec = (uint32_t)(time & 0xffffff); msec = (uint32_t)(time & 0xffffff);

View File

@ -146,8 +146,10 @@ long long timeGet( uint64_t time, IntervalColumn::interval_type unit )
// If negative, mask so it doesn't turn positive // If negative, mask so it doesn't turn positive
int64_t mask = 0; int64_t mask = 0;
if ((time >> 40) & 0x800) if ((time >> 40) & 0x800)
mask = 0xfffffffffffff000; mask = 0xfffffffffffff000;
hour = mask | ((time >> 40) & 0xfff); hour = mask | ((time >> 40) & 0xfff);
if ((hour >= 0) && (time >> 63)) if ((hour >= 0) && (time >> 63))
@ -275,6 +277,7 @@ int64_t Func_extract::getIntVal(rowgroup::Row& row,
} }
long long value; long long value;
if (isTime) if (isTime)
value = timeGet( time, unit ); value = timeGet( time, unit );
else else

View File

@ -130,6 +130,7 @@ int64_t Func_hour::getIntVal(rowgroup::Row& row,
// If negative, mask so it doesn't turn positive // If negative, mask so it doesn't turn positive
bool isNeg = false; bool isNeg = false;
int64_t mask = 0; int64_t mask = 0;
if ((val >> 40) & 0x800) if ((val >> 40) & 0x800)
mask = 0xfffffffffffff000; mask = 0xfffffffffffff000;
@ -137,7 +138,9 @@ int64_t Func_hour::getIntVal(rowgroup::Row& row,
{ {
isNeg = true; isNeg = true;
} }
val = mask | ((val >> 40) & 0xfff); val = mask | ((val >> 40) & 0xfff);
if (isNeg) if (isNeg)
val *= -1; val *= -1;
} }

View File

@ -111,6 +111,7 @@ string Func_time::getStrVal(rowgroup::Row& row,
val = parm[0]->data()->getTimeIntVal(row, isNull); val = parm[0]->data()->getTimeIntVal(row, isNull);
break; break;
} }
case execplan::CalpontSystemCatalog::DATETIME: case execplan::CalpontSystemCatalog::DATETIME:
{ {
val = parm[0]->data()->getTimeIntVal(row, isNull); val = parm[0]->data()->getTimeIntVal(row, isNull);

View File

@ -72,16 +72,19 @@ int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row,
case CalpontSystemCatalog::TIME: case CalpontSystemCatalog::TIME:
val = parm[0]->data()->getTimeIntVal(row, isNull); val = parm[0]->data()->getTimeIntVal(row, isNull);
// If negative, mask so it doesn't turn positive // If negative, mask so it doesn't turn positive
if ((val >> 40) & 0x800) if ((val >> 40) & 0x800)
mask = 0xfffffffffffff000; mask = 0xfffffffffffff000;
bIsNegative = val >> 63; bIsNegative = val >> 63;
hour = (int32_t)(mask | ((val >> 40) & 0xfff)); hour = (int32_t)(mask | ((val >> 40) & 0xfff));
if ((hour >= 0) && bIsNegative) if ((hour >= 0) && bIsNegative)
hour *= -1; hour *= -1;
else else
bIsNegative = false; bIsNegative = false;
min = (int32_t)((val >> 32) & 0xff); min = (int32_t)((val >> 32) & 0xff);
sec = (int32_t)((val >> 24) & 0xff); sec = (int32_t)((val >> 24) & 0xff);
break; break;
@ -162,6 +165,7 @@ int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row,
} }
int64_t rtn; int64_t rtn;
if (hour < 0) if (hour < 0)
{ {
rtn = (int64_t)(hour * 60 * 60) - (min * 60) - sec; rtn = (int64_t)(hour * 60 * 60) - (min * 60) - sec;

View File

@ -208,7 +208,8 @@ public:
int64_t getTimeIntVal(rowgroup::Row& row, int64_t getTimeIntVal(rowgroup::Row& row,
FunctionParm& fp, FunctionParm& fp,
bool& isNull, bool& isNull,
execplan::CalpontSystemCatalog::ColType& op_ct);}; execplan::CalpontSystemCatalog::ColType& op_ct);
};
/** @brief Func_ifnull class /** @brief Func_ifnull class
@ -359,7 +360,8 @@ public:
int64_t getTimeIntVal(rowgroup::Row& row, int64_t getTimeIntVal(rowgroup::Row& row,
FunctionParm& fp, FunctionParm& fp,
bool& isNull, bool& isNull,
execplan::CalpontSystemCatalog::ColType& op_ct);}; execplan::CalpontSystemCatalog::ColType& op_ct);
};
/** @brief Func_coalesce class /** @brief Func_coalesce class

View File

@ -1543,6 +1543,7 @@ void RowAggregation::doBitOp(const Row& rowIn, int64_t colIn, int64_t colOut, in
int64_t dtm = rowIn.getUintField(colIn); int64_t dtm = rowIn.getUintField(colIn);
// Handle negative correctly // Handle negative correctly
int hour = 0; int hour = 0;
if ((dtm >> 40) & 0x800) if ((dtm >> 40) & 0x800)
{ {
hour = 0xfffff000; hour = 0xfffff000;
@ -2077,6 +2078,7 @@ void RowAggregation::doUDAF(const Row& rowIn, int64_t colIn, int64_t colOut, int
datum.columnData = rowIn.getUintField(colIn); datum.columnData = rowIn.getUintField(colIn);
break; break;
} }
case execplan::CalpontSystemCatalog::TIME: case execplan::CalpontSystemCatalog::TIME:
{ {
datum.dataType = execplan::CalpontSystemCatalog::BIGINT; datum.dataType = execplan::CalpontSystemCatalog::BIGINT;