Search in sources :

Example 81 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class ItemSumMin method toExpression.

@Override
public SQLExpr toExpression() {
    Item arg0 = args.get(0);
    SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
    aggregate.addArgument(arg0.toExpression());
    return aggregate;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) SQLAggregateExpr(com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)

Example 82 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class ItemSumSum method toExpression.

@Override
public SQLExpr toExpression() {
    Item arg0 = getArg(0);
    SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
    aggregate.addArgument(arg0.toExpression());
    if (hasWithDistinct()) {
        aggregate.setOption(SQLAggregateOption.DISTINCT);
    }
    return aggregate;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) SQLAggregateExpr(com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)

Example 83 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class JoinHandler method makeOtherJoinOnItem.

private Item makeOtherJoinOnItem(List<FieldPacket> rowPackets, BackendConnection conn) {
    this.joinRowFields = HandlerTool.createFields(rowPackets);
    if (otherJoinOn == null)
        return null;
    Item ret = HandlerTool.createItem(this.otherJoinOn, this.joinRowFields, 0, this.isAllPushDown(), this.type());
    return ret;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item)

Example 84 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class AllAnySubQueryHandler method rowResponse.

@Override
public boolean rowResponse(byte[] rowNull, RowDataPacket rowPacket, boolean isLeft, BackendConnection conn) {
    lock.lock();
    try {
        if (terminate.get()) {
            return true;
        }
        RowDataPacket row = rowPacket;
        if (row == null) {
            row = new RowDataPacket(this.fieldPackets.size());
            row.read(rowNull);
        }
        sourceField.setPtr(row.getValue(0));
        Item value = itemSubQuery.getFiled().getResultItem();
        if (itemSubQuery.getValue().size() == 0) {
            itemSubQuery.getValue().add(value);
            tmpRow = row;
        } else if (itemSubQuery.getValue().size() == 1) {
            handleNewRow(row, value);
        } else {
        // ignore row
        }
    } finally {
        lock.unlock();
    }
    return false;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 85 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class InSubQueryHandler method rowResponse.

@Override
public boolean rowResponse(byte[] rowNull, RowDataPacket rowPacket, boolean isLeft, BackendConnection conn) {
    lock.lock();
    try {
        if (terminate.get()) {
            return true;
        }
        if (++rowCount > maxPartSize * maxConnSize) {
            String errMessage = "sub query too much rows!";
            LOGGER.info(errMessage);
            genErrorPackage(ErrorCode.ER_UNKNOWN_ERROR, errMessage);
            conn.close(errMessage);
            try {
                tempDoneCallBack.call();
            } catch (Exception callback) {
                LOGGER.info("callback exception!", callback);
            }
            return true;
        }
        RowDataPacket row = rowPacket;
        if (row == null) {
            row = new RowDataPacket(this.fieldPackets.size());
            row.read(rowNull);
        }
        sourceField.setPtr(row.getValue(0));
        Item value = itemSubQuery.getFiled().getResultItem();
        if (value != null) {
            itemSubQuery.getValue().add(value);
        }
    } finally {
        lock.unlock();
    }
    return false;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) ItemString(com.actiontech.dble.plan.common.item.ItemString)

Aggregations

Item (com.actiontech.dble.plan.common.item.Item)122 ArrayList (java.util.ArrayList)26 Order (com.actiontech.dble.plan.Order)16 PlanNode (com.actiontech.dble.plan.node.PlanNode)14 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)10 ItemField (com.actiontech.dble.plan.common.item.ItemField)10 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)7 MySqlSelectQueryBlock (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock)7 Test (org.junit.Test)7 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)6 ItemFuncEqual (com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual)6 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)6 JoinNode (com.actiontech.dble.plan.node.JoinNode)6 SQLAggregateExpr (com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)6 ItemFunc (com.actiontech.dble.plan.common.item.function.ItemFunc)5 ItemInt (com.actiontech.dble.plan.common.item.ItemInt)4 ItemString (com.actiontech.dble.plan.common.item.ItemString)4 BigDecimal (java.math.BigDecimal)4 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)3 NamedField (com.actiontech.dble.plan.NamedField)3