use of io.mycat.net.mysql.RowDataPacket in project Mycat-Server by MyCATApache.
the class ShowRouter method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = eof.write(buffer, c, true);
// write rows
byte packetId = eof.packetId;
for (NIOProcessor p : MycatServer.getInstance().getProcessors()) {
RowDataPacket row = getRow(p, c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// write buffer
c.write(buffer);
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat-Server by MyCATApache.
the class ShowRouter method getRow.
private static RowDataPacket getRow(NIOProcessor processor, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(processor.getName().getBytes());
row.add(null);
row.add(null);
row.add(null);
row.add(null);
return row;
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat-Server by MyCATApache.
the class ShowSQLCondition method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = eof.write(buffer, c, true);
// write rows
byte packetId = eof.packetId;
String key = QueryConditionAnalyzer.getInstance().getKey();
List<Map.Entry<Object, AtomicLong>> list = QueryConditionAnalyzer.getInstance().getValues();
if (list != null) {
int size = list.size();
long total = 0L;
for (int i = 0; i < size; i++) {
Map.Entry<Object, AtomicLong> entry = list.get(i);
Object value = entry.getKey();
Long count = entry.getValue().get();
total += count;
RowDataPacket row = getRow(i, key, value.toString(), count, c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
RowDataPacket vk_row = getRow(size + 1, key + ".valuekey", "size", size, c.getCharset());
vk_row.packetId = ++packetId;
buffer = vk_row.write(buffer, c, true);
RowDataPacket vc_row = getRow(size + 2, key + ".valuecount", "total", total, c.getCharset());
vc_row.packetId = ++packetId;
buffer = vc_row.write(buffer, c, true);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// write buffer
c.write(buffer);
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat-Server by MyCATApache.
the class ShowSQLCondition method getRow.
private static RowDataPacket getRow(int i, String key, String value, long count, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(LongUtil.toBytes(i));
row.add(StringUtil.encode(key, charset));
row.add(StringUtil.encode(value, charset));
row.add(LongUtil.toBytes(count));
return row;
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat-Server by MyCATApache.
the class ShowSQLExecute method getRow.
private static RowDataPacket getRow(long id, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(LongUtil.toBytes(id));
row.add(LongUtil.toBytes(100L));
row.add(StringUtil.encode(nf.format(898.9), charset));
row.add(StringUtil.encode(nf.format(8.8), charset));
row.add(StringUtil.encode(nf.format(1.0), charset));
return row;
}
Aggregations