Search in sources :

Example 1 with DistinctLocalResult

use of com.actiontech.dble.backend.mysql.store.DistinctLocalResult 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 DistinctLocalResult

use of com.actiontech.dble.backend.mysql.store.DistinctLocalResult 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)

Aggregations

RowDataComparator (com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)2 DistinctLocalResult (com.actiontech.dble.backend.mysql.store.DistinctLocalResult)2 Order (com.actiontech.dble.plan.Order)2 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)1 ResultStore (com.actiontech.dble.plan.common.external.ResultStore)1 Field (com.actiontech.dble.plan.common.field.Field)1 Item (com.actiontech.dble.plan.common.item.Item)1 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)1