Search in sources :

Example 1 with FieldPacket

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

the class JoinHandler method fieldEofResponse.

@Override
public void fieldEofResponse(byte[] headerNull, List<byte[]> fieldsNull, final List<FieldPacket> fieldPackets, byte[] eofNull, boolean isLeft, final BackendConnection conn) {
    if (this.pool == null)
        this.pool = DbleServer.getInstance().getBufferPool();
    if (isLeft) {
        // logger.debug("field eof left");
        leftFieldPackets = fieldPackets;
        leftComparator = new RowDataComparator(leftFieldPackets, leftOrders, this.isAllPushDown(), this.type());
    } else {
        // logger.debug("field eof right");
        rightFieldPackets = fieldPackets;
        rightComparator = new RowDataComparator(rightFieldPackets, rightOrders, this.isAllPushDown(), this.type());
    }
    if (!fieldSent.compareAndSet(false, true)) {
        this.charset = CharsetUtil.getJavaCharset(conn.getCharset().getResults());
        List<FieldPacket> newFieldPacket = new ArrayList<>();
        newFieldPacket.addAll(leftFieldPackets);
        newFieldPacket.addAll(rightFieldPackets);
        nextHandler.fieldEofResponse(null, null, newFieldPacket, null, this.isLeft, conn);
        otherJoinOnItem = makeOtherJoinOnItem(newFieldPacket, conn);
        // logger.debug("all ready");
        startOwnThread(conn);
    }
}
Also used : ArrayList(java.util.ArrayList) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket) RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Example 2 with FieldPacket

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

the class DistinctHandler method fieldEofResponse.

/**
 * treat all the data from parent as Field Type
 */
public void fieldEofResponse(byte[] headerNull, List<byte[]> fieldsNull, final List<FieldPacket> fieldPackets, byte[] eofNull, boolean isLeft, BackendConnection conn) {
    if (terminate.get())
        return;
    if (this.pool == null)
        this.pool = DbleServer.getInstance().getBufferPool();
    this.fieldPackets = fieldPackets;
    List<Field> sourceFields = HandlerTool.createFields(this.fieldPackets);
    if (this.distinctCols == null) {
        // eg:show tables
        this.distinctCols = new ArrayList<>();
        for (FieldPacket fp : this.fieldPackets) {
            Item sel = HandlerTool.createItemField(fp);
            this.distinctCols.add(sel);
        }
    }
    List<Order> orders = this.fixedOrders;
    if (orders == null)
        orders = HandlerTool.makeOrder(this.distinctCols);
    RowDataComparator comparator = new RowDataComparator(this.fieldPackets, orders, this.isAllPushDown(), type());
    localResult = new DistinctLocalResult(pool, sourceFields.size(), comparator, CharsetUtil.getJavaCharset(conn.getCharset().getResults())).setMemSizeController(session.getOtherBufferMC());
    nextHandler.fieldEofResponse(null, null, this.fieldPackets, null, this.isLeft, conn);
}
Also used : Order(com.actiontech.dble.plan.Order) Field(com.actiontech.dble.plan.common.field.Field) Item(com.actiontech.dble.plan.common.item.Item) DistinctLocalResult(com.actiontech.dble.backend.mysql.store.DistinctLocalResult) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket) RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Example 3 with FieldPacket

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

the class UnionHandler method unionFieldPacket.

private FieldPacket unionFieldPacket(FieldPacket fp1, FieldPacket fp2) {
    FieldPacket union = new FieldPacket();
    union.setCatalog(fp1.getCatalog());
    union.setCharsetIndex(fp1.getCharsetIndex());
    union.setDb(fp1.getDb());
    union.setDecimals((byte) Math.max(fp1.getDecimals(), fp2.getDecimals()));
    union.setDefinition(fp1.getDefinition());
    union.setFlags(fp1.getFlags() | fp2.getFlags());
    union.setLength(Math.max(fp1.getLength(), fp2.getLength()));
    FieldTypes fieldType1 = FieldTypes.valueOf(fp1.getType());
    FieldTypes fieldType2 = FieldTypes.valueOf(fp2.getType());
    FieldTypes mergeFieldType = FieldUtil.fieldTypeMerge(fieldType1, fieldType2);
    union.setType(mergeFieldType.numberValue());
    return union;
}
Also used : FieldTypes(com.actiontech.dble.plan.common.item.FieldTypes) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 4 with FieldPacket

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

the class PacketUtil method getField.

public static FieldPacket getField(String name, int type) {
    FieldPacket packet = new FieldPacket();
    packet.setCharsetIndex(CharsetUtil.getCharsetDefaultIndex(UTF8));
    packet.setName(encode(name, UTF8));
    packet.setType(type);
    return packet;
}
Also used : FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 5 with FieldPacket

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

the class HandlerTool method createFields.

public static List<Field> createFields(List<FieldPacket> fps) {
    List<Field> ret = new ArrayList<>();
    for (FieldPacket fp : fps) {
        Field field = createField(fp);
        ret.add(field);
    }
    return ret;
}
Also used : Field(com.actiontech.dble.plan.common.field.Field) ItemField(com.actiontech.dble.plan.common.item.ItemField) 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