Search in sources :

Example 1 with GroupByLocalResult

use of com.actiontech.dble.backend.mysql.store.GroupByLocalResult in project dble by actiontech.

the class DirectGroupByHandler method fieldEofResponse.

@Override
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);
    for (ItemSum sumFunc : referredSumFunctions) {
        ItemSum sum = (ItemSum) (HandlerTool.createItem(sumFunc, sourceFields, 0, this.isAllPushDown(), this.type()));
        sums.add(sum);
    }
    prepareSumAggregators(sums, true);
    setupSumFunctions(sums);
    /* group fieldpackets are front of the origin */
    sendGroupFieldPackets((MySQLConnection) conn);
    // row in localresult is DGRowPacket which is added aggregate functions result from origin rowdatapacket
    localResultFps = this.fieldPackets;
    List<ItemSum> localResultReferredSums = referredSumFunctions;
    RowDataComparator comparator = new RowDataComparator(this.localResultFps, this.groupBys, this.isAllPushDown(), this.type());
    groupLocalResult = new GroupByLocalResult(pool, localResultFps.size(), comparator, localResultFps, localResultReferredSums, this.isAllPushDown(), CharsetUtil.getJavaCharset(conn.getCharset().getResults())).setMemSizeController(session.getOtherBufferMC());
    for (int i = 0; i < bucketSize; i++) {
        RowDataComparator tmpComparator = new RowDataComparator(this.localResultFps, this.groupBys, this.isAllPushDown(), this.type());
        GroupByBucket bucket = new GroupByBucket(queue, outQueue, pool, localResultFps.size(), tmpComparator, localResultFps, localResultReferredSums, this.isAllPushDown(), CharsetUtil.getJavaCharset(conn.getCharset().getResults()));
        bucket.setMemSizeController(session.getOtherBufferMC());
        buckets.add(bucket);
        bucket.start();
    }
    if (this.groupStart.compareAndSet(false, true)) {
        startOwnThread(conn);
    }
}
Also used : GroupByLocalResult(com.actiontech.dble.backend.mysql.store.GroupByLocalResult) Field(com.actiontech.dble.plan.common.field.Field) ItemSum(com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum) GroupByBucket(com.actiontech.dble.backend.mysql.nio.handler.query.impl.groupby.directgroupby.GroupByBucket) RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Aggregations

GroupByBucket (com.actiontech.dble.backend.mysql.nio.handler.query.impl.groupby.directgroupby.GroupByBucket)1 RowDataComparator (com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)1 GroupByLocalResult (com.actiontech.dble.backend.mysql.store.GroupByLocalResult)1 Field (com.actiontech.dble.plan.common.field.Field)1 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)1