// Return table ordered by total bytes out
  public VoltTable sortByOutput(String tableName) {
    List<ProcOutputRow> sorted = new ArrayList<ProcOutputRow>(m_rowsTable);
    Collections.sort(
        sorted,
        new Comparator<ProcOutputRow>() {
          @Override
          public int compare(ProcOutputRow r1, ProcOutputRow r2) {
            return compareByOutput(r2, r1); // sort descending
          }
        });

    long totalOutput = 0L;
    for (ProcOutputRow row : sorted) {
      totalOutput += (row.avgOUT * row.invocations);
    }

    int kB = 1024;
    int mB = 1024 * kB;
    int gB = 1024 * mB;

    VoltTable result =
        TableShorthand.tableFromShorthand(
            tableName
                + "(TIMESTAMP:BIGINT,"
                + "PROCEDURE:VARCHAR,"
                + "WEIGHTED_PERC:BIGINT,"
                + "INVOCATIONS:BIGINT,"
                + "MIN_RESULT_SIZE:BIGINT,"
                + "MAX_RESULT_SIZE:BIGINT,"
                + "AVG_RESULT_SIZE:BIGINT,"
                + "TOTAL_RESULT_SIZE_MB:BIGINT)");

    for (ProcOutputRow row : sorted) {
      result.addRow(
          row.timestamp,
          row.procedure,
          calculatePercent((row.avgOUT * row.invocations), totalOutput), // % total out
          row.invocations,
          row.minOUT,
          row.maxOUT,
          row.avgOUT,
          (row.avgOUT * row.invocations) / mB // total out
          );
    }
    return result;
  }
Example #2
0
 /** Get a table from shorthand using TableShorthand */
 public static VoltTable quickTable(String shorthand) {
   return TableShorthand.tableFromShorthand(shorthand);
 }