Search in sources :

Example 6 with RowDataPacket

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

the class JoinHandler method connectLeftAndRight.

/**
 * @param leftRows
 * @param rightRows
 * @param conn
 * @return if is interrupted by next handler ,return true,else false
 * @throws Exception
 */
private boolean connectLeftAndRight(LocalResult leftRows, LocalResult rightRows, MySQLConnection conn) throws Exception {
    RowDataPacket leftRow = null;
    RowDataPacket rightRow = null;
    try {
        while ((leftRow = leftRows.next()) != null) {
            // @bug 1097
            int matchCount = 0;
            while ((rightRow = rightRows.next()) != null) {
                RowDataPacket rowPacket = new RowDataPacket(leftFieldPackets.size() + rightFieldPackets.size());
                for (byte[] value : leftRow.fieldValues) {
                    rowPacket.add(value);
                }
                for (byte[] value : rightRow.fieldValues) {
                    rowPacket.add(value);
                }
                if (otherJoinOnItem != null) {
                    HandlerTool.initFields(joinRowFields, rowPacket.fieldValues);
                    if (!otherJoinOnItem.valBool())
                        continue;
                }
                matchCount++;
                if (nextHandler.rowResponse(null, rowPacket, isLeft, conn))
                    return true;
            }
            // send left row and null
            if (matchCount == 0 && isLeftJoin) {
                RowDataPacket rowPacket = new RowDataPacket(leftFieldPackets.size() + rightFieldPackets.size());
                for (byte[] value : leftRow.fieldValues) {
                    rowPacket.add(value);
                }
                for (int i = 0; i < rightFieldPackets.size(); i++) {
                    rowPacket.add(null);
                }
                if (nextHandler.rowResponse(null, rowPacket, isLeft, conn))
                    return true;
            }
            rightRows.reset();
        }
        return false;
    } finally {
        leftRows.close();
        rightRows.close();
    }
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 7 with RowDataPacket

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

the class JoinHandler method terminateThread.

@Override
protected void terminateThread() throws Exception {
    RowDataPacket eofRow = new RowDataPacket(0);
    addEndRowToDeque(eofRow, leftFieldPackets.size(), leftQueue);
    RowDataPacket eofRow2 = new RowDataPacket(0);
    addEndRowToDeque(eofRow2, rightFieldPackets.size(), rightQueue);
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 8 with RowDataPacket

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

the class NotInHandler method rowEofResponse.

@Override
public void rowEofResponse(byte[] data, boolean isLeft, BackendConnection conn) {
    LOGGER.info("roweof");
    if (terminate.get()) {
        return;
    }
    RowDataPacket eofRow = new RowDataPacket(0);
    try {
        if (isLeft) {
            // logger.debug("row eof left");
            addRowToDeque(eofRow, leftFieldPackets.size(), leftQueue, leftComparator);
        } else {
            // logger.debug("row eof right");
            addRowToDeque(eofRow, rightFieldPackets.size(), rightQueue, rightComparator);
        }
    } catch (Exception e) {
        LOGGER.info("not in rowEof exception", e);
    }
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 9 with RowDataPacket

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

the class NotInHandler method terminateThread.

@Override
protected void terminateThread() throws Exception {
    RowDataPacket eofRow = new RowDataPacket(0);
    addEndRowToDeque(eofRow, leftFieldPackets.size(), leftQueue);
    RowDataPacket eofRow2 = new RowDataPacket(0);
    addEndRowToDeque(eofRow2, rightFieldPackets.size(), rightQueue);
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 10 with RowDataPacket

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

the class NotInHandler method takeFirst.

private LocalResult takeFirst(FairLinkedBlockingDeque<LocalResult> deque) throws InterruptedException {
    deque.waitUtilCount(1);
    LocalResult result = deque.peekFirst();
    RowDataPacket lastRow = result.getLastRow();
    if (lastRow.getFieldCount() == 0)
        return deque.takeFirst();
    else {
        deque.waitUtilCount(2);
        return deque.takeFirst();
    }
}
Also used : LocalResult(com.actiontech.dble.backend.mysql.store.LocalResult) UnSortedLocalResult(com.actiontech.dble.backend.mysql.store.UnSortedLocalResult) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Aggregations

RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)141 EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)59 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)59 ByteBuffer (java.nio.ByteBuffer)59 ServerConfig (com.actiontech.dble.config.ServerConfig)8 NIOProcessor (com.actiontech.dble.net.NIOProcessor)8 Map (java.util.Map)8 PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)7 PhysicalDatasource (com.actiontech.dble.backend.datasource.PhysicalDatasource)7 MySQLConnection (com.actiontech.dble.backend.mysql.nio.MySQLConnection)7 LocalResult (com.actiontech.dble.backend.mysql.store.LocalResult)6 UnSortedLocalResult (com.actiontech.dble.backend.mysql.store.UnSortedLocalResult)6 DBHeartbeat (com.actiontech.dble.backend.heartbeat.DBHeartbeat)5 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)5 UserStat (com.actiontech.dble.statistic.stat.UserStat)5 BackendConnection (com.actiontech.dble.backend.BackendConnection)4 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)4 FrontendConnection (com.actiontech.dble.net.FrontendConnection)4 ResultSetHeaderPacket (com.actiontech.dble.net.mysql.ResultSetHeaderPacket)4 LinkedList (java.util.LinkedList)4