use of com.actiontech.dble.statistic.stat.UserSqlRWStat in project dble by actiontech.
the class ShowSQLSumUser method getRow.
private static RowDataPacket getRow(UserStat userStat, long idx, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(LongUtil.toBytes(idx));
if (userStat == null) {
row.add(StringUtil.encode(("not fond"), charset));
return row;
}
String user = userStat.getUser();
UserSqlRWStat rwStat = userStat.getRWStat();
long r = rwStat.getRCount();
long w = rwStat.getWCount();
String rStr = decimalFormat.format(1.0D * r / (r + w));
int max = rwStat.getConcurrentMax();
row.add(StringUtil.encode(user, charset));
row.add(LongUtil.toBytes(r));
row.add(LongUtil.toBytes(w));
row.add(StringUtil.encode(String.valueOf(rStr), charset));
row.add(StringUtil.encode(String.valueOf(max), charset));
row.add(LongUtil.toBytes(rwStat.getNetInBytes()));
row.add(LongUtil.toBytes(rwStat.getNetOutBytes()));
row.add(StringUtil.encode(rwStat.getExecuteHistogram().toString(), charset));
row.add(StringUtil.encode(rwStat.getTimeHistogram().toString(), charset));
row.add(StringUtil.encode(FormatUtil.formatDate(rwStat.getLastExecuteTime()), charset));
return row;
}
Aggregations