SimpleFilter::SimpleFilter(const SimpleFilter& rhs) : fOp(rhs.op()), fIndexFlag(rhs.indexFlag()), fJoinFlag(rhs.joinFlag()) { fLhs = rhs.lhs()->clone(); fRhs = rhs.rhs()->clone(); fSimpleColumnList.clear(); fAggColumnList.clear(); fWindowFunctionColumnList.clear(); SimpleColumn *lsc = dynamic_cast<SimpleColumn*>(fLhs); FunctionColumn *lfc = dynamic_cast<FunctionColumn*>(fLhs); ArithmeticColumn *lac = dynamic_cast<ArithmeticColumn*>(fLhs); WindowFunctionColumn *laf = dynamic_cast<WindowFunctionColumn*>(fLhs); AggregateColumn *lagc = dynamic_cast<AggregateColumn*>(fLhs); SimpleColumn *rsc = dynamic_cast<SimpleColumn*>(fRhs); FunctionColumn *rfc = dynamic_cast<FunctionColumn*>(fRhs); ArithmeticColumn *rac = dynamic_cast<ArithmeticColumn*>(fRhs); AggregateColumn *ragc = dynamic_cast<AggregateColumn*>(fRhs); WindowFunctionColumn *raf = dynamic_cast<WindowFunctionColumn*>(fRhs); if (lsc) { fSimpleColumnList.push_back(lsc); } else if (lagc) { fAggColumnList.push_back(lagc); } else if (lfc) { fSimpleColumnList.insert(fSimpleColumnList.end(), lfc->simpleColumnList().begin(), lfc->simpleColumnList().end()); fAggColumnList.insert(fAggColumnList.end(), lfc->aggColumnList().begin(), lfc->aggColumnList().end()); fWindowFunctionColumnList.insert (fWindowFunctionColumnList.end(), lfc->windowfunctionColumnList().begin(), lfc->windowfunctionColumnList().end()); } else if (lac) { fSimpleColumnList.insert(fSimpleColumnList.end(), lac->simpleColumnList().begin(), lac->simpleColumnList().end()); fAggColumnList.insert(fAggColumnList.end(), lac->aggColumnList().begin(), lac->aggColumnList().end()); fWindowFunctionColumnList.insert (fWindowFunctionColumnList.end(), lac->windowfunctionColumnList().begin(), lac->windowfunctionColumnList().end()); } else if (laf) { fWindowFunctionColumnList.push_back(laf); } if (rsc) { fSimpleColumnList.push_back(rsc); } else if (ragc) { fAggColumnList.push_back(ragc); } else if (rfc) { fSimpleColumnList.insert (fSimpleColumnList.end(), rfc->simpleColumnList().begin(), rfc->simpleColumnList().end()); fAggColumnList.insert (fAggColumnList.end(), rfc->aggColumnList().begin(), rfc->aggColumnList().end()); fWindowFunctionColumnList.insert (fWindowFunctionColumnList.end(), rfc->windowfunctionColumnList().begin(), rfc->windowfunctionColumnList().end()); } else if (rac) { fSimpleColumnList.insert(fSimpleColumnList.end(), rac->simpleColumnList().begin(), rac->simpleColumnList().end()); fAggColumnList.insert(fAggColumnList.end(), rac->aggColumnList().begin(), rac->aggColumnList().end()); fWindowFunctionColumnList.insert (fWindowFunctionColumnList.end(), rac->windowfunctionColumnList().begin(), rac->windowfunctionColumnList().end()); } else if (raf) { fWindowFunctionColumnList.push_back(raf); } }
void SimpleFilter::unserialize(messageqcpp::ByteStream& b) { ObjectReader::checkType(b, ObjectReader::SIMPLEFILTER); //delete fOp; delete fLhs; delete fRhs; Filter::unserialize(b); fOp.reset(dynamic_cast<Operator*>(ObjectReader::createTreeNode(b))); fLhs = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b)); fRhs = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b)); b >> reinterpret_cast<uint32_t&>(fIndexFlag); b >> reinterpret_cast<uint32_t&>(fJoinFlag); fSimpleColumnList.clear(); fAggColumnList.clear(); fWindowFunctionColumnList.clear(); SimpleColumn *lsc = dynamic_cast<SimpleColumn*>(fLhs); FunctionColumn *lfc = dynamic_cast<FunctionColumn*>(fLhs); ArithmeticColumn *lac = dynamic_cast<ArithmeticColumn*>(fLhs); WindowFunctionColumn *laf = dynamic_cast<WindowFunctionColumn*>(fLhs); AggregateColumn *lagc = dynamic_cast<AggregateColumn*>(fLhs); SimpleColumn *rsc = dynamic_cast<SimpleColumn*>(fRhs); FunctionColumn *rfc = dynamic_cast<FunctionColumn*>(fRhs); ArithmeticColumn *rac = dynamic_cast<ArithmeticColumn*>(fRhs); AggregateColumn *ragc = dynamic_cast<AggregateColumn*>(fRhs); WindowFunctionColumn *raf = dynamic_cast<WindowFunctionColumn*>(fRhs); if (lsc) { fSimpleColumnList.push_back(lsc); } else if (lagc) { fAggColumnList.push_back(lagc); } else if (lfc) { fSimpleColumnList.insert(fSimpleColumnList.end(), lfc->simpleColumnList().begin(), lfc->simpleColumnList().end()); fAggColumnList.insert(fAggColumnList.end(), lfc->aggColumnList().begin(), lfc->aggColumnList().end()); fWindowFunctionColumnList.insert (fWindowFunctionColumnList.end(), lfc->windowfunctionColumnList().begin(), lfc->windowfunctionColumnList().end()); } else if (lac) { fSimpleColumnList.insert(fSimpleColumnList.end(), lac->simpleColumnList().begin(), lac->simpleColumnList().end()); fAggColumnList.insert(fAggColumnList.end(), lac->aggColumnList().begin(), lac->aggColumnList().end()); fWindowFunctionColumnList.insert (fWindowFunctionColumnList.end(), lac->windowfunctionColumnList().begin(), lac->windowfunctionColumnList().end()); } else if (laf) { fWindowFunctionColumnList.push_back(laf); } if (rsc) { fSimpleColumnList.push_back(rsc); } else if (ragc) { fAggColumnList.push_back(ragc); } else if (rfc) { fSimpleColumnList.insert (fSimpleColumnList.end(), rfc->simpleColumnList().begin(), rfc->simpleColumnList().end()); fAggColumnList.insert (fAggColumnList.end(), rfc->aggColumnList().begin(), rfc->aggColumnList().end()); fWindowFunctionColumnList.insert (fWindowFunctionColumnList.end(), rfc->windowfunctionColumnList().begin(), rfc->windowfunctionColumnList().end()); } else if (rac) { fSimpleColumnList.insert(fSimpleColumnList.end(), rac->simpleColumnList().begin(), rac->simpleColumnList().end()); fAggColumnList.insert(fAggColumnList.end(), rac->aggColumnList().begin(), rac->aggColumnList().end()); fWindowFunctionColumnList.insert (fWindowFunctionColumnList.end(), rac->windowfunctionColumnList().begin(), rac->windowfunctionColumnList().end()); } else if (raf) { fWindowFunctionColumnList.push_back(raf); } // construct regex constant for like operator if (fOp->op() == OP_LIKE || fOp->op() == OP_NOTLIKE) { ConstantColumn *rcc = dynamic_cast<ConstantColumn*>(fRhs); if (rcc) rcc->constructRegex(); ConstantColumn *lcc = dynamic_cast<ConstantColumn*>(fLhs); if (lcc) lcc->constructRegex(); } }