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);
}
}
Aggregations