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();
}
}
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);
}
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);
}
}
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);
}
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();
}
}
Aggregations