use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class JoinHandler method fieldEofResponse.
@Override
public void fieldEofResponse(byte[] headerNull, List<byte[]> fieldsNull, final List<FieldPacket> fieldPackets, byte[] eofNull, boolean isLeft, final BackendConnection conn) {
if (this.pool == null)
this.pool = DbleServer.getInstance().getBufferPool();
if (isLeft) {
// logger.debug("field eof left");
leftFieldPackets = fieldPackets;
leftComparator = new RowDataComparator(leftFieldPackets, leftOrders, this.isAllPushDown(), this.type());
} else {
// logger.debug("field eof right");
rightFieldPackets = fieldPackets;
rightComparator = new RowDataComparator(rightFieldPackets, rightOrders, this.isAllPushDown(), this.type());
}
if (!fieldSent.compareAndSet(false, true)) {
this.charset = CharsetUtil.getJavaCharset(conn.getCharset().getResults());
List<FieldPacket> newFieldPacket = new ArrayList<>();
newFieldPacket.addAll(leftFieldPackets);
newFieldPacket.addAll(rightFieldPackets);
nextHandler.fieldEofResponse(null, null, newFieldPacket, null, this.isLeft, conn);
otherJoinOnItem = makeOtherJoinOnItem(newFieldPacket, conn);
// logger.debug("all ready");
startOwnThread(conn);
}
}
use of com.actiontech.dble.net.mysql.FieldPacket 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.net.mysql.FieldPacket in project dble by actiontech.
the class UnionHandler method unionFieldPacket.
private FieldPacket unionFieldPacket(FieldPacket fp1, FieldPacket fp2) {
FieldPacket union = new FieldPacket();
union.setCatalog(fp1.getCatalog());
union.setCharsetIndex(fp1.getCharsetIndex());
union.setDb(fp1.getDb());
union.setDecimals((byte) Math.max(fp1.getDecimals(), fp2.getDecimals()));
union.setDefinition(fp1.getDefinition());
union.setFlags(fp1.getFlags() | fp2.getFlags());
union.setLength(Math.max(fp1.getLength(), fp2.getLength()));
FieldTypes fieldType1 = FieldTypes.valueOf(fp1.getType());
FieldTypes fieldType2 = FieldTypes.valueOf(fp2.getType());
FieldTypes mergeFieldType = FieldUtil.fieldTypeMerge(fieldType1, fieldType2);
union.setType(mergeFieldType.numberValue());
return union;
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class PacketUtil method getField.
public static FieldPacket getField(String name, int type) {
FieldPacket packet = new FieldPacket();
packet.setCharsetIndex(CharsetUtil.getCharsetDefaultIndex(UTF8));
packet.setName(encode(name, UTF8));
packet.setType(type);
return packet;
}
use of com.actiontech.dble.net.mysql.FieldPacket 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