use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class SingleRowSubQueryHandler method rowResponse.
@Override
public boolean rowResponse(byte[] rowNull, RowDataPacket rowPacket, boolean isLeft, BackendConnection conn) {
lock.lock();
try {
if (terminate.get()) {
return true;
}
if (++rowCount > 1) {
String errMessage = "Subquery returns more than 1 row";
LOGGER.info(errMessage);
genErrorPackage(ErrorCode.ER_SUBQUERY_NO_1_ROW, errMessage);
return true;
}
RowDataPacket row = rowPacket;
if (row == null) {
row = new RowDataPacket(this.fieldPackets.size());
row.read(rowNull);
}
if (!itemSubQuery.isField()) {
setSubQueryFiled();
}
sourceField.setPtr(row.getValue(0));
} finally {
lock.unlock();
}
return false;
}
use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class TempTableHandler method rowEofResponse.
@Override
public void rowEofResponse(byte[] eof, boolean isLeft, BackendConnection conn) {
lock.lock();
try {
// callBack after terminated
if (terminate.get()) {
return;
}
tempTable.dataEof();
// locked onTerminate, because terminated may sync with start
tempDoneCallBack.call();
RowDataPacket rp = null;
while ((rp = tempTable.nextRow()) != null) {
nextHandler.rowResponse(null, rp, this.isLeft, conn);
}
nextHandler.rowEofResponse(eof, this.isLeft, conn);
} catch (Exception e) {
LOGGER.info("rowEof exception!", e);
throw new TempTableException("rowEof exception!", e);
} finally {
lock.unlock();
}
}
use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class DirectGroupByHandler method sendGroupRowPacket.
private void sendGroupRowPacket(MySQLConnection conn) {
groupLocalResult.done();
RowDataPacket row = null;
List<Field> localFields = HandlerTool.createFields(localResultFps);
List<ItemSum> sendSums = new ArrayList<>();
for (ItemSum selSum : referredSumFunctions) {
ItemSum sum = (ItemSum) HandlerTool.createItem(selSum, localFields, 0, false, HandlerType.GROUPBY);
sendSums.add(sum);
}
prepareSumAggregators(sendSums, true);
while ((row = groupLocalResult.next()) != null) {
if (sendGroupRowPacket(conn, row, sendSums))
break;
}
}
use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class OrderedGroupByHandler method sendNoRowGroupRowPacket.
/**
* send data to next even no data here. eg: select count(*) from t2 ,if t2 empty,then send 0
*/
private void sendNoRowGroupRowPacket(MySQLConnection conn) {
RowDataPacket newRp = new RowDataPacket(this.fieldPackets.size() + this.sums.size());
// sumfuncs are front
for (ItemSum sum : this.sums) {
sum.noRowsInResult();
byte[] tmp = sum.getRowPacketByte();
newRp.add(tmp);
}
for (int i = 0; i < this.fieldPackets.size(); i++) {
newRp.add(null);
}
originRp = null;
nextHandler.rowResponse(null, newRp, this.isLeft, conn);
}
use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class GroupByLocalResult method add.
/* should group sumfunctions when find a row in rows */
@Override
public void add(RowDataPacket row) {
lock.lock();
try {
if (isClosed)
return;
int index = rows.indexOf(row);
int incrementSize = 0;
if (index >= 0) /* found */
{
RowDataPacket oldRow = rows.get(index);
int oldRowSizeBefore = getRowMemory(oldRow);
onFoundRow(oldRow, row);
int oldRowSizeAfter = getRowMemory(oldRow);
incrementSize = oldRowSizeAfter - oldRowSizeBefore;
} else {
onFirstGroupRow(row);
rows.add(row);
rowCount++;
incrementSize = getRowMemory(row);
}
currentMemory += incrementSize;
boolean needFlush = false;
if (bufferMC != null) {
if (!bufferMC.addSize(incrementSize)) {
needFlush = true;
}
} else if (currentMemory > maxMemory) {
needFlush = true;
}
if (needFlush) {
if (external == null)
external = makeExternal();
addRowsToDisk();
}
} finally {
lock.unlock();
}
}
Aggregations