Search in sources :

Example 1 with RowDataComparator

use of com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator 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 RowDataComparator

use of com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator in project dble by actiontech.

the class NotInHandler 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());
        nextHandler.fieldEofResponse(null, null, leftFieldPackets, null, this.isLeft, conn);
        // logger.debug("all ready");
        startOwnThread(conn);
    }
}
Also used : RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Example 3 with RowDataComparator

use of com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator in project dble by actiontech.

the class AllAnySubQueryHandler method fieldEofResponse.

@Override
public void fieldEofResponse(byte[] headerNull, List<byte[]> fieldsNull, List<FieldPacket> fieldPackets, byte[] eofNull, boolean isLeft, BackendConnection conn) {
    if (terminate.get()) {
        return;
    }
    lock.lock();
    try {
        // create field for first time
        if (this.fieldPackets.isEmpty()) {
            this.fieldPackets = fieldPackets;
            sourceField = HandlerTool.createField(this.fieldPackets.get(0));
            Item select = itemSubQuery.getSelect();
            select.setPushDownName(select.getAlias());
            Item tmpItem = HandlerTool.createItem(select, Collections.singletonList(this.sourceField), 0, isAllPushDown(), type());
            itemSubQuery.setFiled(tmpItem);
            rowComparator = new RowDataComparator(this.fieldPackets, Collections.singletonList(new Order(select)), this.isAllPushDown(), this.type());
        }
    } finally {
        lock.unlock();
    }
}
Also used : Order(com.actiontech.dble.plan.Order) Item(com.actiontech.dble.plan.common.item.Item) RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Example 4 with RowDataComparator

use of com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator 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 5 with RowDataComparator

use of com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator in project dble by actiontech.

the class OrderByHandler method fieldEofResponse.

@Override
public void fieldEofResponse(byte[] headerNull, List<byte[]> fieldsNull, final List<FieldPacket> fieldPackets, byte[] eofNull, boolean isLeft, final BackendConnection conn) {
    if (terminate.get())
        return;
    if (this.pool == null)
        this.pool = DbleServer.getInstance().getBufferPool();
    this.fieldPackets = fieldPackets;
    RowDataComparator cmp = new RowDataComparator(this.fieldPackets, orders, isAllPushDown(), type());
    localResult = new SortedLocalResult(pool, fieldPackets.size(), cmp, CharsetUtil.getJavaCharset(conn.getCharset().getResults())).setMemSizeController(session.getOrderBufferMC());
    nextHandler.fieldEofResponse(null, null, fieldPackets, null, this.isLeft, conn);
    startOwnThread(conn);
}
Also used : SortedLocalResult(com.actiontech.dble.backend.mysql.store.SortedLocalResult) RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Aggregations

RowDataComparator (com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)9 Order (com.actiontech.dble.plan.Order)4 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)3 Field (com.actiontech.dble.plan.common.field.Field)3 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)3 DistinctLocalResult (com.actiontech.dble.backend.mysql.store.DistinctLocalResult)2 Item (com.actiontech.dble.plan.common.item.Item)2 GroupByBucket (com.actiontech.dble.backend.mysql.nio.handler.query.impl.groupby.directgroupby.GroupByBucket)1 GroupByLocalResult (com.actiontech.dble.backend.mysql.store.GroupByLocalResult)1 SortedLocalResult (com.actiontech.dble.backend.mysql.store.SortedLocalResult)1 ResultStore (com.actiontech.dble.plan.common.external.ResultStore)1 ItemField (com.actiontech.dble.plan.common.item.ItemField)1 ArrayList (java.util.ArrayList)1