1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -59,17 +59,17 @@ namespace joblist
{
TupleHavingStep::TupleHavingStep(const JobInfo& jobInfo) :
ExpressionStep(jobInfo),
fInputDL(NULL),
fOutputDL(NULL),
fInputIterator(0),
fRunner(0),
fRowsReturned(0),
fEndOfResult(false),
fFeInstance(funcexp::FuncExp::instance())
ExpressionStep(jobInfo),
fInputDL(NULL),
fOutputDL(NULL),
fInputIterator(0),
fRunner(0),
fRowsReturned(0),
fEndOfResult(false),
fFeInstance(funcexp::FuncExp::instance())
{
fExtendedInfo = "HVS: ";
fQtc.stepParms().stepType = StepTeleStats::T_HVS;
fExtendedInfo = "HVS: ";
fQtc.stepParms().stepType = StepTeleStats::T_HVS;
}
@ -86,341 +86,356 @@ void TupleHavingStep::setOutputRowGroup(const rowgroup::RowGroup& rg)
void TupleHavingStep::initialize(const RowGroup& rgIn, const JobInfo& jobInfo)
{
fRowGroupIn = rgIn;
fRowGroupIn.initRow(&fRowIn);
fRowGroupIn = rgIn;
fRowGroupIn.initRow(&fRowIn);
map<uint32_t, uint32_t> keyToIndexMap;
for (uint64_t i = 0; i < fRowGroupIn.getKeys().size(); ++i)
if (keyToIndexMap.find(fRowGroupIn.getKeys()[i]) == keyToIndexMap.end())
keyToIndexMap.insert(make_pair(fRowGroupIn.getKeys()[i], i));
updateInputIndex(keyToIndexMap, jobInfo);
map<uint32_t, uint32_t> keyToIndexMap;
vector<uint32_t> oids, oidsIn = fRowGroupIn.getOIDs();
vector<uint32_t> keys, keysIn = fRowGroupIn.getKeys();
vector<uint32_t> scale, scaleIn = fRowGroupIn.getScale();
vector<uint32_t> precision, precisionIn = fRowGroupIn.getPrecision();
vector<CalpontSystemCatalog::ColDataType> types, typesIn = fRowGroupIn.getColTypes();
vector<uint32_t> pos, posIn = fRowGroupIn.getOffsets();
for (uint64_t i = 0; i < fRowGroupIn.getKeys().size(); ++i)
if (keyToIndexMap.find(fRowGroupIn.getKeys()[i]) == keyToIndexMap.end())
keyToIndexMap.insert(make_pair(fRowGroupIn.getKeys()[i], i));
size_t n = 0;
RetColsVector::const_iterator i = jobInfo.deliveredCols.begin();
while (i != jobInfo.deliveredCols.end())
if (NULL == dynamic_cast<const ConstantColumn*>(i++->get()))
n++;
updateInputIndex(keyToIndexMap, jobInfo);
oids.insert(oids.end(), oidsIn.begin(), oidsIn.begin() + n);
keys.insert(keys.end(), keysIn.begin(), keysIn.begin() + n);
scale.insert(scale.end(), scaleIn.begin(), scaleIn.begin() + n);
precision.insert(precision.end(), precisionIn.begin(), precisionIn.begin() + n);
types.insert(types.end(), typesIn.begin(), typesIn.begin() + n);
pos.insert(pos.end(), posIn.begin(), posIn.begin() + n + 1);
vector<uint32_t> oids, oidsIn = fRowGroupIn.getOIDs();
vector<uint32_t> keys, keysIn = fRowGroupIn.getKeys();
vector<uint32_t> scale, scaleIn = fRowGroupIn.getScale();
vector<uint32_t> precision, precisionIn = fRowGroupIn.getPrecision();
vector<CalpontSystemCatalog::ColDataType> types, typesIn = fRowGroupIn.getColTypes();
vector<uint32_t> pos, posIn = fRowGroupIn.getOffsets();
fRowGroupOut = RowGroup(oids.size(), pos, oids, keys, types, scale, precision, jobInfo.stringTableThreshold);
fRowGroupOut.initRow(&fRowOut);
size_t n = 0;
RetColsVector::const_iterator i = jobInfo.deliveredCols.begin();
while (i != jobInfo.deliveredCols.end())
if (NULL == dynamic_cast<const ConstantColumn*>(i++->get()))
n++;
oids.insert(oids.end(), oidsIn.begin(), oidsIn.begin() + n);
keys.insert(keys.end(), keysIn.begin(), keysIn.begin() + n);
scale.insert(scale.end(), scaleIn.begin(), scaleIn.begin() + n);
precision.insert(precision.end(), precisionIn.begin(), precisionIn.begin() + n);
types.insert(types.end(), typesIn.begin(), typesIn.begin() + n);
pos.insert(pos.end(), posIn.begin(), posIn.begin() + n + 1);
fRowGroupOut = RowGroup(oids.size(), pos, oids, keys, types, scale, precision, jobInfo.stringTableThreshold);
fRowGroupOut.initRow(&fRowOut);
}
void TupleHavingStep::expressionFilter(const ParseTree* filter, JobInfo& jobInfo)
{
// let base class handle the simple columns
ExpressionStep::expressionFilter(filter, jobInfo);
// let base class handle the simple columns
ExpressionStep::expressionFilter(filter, jobInfo);
// extract simple columns from parse tree
vector<AggregateColumn*> acv;
fExpressionFilter->walk(getAggCols, &acv);
fColumns.insert(fColumns.end(), acv.begin(), acv.end());
// extract simple columns from parse tree
vector<AggregateColumn*> acv;
fExpressionFilter->walk(getAggCols, &acv);
fColumns.insert(fColumns.end(), acv.begin(), acv.end());
}
void TupleHavingStep::run()
{
if (fInputJobStepAssociation.outSize() == 0)
throw logic_error("No input data list for having step.");
if (fInputJobStepAssociation.outSize() == 0)
throw logic_error("No input data list for having step.");
fInputDL = fInputJobStepAssociation.outAt(0)->rowGroupDL();
if (fInputDL == NULL)
throw logic_error("Input is not a RowGroup data list.");
fInputDL = fInputJobStepAssociation.outAt(0)->rowGroupDL();
fInputIterator = fInputDL->getIterator();
if (fInputDL == NULL)
throw logic_error("Input is not a RowGroup data list.");
if (fDelivery == false)
{
if (fOutputJobStepAssociation.outSize() == 0)
throw logic_error("No output data list for non-delivery having step.");
fInputIterator = fInputDL->getIterator();
fOutputDL = fOutputJobStepAssociation.outAt(0)->rowGroupDL();
if (fOutputDL == NULL)
throw logic_error("Output is not a RowGroup data list.");
if (fDelivery == false)
{
if (fOutputJobStepAssociation.outSize() == 0)
throw logic_error("No output data list for non-delivery having step.");
fRunner = jobstepThreadPool.invoke(Runner(this));
}
fOutputDL = fOutputJobStepAssociation.outAt(0)->rowGroupDL();
if (fOutputDL == NULL)
throw logic_error("Output is not a RowGroup data list.");
fRunner = jobstepThreadPool.invoke(Runner(this));
}
}
void TupleHavingStep::join()
{
if (fRunner)
jobstepThreadPool.join(fRunner);
if (fRunner)
jobstepThreadPool.join(fRunner);
}
uint32_t TupleHavingStep::nextBand(messageqcpp::ByteStream &bs)
uint32_t TupleHavingStep::nextBand(messageqcpp::ByteStream& bs)
{
RGData rgDataIn;
RGData rgDataOut;
bool more = false;
uint32_t rowCount = 0;
RGData rgDataIn;
RGData rgDataOut;
bool more = false;
uint32_t rowCount = 0;
try
{
bs.restart();
try
{
bs.restart();
more = fInputDL->next(fInputIterator, &rgDataIn);
if (dlTimes.FirstReadTime().tv_sec ==0)
more = fInputDL->next(fInputIterator, &rgDataIn);
if (dlTimes.FirstReadTime().tv_sec == 0)
dlTimes.setFirstReadTime();
if (!more || cancelled())
{
fEndOfResult = true;
}
if (!more || cancelled())
{
fEndOfResult = true;
}
bool emptyRowGroup = true;
while (more && !fEndOfResult && emptyRowGroup)
{
if (cancelled())
{
while (more)
more = fInputDL->next(fInputIterator, &rgDataIn);
break;
}
bool emptyRowGroup = true;
fRowGroupIn.setData(&rgDataIn);
rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount());
fRowGroupOut.setData(&rgDataOut);
while (more && !fEndOfResult && emptyRowGroup)
{
if (cancelled())
{
while (more)
more = fInputDL->next(fInputIterator, &rgDataIn);
doHavingFilters();
break;
}
if (fRowGroupOut.getRowCount() > 0)
{
emptyRowGroup = false;
fRowGroupOut.serializeRGData(bs);
rowCount = fRowGroupOut.getRowCount();
}
else
{
more = fInputDL->next(fInputIterator, &rgDataIn);
}
}
fRowGroupIn.setData(&rgDataIn);
rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount());
fRowGroupOut.setData(&rgDataOut);
if (!more)
{
fEndOfResult = true;
}
}
catch(const std::exception& ex)
{
catchHandler(ex.what(), tupleHavingStepErr, fErrorInfo, fSessionId);
while (more)
more = fInputDL->next(fInputIterator, &rgDataIn);
fEndOfResult = true;
}
catch(...)
{
catchHandler("TupleHavingStep next band caught an unknown exception",
tupleHavingStepErr, fErrorInfo, fSessionId);
while (more)
more = fInputDL->next(fInputIterator, &rgDataIn);
fEndOfResult = true;
}
doHavingFilters();
if (fEndOfResult)
{
// send an empty / error band
rgDataOut.reinit(fRowGroupOut, 0);
fRowGroupOut.setData(&rgDataOut);
fRowGroupOut.resetRowGroup(0);
fRowGroupOut.setStatus(status());
fRowGroupOut.serializeRGData(bs);
if (fRowGroupOut.getRowCount() > 0)
{
emptyRowGroup = false;
fRowGroupOut.serializeRGData(bs);
rowCount = fRowGroupOut.getRowCount();
}
else
{
more = fInputDL->next(fInputIterator, &rgDataIn);
}
}
dlTimes.setLastReadTime();
dlTimes.setEndOfInputTime();
if (!more)
{
fEndOfResult = true;
}
}
catch (const std::exception& ex)
{
catchHandler(ex.what(), tupleHavingStepErr, fErrorInfo, fSessionId);
if (traceOn())
printCalTrace();
}
while (more)
more = fInputDL->next(fInputIterator, &rgDataIn);
return rowCount;
fEndOfResult = true;
}
catch (...)
{
catchHandler("TupleHavingStep next band caught an unknown exception",
tupleHavingStepErr, fErrorInfo, fSessionId);
while (more)
more = fInputDL->next(fInputIterator, &rgDataIn);
fEndOfResult = true;
}
if (fEndOfResult)
{
// send an empty / error band
rgDataOut.reinit(fRowGroupOut, 0);
fRowGroupOut.setData(&rgDataOut);
fRowGroupOut.resetRowGroup(0);
fRowGroupOut.setStatus(status());
fRowGroupOut.serializeRGData(bs);
dlTimes.setLastReadTime();
dlTimes.setEndOfInputTime();
if (traceOn())
printCalTrace();
}
return rowCount;
}
void TupleHavingStep::execute()
{
RGData rgDataIn;
RGData rgDataOut;
bool more = false;
StepTeleStats sts;
sts.query_uuid = fQueryUuid;
sts.step_uuid = fStepUuid;
RGData rgDataIn;
RGData rgDataOut;
bool more = false;
StepTeleStats sts;
sts.query_uuid = fQueryUuid;
sts.step_uuid = fStepUuid;
try
{
more = fInputDL->next(fInputIterator, &rgDataIn);
dlTimes.setFirstReadTime();
try
{
more = fInputDL->next(fInputIterator, &rgDataIn);
dlTimes.setFirstReadTime();
sts.msg_type = StepTeleStats::ST_START;
sts.total_units_of_work = 1;
postStepStartTele(sts);
sts.msg_type = StepTeleStats::ST_START;
sts.total_units_of_work = 1;
postStepStartTele(sts);
if (!more && cancelled())
{
fEndOfResult = true;
}
if (!more && cancelled())
{
fEndOfResult = true;
}
while (more && !fEndOfResult)
{
fRowGroupIn.setData(&rgDataIn);
rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount());
fRowGroupOut.setData(&rgDataOut);
while (more && !fEndOfResult)
{
fRowGroupIn.setData(&rgDataIn);
rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount());
fRowGroupOut.setData(&rgDataOut);
doHavingFilters();
doHavingFilters();
more = fInputDL->next(fInputIterator, &rgDataIn);
if (cancelled())
{
fEndOfResult = true;
}
else
{
fOutputDL->insert(rgDataOut);
}
}
}
catch(const std::exception& ex)
{
catchHandler(ex.what(), tupleHavingStepErr, fErrorInfo, fSessionId);
}
catch(...)
{
catchHandler("TupleHavingStep execute caught an unknown exception",
tupleHavingStepErr, fErrorInfo, fSessionId);
}
more = fInputDL->next(fInputIterator, &rgDataIn);
while (more)
more = fInputDL->next(fInputIterator, &rgDataIn);
if (cancelled())
{
fEndOfResult = true;
}
else
{
fOutputDL->insert(rgDataOut);
}
}
}
catch (const std::exception& ex)
{
catchHandler(ex.what(), tupleHavingStepErr, fErrorInfo, fSessionId);
}
catch (...)
{
catchHandler("TupleHavingStep execute caught an unknown exception",
tupleHavingStepErr, fErrorInfo, fSessionId);
}
fEndOfResult = true;
fOutputDL->endOfInput();
while (more)
more = fInputDL->next(fInputIterator, &rgDataIn);
sts.msg_type = StepTeleStats::ST_SUMMARY;
sts.total_units_of_work = sts.units_of_work_completed = 1;
sts.rows = fRowsReturned;
postStepSummaryTele(sts);
fEndOfResult = true;
fOutputDL->endOfInput();
dlTimes.setLastReadTime();
dlTimes.setEndOfInputTime();
sts.msg_type = StepTeleStats::ST_SUMMARY;
sts.total_units_of_work = sts.units_of_work_completed = 1;
sts.rows = fRowsReturned;
postStepSummaryTele(sts);
if (traceOn())
printCalTrace();
dlTimes.setLastReadTime();
dlTimes.setEndOfInputTime();
if (traceOn())
printCalTrace();
}
void TupleHavingStep::doHavingFilters()
{
fRowGroupIn.getRow(0, &fRowIn);
fRowGroupOut.getRow(0, &fRowOut);
fRowGroupOut.resetRowGroup(fRowGroupIn.getBaseRid());
fRowGroupIn.getRow(0, &fRowIn);
fRowGroupOut.getRow(0, &fRowOut);
fRowGroupOut.resetRowGroup(fRowGroupIn.getBaseRid());
for (uint64_t i = 0; i < fRowGroupIn.getRowCount(); ++i)
{
if(fFeInstance->evaluate(fRowIn, fExpressionFilter))
{
copyRow(fRowIn, &fRowOut);
fRowGroupOut.incRowCount();
fRowOut.nextRow();
}
for (uint64_t i = 0; i < fRowGroupIn.getRowCount(); ++i)
{
if (fFeInstance->evaluate(fRowIn, fExpressionFilter))
{
copyRow(fRowIn, &fRowOut);
fRowGroupOut.incRowCount();
fRowOut.nextRow();
}
fRowIn.nextRow();
}
fRowIn.nextRow();
}
fRowsReturned += fRowGroupOut.getRowCount();
fRowsReturned += fRowGroupOut.getRowCount();
}
const RowGroup& TupleHavingStep::getOutputRowGroup() const
{
return fRowGroupOut;
return fRowGroupOut;
}
const RowGroup& TupleHavingStep::getDeliveredRowGroup() const
{
return fRowGroupOut;
return fRowGroupOut;
}
void TupleHavingStep::deliverStringTableRowGroup(bool b)
{
fRowGroupOut.setUseStringTable(b);
fRowGroupOut.setUseStringTable(b);
}
bool TupleHavingStep::deliverStringTableRowGroup() const
{
return fRowGroupOut.usesStringTable();
return fRowGroupOut.usesStringTable();
}
const string TupleHavingStep::toString() const
{
ostringstream oss;
oss << "HavingStep ses:" << fSessionId << " txn:" << fTxnId << " st:" << fStepId;
ostringstream oss;
oss << "HavingStep ses:" << fSessionId << " txn:" << fTxnId << " st:" << fStepId;
oss << " in:";
for (unsigned i = 0; i < fInputJobStepAssociation.outSize(); i++)
oss << fInputJobStepAssociation.outAt(i);
oss << " in:";
oss << " out:";
for (unsigned i = 0; i < fOutputJobStepAssociation.outSize(); i++)
oss << fOutputJobStepAssociation.outAt(i);
for (unsigned i = 0; i < fInputJobStepAssociation.outSize(); i++)
oss << fInputJobStepAssociation.outAt(i);
oss << endl;
oss << " out:";
return oss.str();
for (unsigned i = 0; i < fOutputJobStepAssociation.outSize(); i++)
oss << fOutputJobStepAssociation.outAt(i);
oss << endl;
return oss.str();
}
void TupleHavingStep::printCalTrace()
{
time_t t = time (0);
char timeString[50];
ctime_r (&t, timeString);
timeString[strlen (timeString )-1] = '\0';
ostringstream logStr;
logStr << "ses:" << fSessionId << " st: " << fStepId << " finished at "<< timeString
<< "; total rows returned-" << fRowsReturned << endl
<< "\t1st read " << dlTimes.FirstReadTimeString()
<< "; EOI " << dlTimes.EndOfInputTimeString() << "; runtime-"
<< JSTimeStamp::tsdiffstr(dlTimes.EndOfInputTime(), dlTimes.FirstReadTime())
<< "s;\n\tUUID " << uuids::to_string(fStepUuid) << endl
<< "\tJob completion status " << status() << endl;
logEnd(logStr.str().c_str());
fExtendedInfo += logStr.str();
formatMiniStats();
time_t t = time (0);
char timeString[50];
ctime_r (&t, timeString);
timeString[strlen (timeString ) - 1] = '\0';
ostringstream logStr;
logStr << "ses:" << fSessionId << " st: " << fStepId << " finished at " << timeString
<< "; total rows returned-" << fRowsReturned << endl
<< "\t1st read " << dlTimes.FirstReadTimeString()
<< "; EOI " << dlTimes.EndOfInputTimeString() << "; runtime-"
<< JSTimeStamp::tsdiffstr(dlTimes.EndOfInputTime(), dlTimes.FirstReadTime())
<< "s;\n\tUUID " << uuids::to_string(fStepUuid) << endl
<< "\tJob completion status " << status() << endl;
logEnd(logStr.str().c_str());
fExtendedInfo += logStr.str();
formatMiniStats();
}
void TupleHavingStep::formatMiniStats()
{
fMiniInfo += "THS ";
fMiniInfo += "UM ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += JSTimeStamp::tsdiffstr(dlTimes.EndOfInputTime(),dlTimes.FirstReadTime()) + " ";
fMiniInfo += "- ";
fMiniInfo += "THS ";
fMiniInfo += "UM ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += "- ";
fMiniInfo += JSTimeStamp::tsdiffstr(dlTimes.EndOfInputTime(), dlTimes.FirstReadTime()) + " ";
fMiniInfo += "- ";
}