Search in sources :

Example 21 with ItemSum

use of com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum in project dble by actiontech.

the class OrderedGroupByHandler method sendGroupRowPacket.

private void sendGroupRowPacket(MySQLConnection conn) {
    RowDataPacket newRp = new RowDataPacket(this.fieldPackets.size() + this.sums.size());
    for (ItemSum sum : this.sums) {
        byte[] tmp = sum.getRowPacketByte();
        newRp.add(tmp);
    }
    for (int i = 0; i < originRp.getFieldCount(); i++) {
        newRp.add(originRp.getValue(i));
    }
    nextHandler.rowResponse(null, newRp, this.isLeft, conn);
}
Also used : ItemSum(com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 22 with ItemSum

use of com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum in project dble by actiontech.

the class OrderedGroupByHandler method prepareSumAggregators.

/**
 * see Sql_executor.cc
 *
 * @return
 */
protected void prepareSumAggregators(List<ItemSum> functions, List<ItemSum> sumFunctions, List<FieldPacket> packets, boolean isAllPushDown, boolean needDistinct, MySQLConnection conn) {
    LOGGER.info("prepare_sum_aggregators");
    for (int i = 0; i < functions.size(); i++) {
        ItemSum func = functions.get(i);
        ResultStore store = null;
        if (func.hasWithDistinct()) {
            ItemSum selFunc = sumFunctions.get(i);
            List<Order> orders = HandlerTool.makeOrder(selFunc.arguments());
            RowDataComparator distinctCmp = new RowDataComparator(packets, orders, isAllPushDown, this.type());
            store = new DistinctLocalResult(pool, packets.size(), distinctCmp, this.charset).setMemSizeController(session.getOtherBufferMC());
            distinctStores.add(store);
        }
        func.setAggregator(needDistinct && func.hasWithDistinct() ? AggregatorType.DISTINCT_AGGREGATOR : AggregatorType.SIMPLE_AGGREGATOR, store);
    }
}
Also used : Order(com.actiontech.dble.plan.Order) DistinctLocalResult(com.actiontech.dble.backend.mysql.store.DistinctLocalResult) ItemSum(com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum) ResultStore(com.actiontech.dble.plan.common.external.ResultStore) RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Example 23 with ItemSum

use of com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum in project dble by actiontech.

the class OrderedGroupByHandler method sendGroupFieldPackets.

/**
 * new fieldPackets: generated function result + origin fieldpackets
 */
private void sendGroupFieldPackets(BackendConnection conn) {
    List<FieldPacket> newFps = new ArrayList<>();
    for (ItemSum sum1 : sums) {
        Item sum = sum1;
        FieldPacket tmp = new FieldPacket();
        sum.makeField(tmp);
        newFps.add(tmp);
    }
    newFps.addAll(this.fieldPackets);
    nextHandler.fieldEofResponse(null, null, newFps, null, this.isLeft, conn);
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) ItemSum(com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum) ArrayList(java.util.ArrayList) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Aggregations

ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)23 DGRowPacket (com.actiontech.dble.backend.mysql.nio.handler.query.impl.groupby.directgroupby.DGRowPacket)8 Item (com.actiontech.dble.plan.common.item.Item)6 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)5 ArrayList (java.util.ArrayList)4 RowDataComparator (com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)3 Field (com.actiontech.dble.plan.common.field.Field)3 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)2 Order (com.actiontech.dble.plan.Order)2 ItemFunc (com.actiontech.dble.plan.common.item.function.ItemFunc)2 DirectGroupByHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.groupby.DirectGroupByHandler)1 OrderedGroupByHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.groupby.OrderedGroupByHandler)1 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 ResultStore (com.actiontech.dble.plan.common.external.ResultStore)1 ItemField (com.actiontech.dble.plan.common.item.ItemField)1 ItemInt (com.actiontech.dble.plan.common.item.ItemInt)1 ItemScalarSubQuery (com.actiontech.dble.plan.common.item.subquery.ItemScalarSubQuery)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1