Esempio n. 1
0
void JoinOperator::updateExpression(Expression *exp, unordered_map<string, Expression*> lm, unordered_map<string, Expression*> rm
        , string ltable, string rtable) {
    ExprType t = exp->getType();
    if(t != ExprType::COLEXPRESSION && t != ExprType::DOUBLEVALUEEXPRESSION && t != ExprType::STRINGVALUEEXPRESSION &&
       t != ExprType::LONGVALUEEXPRESSION && t != ExprType::DATEVALUEEXPRESSION){
        BinaryExpression* bexp = (BinaryExpression*)exp;
        updateExpression(bexp->getLeftExpression(), lm, rm, ltable, rtable);
        updateExpression(bexp->getRightExpression(), lm, rm, ltable, rtable);
    } else if(t == COLEXPRESSION){
        ColExpression* col = (ColExpression*)exp;
        if(lm.find(col->getQualifiedName()) != lm.end()){
            ColExpression* e = (ColExpression*)lm[col->getQualifiedName()];
            col->setType(e->getDataType());
            col->setColPos(e->getColPos());
            left.push_back(col);
        } else if(rm.find(col->getQualifiedName()) != rm.end()){
            ColExpression* e = (ColExpression*)rm[col->getQualifiedName()];
            col->setType(e->getDataType());
            col->setColPos(e->getColPos() + (int)lm.size());
            ColExpression *rcol = new ColExpression(col->getQualifiedName(), col->getColPos()-(int)lm.size(), col->getDataType());
            right.push_back(rcol);
        } else {
            std::cout << "column : " << col->getQualifiedName() << " not found in any schema " << std::endl;
        }
    }
}
Esempio n. 2
0
void ProjectionOperator::updateExpression(Expression *newExp, unordered_map<std::string, Expression *> m, string tableName) {
	ExprType t = newExp->getType();
	if(t != ExprType::COLEXPRESSION && t != ExprType::DOUBLEVALUEEXPRESSION && t != ExprType::STRINGVALUEEXPRESSION &&
			t != ExprType::LONGVALUEEXPRESSION && t != ExprType::DATEVALUEEXPRESSION){
		BinaryExpression* b = (BinaryExpression*)newExp;
		updateExpression(b->getLeftExpression(), m, tableName);
		updateExpression(b->getRightExpression(), m, tableName);
	} else if(t == ExprType::COLEXPRESSION){
		if(((ColExpression*)newExp)->getTableName() == "")
			((ColExpression*)newExp)->setTableName(tableName);
		ColExpression* col = (ColExpression*)m[((ColExpression*)newExp)->getQualifiedName()];
		((ColExpression*)newExp)->setColPos(col->getColPos());
		((ColExpression*)newExp)->setType(col->getDataType());
	}
}
Esempio n. 3
0
DataType Expression::getDataType() {
    ExprType t = this->getType();
    if(t == STRINGVALUEEXPRESSION)
        return STRING;
    if(t == DOUBLEVALUEEXPRESSION)
        return DOUBLE;
    if(t == LONGVALUEEXPRESSION)
        return LONG;
    if(t == DATEVALUEEXPRESSION)
        return DATE;
    if(t == ADDITIONEXPRESSION || t == SUBTRACTIONEXPRESSION || t == MULTIPLICATIONEXPRESSION || t == DIVISIONEXPRESSION){
        BinaryExpression* bexp = (BinaryExpression*)this;
        DataType t1 = bexp->getLeftExpression()->getDataType();
        DataType t2 = bexp->getRightExpression()->getDataType();
        if(t1 == DOUBLE || t2 == DOUBLE)
            return DOUBLE;
        return LONG;
    }
    if(t == COLEXPRESSION)
        return getDataType();
    //Boolean
    return LONG;
}