Search in sources :

Example 1 with Field

use of com.actiontech.dble.plan.common.field.Field 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 2 with Field

use of com.actiontech.dble.plan.common.field.Field 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 3 with Field

use of com.actiontech.dble.plan.common.field.Field 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;
    }
}
Also used : Field(com.actiontech.dble.plan.common.field.Field) ItemSum(com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) ArrayList(java.util.ArrayList)

Example 4 with Field

use of com.actiontech.dble.plan.common.field.Field in project dble by actiontech.

the class OrderedGroupByHandler method fieldEofResponse.

@Override
public void fieldEofResponse(byte[] headerNull, List<byte[]> fieldsNull, final List<FieldPacket> fieldPackets, byte[] eofNull, boolean isLeft, BackendConnection conn) {
    this.charset = CharsetUtil.getJavaCharset(conn.getCharset().getResults());
    if (terminate.get())
        return;
    if (this.pool == null)
        this.pool = DbleServer.getInstance().getBufferPool();
    this.fieldPackets = fieldPackets;
    List<Field> sourceFields = HandlerTool.createFields(this.fieldPackets);
    for (ItemSum sumFunc : referredSumFunctions) {
        ItemSum sum = (ItemSum) (HandlerTool.createItem(sumFunc, sourceFields, 0, this.isAllPushDown(), this.type()));
        sums.add(sum);
    }
    comparator = new RowDataComparator(this.fieldPackets, this.groupBys, this.isAllPushDown(), this.type());
    prepareSumAggregators(sums, this.referredSumFunctions, this.fieldPackets, this.isAllPushDown(), true, (MySQLConnection) conn);
    setupSumFunctions(sums);
    sendGroupFieldPackets(conn);
}
Also used : Field(com.actiontech.dble.plan.common.field.Field) ItemSum(com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum) RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Example 5 with Field

use of com.actiontech.dble.plan.common.field.Field in project dble by actiontech.

the class HandlerTool method createFields.

public static List<Field> createFields(List<FieldPacket> fps) {
    List<Field> ret = new ArrayList<>();
    for (FieldPacket fp : fps) {
        Field field = createField(fp);
        ret.add(field);
    }
    return ret;
}
Also used : Field(com.actiontech.dble.plan.common.field.Field) ItemField(com.actiontech.dble.plan.common.item.ItemField) ArrayList(java.util.ArrayList) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Aggregations

Field (com.actiontech.dble.plan.common.field.Field)10 RowDataComparator (com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)3 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)3 ItemField (com.actiontech.dble.plan.common.item.ItemField)3 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)3 Item (com.actiontech.dble.plan.common.item.Item)2 ArrayList (java.util.ArrayList)2 GroupByBucket (com.actiontech.dble.backend.mysql.nio.handler.query.impl.groupby.directgroupby.GroupByBucket)1 DistinctLocalResult (com.actiontech.dble.backend.mysql.store.DistinctLocalResult)1 GroupByLocalResult (com.actiontech.dble.backend.mysql.store.GroupByLocalResult)1 UnSortedLocalResult (com.actiontech.dble.backend.mysql.store.UnSortedLocalResult)1 PackageBufINf (com.actiontech.dble.manager.handler.PackageBufINf)1 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)1 Order (com.actiontech.dble.plan.Order)1 TempTableException (com.actiontech.dble.plan.common.exception.TempTableException)1 MySQLItemVisitor (com.actiontech.dble.plan.visitor.MySQLItemVisitor)1 ByteBuffer (java.nio.ByteBuffer)1