use of io.mycat.statistic.stat.SqlResultSet in project Mycat-Server by MyCATApache.
the class ShowSqlResultSet 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;
int i = 0;
Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
for (UserStat userStat : statMap.values()) {
String user = userStat.getUser();
ConcurrentHashMap<String, SqlResultSet> map = userStat.getSqlResultSizeRecorder().getSqlResultSet();
if (map != null) {
for (SqlResultSet sqlResultSet : map.values()) {
RowDataPacket row = getRow(++i, user, sqlResultSet.getSql(), sqlResultSet.getCount(), sqlResultSet.getResultSetSize(), 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);
}
Aggregations