Search in sources :

Example 1 with TempTableException

use of com.actiontech.dble.plan.common.exception.TempTableException in project dble by actiontech.

the class TempTableHandler 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 {
        if (this.fieldPackets.isEmpty()) {
            this.fieldPackets = fieldPackets;
            tempTable.setFieldPackets(this.fieldPackets);
            tempTable.setCharset(conn.getCharset().getResults());
            tempTable.setRowsStore(new UnSortedLocalResult(fieldPackets.size(), DbleServer.getInstance().getBufferPool(), CharsetUtil.getJavaCharset(conn.getCharset().getResults())).setMemSizeController(session.getOtherBufferMC()));
            List<Field> fields = HandlerTool.createFields(this.fieldPackets);
            sourceSelIndex = HandlerTool.findField(sourceSel, fields, 0);
            if (sourceSelIndex < 0)
                throw new TempTableException("sourcesel [" + sourceSel.toString() + "] not found in fields");
            sourceField = fields.get(sourceSelIndex);
            if (nextHandler != null) {
                nextHandler.fieldEofResponse(headerNull, fieldsNull, fieldPackets, eofNull, this.isLeft, conn);
            } else {
                throw new TempTableException("unexpected nextHandler is null");
            }
        }
    } finally {
        lock.unlock();
    }
}
Also used : Field(com.actiontech.dble.plan.common.field.Field) TempTableException(com.actiontech.dble.plan.common.exception.TempTableException) UnSortedLocalResult(com.actiontech.dble.backend.mysql.store.UnSortedLocalResult)

Example 2 with TempTableException

use of com.actiontech.dble.plan.common.exception.TempTableException 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();
    }
}
Also used : TempTableException(com.actiontech.dble.plan.common.exception.TempTableException) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) TempTableException(com.actiontech.dble.plan.common.exception.TempTableException)

Example 3 with TempTableException

use of com.actiontech.dble.plan.common.exception.TempTableException in project dble by actiontech.

the class TempTableHandler method rowResponse.

@Override
public boolean rowResponse(byte[] rowNull, RowDataPacket rowPacket, boolean isLeft, BackendConnection conn) {
    lock.lock();
    try {
        if (terminate.get()) {
            return true;
        }
        if (++rowCount > maxPartSize * maxConnSize) {
            String errMessage = "temptable of [" + conn.toString() + "] too much rows,[rows=" + rowCount + "]!";
            LOGGER.info(errMessage);
            throw new TempTableException(errMessage);
        }
        RowDataPacket row = rowPacket;
        if (row == null) {
            row = new RowDataPacket(this.fieldPackets.size());
            row.read(rowNull);
        }
        tempTable.addRow(row);
        sourceField.setPtr(row.getValue(sourceSelIndex));
        valueSet.add(sourceField.valStr());
    } finally {
        lock.unlock();
    }
    return false;
}
Also used : TempTableException(com.actiontech.dble.plan.common.exception.TempTableException) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Aggregations

TempTableException (com.actiontech.dble.plan.common.exception.TempTableException)3 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)2 UnSortedLocalResult (com.actiontech.dble.backend.mysql.store.UnSortedLocalResult)1 Field (com.actiontech.dble.plan.common.field.Field)1