uint TupleConstantOnlyStep::nextBand(messageqcpp::ByteStream &bs) { RGData rgDataOut; uint rowCount = 0; if (!fEndOfResult) { try { bs.restart(); if (traceOn() && dlTimes.FirstReadTime().tv_sec == 0) dlTimes.setFirstReadTime(); rgDataOut.reinit(fRowGroupOut, 1); fRowGroupOut.setData(&rgDataOut); fillInConstants(); fRowGroupOut.serializeRGData(bs); rowCount = fRowGroupOut.getRowCount(); } catch(const std::exception& ex) { catchHandler(ex.what(), fSessionId); if (status() == 0) status(tupleConstantStepErr); } catch(...) { catchHandler("TupleConstantStep next band caught an unknown exception", fSessionId); if (status() == 0) status(tupleConstantStepErr); } fEndOfResult = true; } else { // send an empty / error band RGData rgData(fRowGroupOut, 0); fRowGroupOut.setData(&rgData); fRowGroupOut.resetRowGroup(0); fRowGroupOut.setStatus(status()); fRowGroupOut.serializeRGData(bs); if (traceOn()) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } } return rowCount; }
void TupleHavingStep::execute() { RGData rgDataIn; RGData rgDataOut; bool more = false; try { more = fInputDL->next(fInputIterator, &rgDataIn); dlTimes.setFirstReadTime(); if (!more && cancelled()) { fEndOfResult = true; } while (more && !fEndOfResult) { fRowGroupIn.setData(&rgDataIn); rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount()); fRowGroupOut.setData(&rgDataOut); 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); } while (more) more = fInputDL->next(fInputIterator, &rgDataIn); fEndOfResult = true; fOutputDL->endOfInput(); dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); if (traceOn()) printCalTrace(); }
void TupleConstantOnlyStep::run() { if (fDelivery == false) { if (fOutputJobStepAssociation.outSize() == 0) throw logic_error("No output data list for non-delivery constant step."); fOutputDL = fOutputJobStepAssociation.outAt(0)->rowGroupDL(); if (fOutputDL == NULL) throw logic_error("Output is not a RowGroup data list."); try { RGData rgDataOut(fRowGroupOut, 1); fRowGroupOut.setData(&rgDataOut); if (traceOn()) dlTimes.setFirstReadTime(); fillInConstants(); fOutputDL->insert(rgDataOut); } catch(...) { catchHandler("TupleConstantOnlyStep run caught an unknown exception", fSessionId); if (status() == 0) status(tupleConstantStepErr); } if (traceOn()) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } // Bug 3136, let mini stats to be formatted if traceOn. fEndOfResult = true; fOutputDL->endOfInput(); } }
uint TupleConstantBooleanStep::nextBand(messageqcpp::ByteStream &bs) { // send an empty band RGData rgData(fRowGroupOut, 0); fRowGroupOut.setData(&rgData); fRowGroupOut.resetRowGroup(0); fRowGroupOut.setStatus(status()); fRowGroupOut.serializeRGData(bs); if (traceOn()) { dlTimes.setFirstReadTime(); dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } return 0; }
void TupleConstantBooleanStep::run() { if (fDelivery == false) { if (fOutputJobStepAssociation.outSize() == 0) throw logic_error("No output data list for non-delivery constant step."); fOutputDL = fOutputJobStepAssociation.outAt(0)->rowGroupDL(); if (fOutputDL == NULL) throw logic_error("Output is not a RowGroup data list."); if (traceOn()) { dlTimes.setFirstReadTime(); dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } // Bug 3136, let mini stats to be formatted if traceOn. fOutputDL->endOfInput(); } }
void SubAdapterStep::execute() { RGData rgDataIn; RGData rgDataOut; Row rowIn; Row rowFe; Row rowOut; fRowGroupIn.initRow(&rowIn); fRowGroupOut.initRow(&rowOut); RGData rowFeData; bool usesFE = false; if (fRowGroupFe.getColumnCount() != (uint32_t) -1) { usesFE = true; fRowGroupFe.initRow(&rowFe, true); rowFeData = RGData(fRowGroupFe, 1); fRowGroupFe.setData(&rowFeData); fRowGroupFe.getRow(0, &rowFe); } bool more = false; try { fSubStep->run(); more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn()) dlTimes.setFirstReadTime(); while (more && !cancelled()) { fRowGroupIn.setData(&rgDataIn); rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount()); fRowGroupOut.setData(&rgDataOut); fRowGroupOut.resetRowGroup(fRowGroupIn.getBaseRid()); fRowGroupIn.getRow(0, &rowIn); fRowGroupOut.getRow(0, &rowOut); for (uint64_t i = 0; i < fRowGroupIn.getRowCount(); ++i) { if(fExpression.get() == NULL) { outputRow(rowIn, rowOut); } else if (!usesFE) { if(fExpression->evaluate(&rowIn)) { outputRow(rowIn, rowOut); } } else { copyRow(rowIn, &rowFe, rowIn.getColumnCount()); //memcpy(rowFe.getData(), rowIn.getData(), rowIn.getSize()); if(fExpression->evaluate(&rowFe)) { outputRow(rowFe, rowOut); } } rowIn.nextRow(); } if (fRowGroupOut.getRowCount() > 0) { fRowsReturned += fRowGroupOut.getRowCount(); fOutputDL->insert(rgDataOut); } more = fInputDL->next(fInputIterator, &rgDataIn); } } catch(const std::exception& ex) { catchHandler(ex.what(), ERR_EXEMGR_MALFUNCTION, fErrorInfo, fSessionId); } catch(...) { catchHandler("SubAdapterStep execute caught an unknown exception", ERR_EXEMGR_MALFUNCTION, fErrorInfo, fSessionId); } if (cancelled()) while (more) more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn()) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } // Bug 3136, let mini stats to be formatted if traceOn. fOutputDL->endOfInput(); }
void TupleHavingStep::execute() { 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(); sts.msg_type = StepTeleStats::ST_START; sts.total_units_of_work = 1; postStepStartTele(sts); if (!more && cancelled()) { fEndOfResult = true; } while (more && !fEndOfResult) { fRowGroupIn.setData(&rgDataIn); rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount()); fRowGroupOut.setData(&rgDataOut); 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); } while (more) more = fInputDL->next(fInputIterator, &rgDataIn); fEndOfResult = true; fOutputDL->endOfInput(); sts.msg_type = StepTeleStats::ST_SUMMARY; sts.total_units_of_work = sts.units_of_work_completed = 1; sts.rows = fRowsReturned; postStepSummaryTele(sts); dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); if (traceOn()) printCalTrace(); }
uint32_t TupleHavingStep::nextBand(messageqcpp::ByteStream &bs) { RGData rgDataIn; RGData rgDataOut; bool more = false; uint32_t rowCount = 0; try { bs.restart(); more = fInputDL->next(fInputIterator, &rgDataIn); if (dlTimes.FirstReadTime().tv_sec ==0) dlTimes.setFirstReadTime(); if (!more || cancelled()) { fEndOfResult = true; } bool emptyRowGroup = true; while (more && !fEndOfResult && emptyRowGroup) { if (cancelled()) { while (more) more = fInputDL->next(fInputIterator, &rgDataIn); break; } fRowGroupIn.setData(&rgDataIn); rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount()); fRowGroupOut.setData(&rgDataOut); doHavingFilters(); if (fRowGroupOut.getRowCount() > 0) { emptyRowGroup = false; fRowGroupOut.serializeRGData(bs); rowCount = fRowGroupOut.getRowCount(); } else { more = fInputDL->next(fInputIterator, &rgDataIn); } } 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; } 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 TupleAnnexStep::executeWithOrderBy() { RGData rgDataIn; RGData rgDataOut; bool more = false; try { more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn()) dlTimes.setFirstReadTime(); while (more && !cancelled()) { fRowGroupIn.setData(&rgDataIn); fRowGroupIn.getRow(0, &fRowIn); for (uint64_t i = 0; i < fRowGroupIn.getRowCount() && !cancelled(); ++i) { fOrderBy->processRow(fRowIn); fRowIn.nextRow(); } more = fInputDL->next(fInputIterator, &rgDataIn); } fOrderBy->finalize(); if (!cancelled()) { while (fOrderBy->getData(rgDataIn)) { if (fConstant == NULL && fRowGroupOut.getColumnCount() == fRowGroupIn.getColumnCount()) { rgDataOut = rgDataIn; fRowGroupOut.setData(&rgDataOut); } else { fRowGroupIn.setData(&rgDataIn); fRowGroupIn.getRow(0, &fRowIn); rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount()); fRowGroupOut.setData(&rgDataOut); fRowGroupOut.resetRowGroup(fRowGroupIn.getBaseRid()); fRowGroupOut.setDBRoot(fRowGroupIn.getDBRoot()); fRowGroupOut.getRow(0, &fRowOut); for (uint64_t i = 0; i < fRowGroupIn.getRowCount(); ++i) { if (fConstant) fConstant->fillInConstants(fRowIn, fRowOut); else copyRow(fRowIn, &fRowOut); fRowGroupOut.incRowCount(); fRowOut.nextRow(); fRowIn.nextRow(); } } if (fRowGroupOut.getRowCount() > 0) { fRowsReturned += fRowGroupOut.getRowCount(); fOutputDL->insert(rgDataOut); } } } } catch(const std::exception& ex) { catchHandler(ex.what(), fSessionId); if (status() == 0) status(ERR_IN_PROCESS); } catch(...) { catchHandler("TupleAnnexStep execute caught an unknown exception", fSessionId); if (status() == 0) status(ERR_IN_PROCESS); } while (more) more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn() && !fDelivery) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } // Bug 3136, let mini stats to be formatted if traceOn. fOutputDL->endOfInput(); }
void TupleAnnexStep::executeNoOrderByWithDistinct() { scoped_ptr<DistinctMap_t> distinctMap(new DistinctMap_t(10, TAHasher(this), TAEq(this))); vector<RGData> dataVec; RGData rgDataIn; RGData rgDataOut; bool more = false; rgDataOut.reinit(fRowGroupOut); fRowGroupOut.setData(&rgDataOut); fRowGroupOut.resetRowGroup(0); fRowGroupOut.getRow(0, &fRowOut); fRowGroupOut.initRow(&row1); fRowGroupOut.initRow(&row2); try { more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn()) dlTimes.setFirstReadTime(); while (more && !cancelled() && !fLimitHit) { fRowGroupIn.setData(&rgDataIn); fRowGroupIn.getRow(0, &fRowIn); for (uint64_t i = 0; i < fRowGroupIn.getRowCount() && !cancelled() && !fLimitHit; ++i) { pair<DistinctMap_t::iterator, bool> inserted; if (fConstant) fConstant->fillInConstants(fRowIn, fRowOut); else copyRow(fRowIn, &fRowOut); ++fRowsProcessed; fRowIn.nextRow(); inserted = distinctMap->insert(fRowOut.getPointer()); if (inserted.second) { fRowGroupOut.incRowCount(); fRowOut.nextRow(); if (UNLIKELY(++fRowsReturned >= fLimitCount)) { fLimitHit = true; fJobList->abortOnLimit((JobStep*) this); } if (UNLIKELY(fRowGroupOut.getRowCount() >= 8192)) { dataVec.push_back(rgDataOut); rgDataOut.reinit(fRowGroupOut); fRowGroupOut.setData(&rgDataOut); fRowGroupOut.resetRowGroup(0); fRowGroupOut.getRow(0, &fRowOut); } } } more = fInputDL->next(fInputIterator, &rgDataIn); } if (fRowGroupOut.getRowCount() > 0) dataVec.push_back(rgDataOut); for (vector<RGData>::iterator i = dataVec.begin(); i != dataVec.end(); i++) { rgDataOut = *i; fRowGroupOut.setData(&rgDataOut); fOutputDL->insert(rgDataOut); } } catch(const std::exception& ex) { catchHandler(ex.what(), fSessionId); if (status() == 0) status(ERR_IN_PROCESS); } catch(...) { catchHandler("TupleAnnexStep execute caught an unknown exception", fSessionId); if (status() == 0) status(ERR_IN_PROCESS); } while (more) more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn() && !fDelivery) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } // Bug 3136, let mini stats to be formatted if traceOn. fOutputDL->endOfInput(); }
void TupleAnnexStep::executeNoOrderBy() { RGData rgDataIn; RGData rgDataOut; bool more = false; try { more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn()) dlTimes.setFirstReadTime(); while (more && !cancelled() && !fLimitHit) { fRowGroupIn.setData(&rgDataIn); fRowGroupIn.getRow(0, &fRowIn); // Get a new output rowgroup for each input rowgroup to preserve the rids rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount()); fRowGroupOut.setData(&rgDataOut); fRowGroupOut.resetRowGroup(fRowGroupIn.getBaseRid()); fRowGroupOut.setDBRoot(fRowGroupIn.getDBRoot()); fRowGroupOut.getRow(0, &fRowOut); for (uint64_t i = 0; i < fRowGroupIn.getRowCount() && !cancelled() && !fLimitHit; ++i) { // skip first limit-start rows if (fRowsProcessed++ < fLimitStart) { fRowIn.nextRow(); continue; } if (fConstant) fConstant->fillInConstants(fRowIn, fRowOut); else copyRow(fRowIn, &fRowOut); fRowGroupOut.incRowCount(); if (++fRowsReturned < fLimitCount) { fRowOut.nextRow(); fRowIn.nextRow(); } else { fLimitHit = true; fJobList->abortOnLimit((JobStep*) this); } } if (fRowGroupOut.getRowCount() > 0) { fOutputDL->insert(rgDataOut); } more = fInputDL->next(fInputIterator, &rgDataIn); } } catch(const std::exception& ex) { catchHandler(ex.what(), fSessionId); if (status() == 0) status(ERR_IN_PROCESS); } catch(...) { catchHandler("TupleAnnexStep execute caught an unknown exception", fSessionId); if (status() == 0) status(ERR_IN_PROCESS); } while (more) more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn() && !fDelivery) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } // Bug 3136, let mini stats to be formatted if traceOn. fOutputDL->endOfInput(); }
uint TupleAnnexStep::nextBand(messageqcpp::ByteStream &bs) { RGData rgDataOut; bool more = false; uint rowCount = 0; try { bs.restart(); more = fOutputDL->next(fOutputIterator, &rgDataOut); if (traceOn() && dlTimes.FirstReadTime().tv_sec ==0) dlTimes.setFirstReadTime(); if (more && !cancelled()) { fRowGroupDeliver.setData(&rgDataOut); fRowGroupDeliver.serializeRGData(bs); rowCount = fRowGroupDeliver.getRowCount(); } else { if (more) more = fOutputDL->next(fOutputIterator, &rgDataOut); fEndOfResult = true; } } catch(const std::exception& ex) { catchHandler(ex.what(), fSessionId); if (status() == 0) status(ERR_IN_DELIVERY); while (more) more = fOutputDL->next(fOutputIterator, &rgDataOut); fEndOfResult = true; } catch(...) { catchHandler("TupleAnnexStep next band caught an unknown exception", fSessionId); if (status() == 0) status(ERR_IN_DELIVERY); while (more) more = fOutputDL->next(fOutputIterator, &rgDataOut); fEndOfResult = true; } if (fEndOfResult) { // send an empty / error band rgDataOut.reinit(fRowGroupDeliver, 0); fRowGroupDeliver.setData(&rgDataOut); fRowGroupDeliver.resetRowGroup(0); fRowGroupDeliver.setStatus(status()); fRowGroupDeliver.serializeRGData(bs); if (traceOn()) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); } if (traceOn()) printCalTrace(); } return rowCount; }
void TupleConstantStep::execute() { RGData rgDataIn; RGData rgDataOut; bool more = false; try { more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn()) dlTimes.setFirstReadTime(); if (!more && cancelled()) { fEndOfResult = true; } while (more && !fEndOfResult) { fRowGroupIn.setData(&rgDataIn); rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount()); fRowGroupOut.setData(&rgDataOut); fillInConstants(); more = fInputDL->next(fInputIterator, &rgDataIn); if (cancelled()) { fEndOfResult = true; } else { fOutputDL->insert(rgDataOut); } } } catch(const std::exception& ex) { catchHandler(ex.what(), fSessionId); if (status() == 0) status(tupleConstantStepErr); } catch(...) { catchHandler("TupleConstantStep execute caught an unknown exception", fSessionId); if (status() == 0) status(tupleConstantStepErr); } if (!fEndOfResult) while (more) more = fInputDL->next(fInputIterator, &rgDataIn); // Bug 3136, let mini stats to be formatted if traceOn. if (traceOn()) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } fEndOfResult = true; fOutputDL->endOfInput(); }
void SubAdapterStep::execute() { RGData rgDataIn; RGData rgDataOut; Row rowIn; Row rowFe; Row rowOut; fRowGroupIn.initRow(&rowIn); fRowGroupOut.initRow(&rowOut); RGData rowFeData; StepTeleStats sts; sts.query_uuid = fQueryUuid; sts.step_uuid = fStepUuid; bool usesFE = false; if (fRowGroupFe.getColumnCount() > 0) { usesFE = true; fRowGroupFe.initRow(&rowFe, true); rowFeData = RGData(fRowGroupFe, 1); fRowGroupFe.setData(&rowFeData); fRowGroupFe.getRow(0, &rowFe); } bool more = false; try { sts.msg_type = StepTeleStats::ST_START; sts.total_units_of_work = 1; postStepStartTele(sts); fSubStep->run(); more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn()) dlTimes.setFirstReadTime(); while (more && !cancelled()) { fRowGroupIn.setData(&rgDataIn); rgDataOut.reinit(fRowGroupOut, fRowGroupIn.getRowCount()); fRowGroupOut.setData(&rgDataOut); fRowGroupOut.resetRowGroup(fRowGroupIn.getBaseRid()); fRowGroupIn.getRow(0, &rowIn); fRowGroupOut.getRow(0, &rowOut); fRowsInput += fRowGroupIn.getRowCount(); for (uint64_t i = 0; i < fRowGroupIn.getRowCount(); ++i) { if(fExpression.get() == NULL) { outputRow(rowIn, rowOut); } else if (!usesFE) { if(fExpression->evaluate(&rowIn)) { outputRow(rowIn, rowOut); } } else { copyRow(rowIn, &rowFe, rowIn.getColumnCount()); //memcpy(rowFe.getData(), rowIn.getData(), rowIn.getSize()); if(fExpression->evaluate(&rowFe)) { outputRow(rowFe, rowOut); } } rowIn.nextRow(); } if (fRowGroupOut.getRowCount() > 0) { fRowsReturned += fRowGroupOut.getRowCount(); fOutputDL->insert(rgDataOut); } more = fInputDL->next(fInputIterator, &rgDataIn); } } catch(const std::exception& ex) { catchHandler(ex.what(), ERR_EXEMGR_MALFUNCTION, fErrorInfo, fSessionId); } catch(...) { catchHandler("SubAdapterStep execute caught an unknown exception", ERR_EXEMGR_MALFUNCTION, fErrorInfo, fSessionId); } if (cancelled()) while (more) more = fInputDL->next(fInputIterator, &rgDataIn); if (traceOn()) { dlTimes.setLastReadTime(); dlTimes.setEndOfInputTime(); printCalTrace(); } sts.msg_type = StepTeleStats::ST_SUMMARY; sts.total_units_of_work = sts.units_of_work_completed = 1; sts.rows = fRowsReturned; postStepSummaryTele(sts); // Bug 3136, let mini stats to be formatted if traceOn. fOutputDL->endOfInput(); }