Search in sources :

Example 76 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class SendMakeHandler method fieldEofResponse.

@Override
public void fieldEofResponse(byte[] headerNull, List<byte[]> fieldsNull, List<FieldPacket> fieldPackets, byte[] eofNull, boolean isLeft, BackendConnection conn) {
    lock.lock();
    try {
        if (terminate.get())
            return;
        this.fieldPackets = fieldPackets;
        this.sourceFields = HandlerTool.createFields(this.fieldPackets);
        for (Item sel : selects) {
            Item tmpItem = HandlerTool.createItem(sel, this.sourceFields, 0, isAllPushDown(), type());
            tmpItem.setItemName(sel.getItemName());
            String selAlias = sel.getAlias();
            if (selAlias != null || tableAlias != null) {
                // remove the added tmp FNAF
                if (StringUtils.indexOf(selAlias, Item.FNAF) == 0)
                    selAlias = StringUtils.substring(selAlias, Item.FNAF.length());
            }
            tmpItem = HandlerTool.createRefItem(tmpItem, schema, table, tableAlias, selAlias);
            this.selItems.add(tmpItem);
        }
        List<FieldPacket> newFieldPackets = new ArrayList<>();
        for (Item selItem : this.selItems) {
            FieldPacket tmpFp = new FieldPacket();
            selItem.makeField(tmpFp);
            /* Keep things compatible for old clients */
            if (tmpFp.getType() == FieldTypes.MYSQL_TYPE_VARCHAR.numberValue())
                tmpFp.setType(FieldTypes.MYSQL_TYPE_VAR_STRING.numberValue());
            newFieldPackets.add(tmpFp);
        }
        nextHandler.fieldEofResponse(null, null, newFieldPackets, null, this.isLeft, conn);
    } finally {
        lock.unlock();
    }
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) ArrayList(java.util.ArrayList) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 77 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class UnionHandler method unionFieldPackets.

/**
 * merge field packets with field packets2
 * eg: int field union double field ->double field
 *
 * @param fieldPackets fieldPackets
 * @param fieldPackets2 fieldPackets2
 */
private List<FieldPacket> unionFieldPackets(List<FieldPacket> fieldPackets, List<FieldPacket> fieldPackets2) {
    List<FieldPacket> newFps = new ArrayList<>();
    for (int i = 0; i < fieldPackets.size(); i++) {
        FieldPacket fp1 = fieldPackets.get(i);
        FieldPacket fp2 = fieldPackets2.get(i);
        FieldPacket newFp = unionFieldPacket(fp1, fp2);
        newFps.add(newFp);
    }
    return newFps;
}
Also used : ArrayList(java.util.ArrayList) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 78 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class UnionHandler method checkFieldPackets.

private void checkFieldPackets() {
    for (int i = 0; i < selects.size(); i++) {
        FieldPacket fp = this.fieldPackets.get(i);
        Item sel = selects.get(i);
        fp.setName(sel.getItemName().getBytes());
        fp.setDb(null);
        fp.setTable(null);
        fp.setOrgTable(null);
    }
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 79 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class DirectGroupByHandler method sendGroupFieldPackets.

/**
 * aggregate functions result and origin rowdatapacket
 */
private List<FieldPacket> sendGroupFieldPackets(MySQLConnection conn) {
    List<FieldPacket> newFps = new ArrayList<>();
    for (ItemSum sum1 : sums) {
        Item sum = sum1;
        FieldPacket tmp = new FieldPacket();
        sum.makeField(tmp);
        newFps.add(tmp);
    }
    newFps.addAll(this.fieldPackets);
    nextHandler.fieldEofResponse(null, null, newFps, null, this.isLeft, conn);
    return newFps;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) ItemSum(com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum) ArrayList(java.util.ArrayList) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 80 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class OrderedGroupByHandler method sendGroupFieldPackets.

/**
 * new fieldPackets: generated function result + origin fieldpackets
 */
private void sendGroupFieldPackets(BackendConnection conn) {
    List<FieldPacket> newFps = new ArrayList<>();
    for (ItemSum sum1 : sums) {
        Item sum = sum1;
        FieldPacket tmp = new FieldPacket();
        sum.makeField(tmp);
        newFps.add(tmp);
    }
    newFps.addAll(this.fieldPackets);
    nextHandler.fieldEofResponse(null, null, newFps, null, this.isLeft, conn);
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) ItemSum(com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum) ArrayList(java.util.ArrayList) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Aggregations

FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)81 EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)65 ByteBuffer (java.nio.ByteBuffer)64 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)59 ArrayList (java.util.ArrayList)9 Map (java.util.Map)8 NIOProcessor (com.actiontech.dble.net.NIOProcessor)6 ResultSetHeaderPacket (com.actiontech.dble.net.mysql.ResultSetHeaderPacket)6 Item (com.actiontech.dble.plan.common.item.Item)6 UserStat (com.actiontech.dble.statistic.stat.UserStat)6 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)4 PackageBufINf (com.actiontech.dble.manager.handler.PackageBufINf)4 RowDataComparator (com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)3 ServerConfig (com.actiontech.dble.config.ServerConfig)3 FrontendConnection (com.actiontech.dble.net.FrontendConnection)3 Field (com.actiontech.dble.plan.common.field.Field)3 BackendConnection (com.actiontech.dble.backend.BackendConnection)2 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)2 TableConfig (com.actiontech.dble.config.model.TableConfig)2 UserConfig (com.actiontech.dble.config.model.UserConfig)2