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