示例#1
0
  /**
   * Format result set.
   *
   * @param rs the rs
   * @return the string
   */
  private String formatResultSet(LensClient.LensClientResultSetWithStats rs) {
    StringBuilder b = new StringBuilder();
    if (rs.getResultSet() != null) {
      QueryResultSetMetadata resultSetMetadata = rs.getResultSet().getResultSetMetadata();
      for (ResultColumn column : resultSetMetadata.getColumns()) {
        b.append(column.getName()).append("\t");
      }
      b.append("\n");
      QueryResult r = rs.getResultSet().getResult();
      if (r instanceof InMemoryQueryResult) {
        InMemoryQueryResult temp = (InMemoryQueryResult) r;
        b.append(temp.toPrettyString());
      } else {
        PersistentQueryResult temp = (PersistentQueryResult) r;
        b.append("Results of query stored at : ").append(temp.getPersistedURI()).append("  ");
        if (null != temp.getNumRows()) {
          b.append(temp.getNumRows()).append(" rows ");
        }
      }
    }

    if (rs.getQuery() != null) {
      long submissionTime = rs.getQuery().getSubmissionTime();
      long endTime = rs.getQuery().getFinishTime();
      b.append("processed in (")
          .append(endTime > 0 ? ((endTime - submissionTime) / 1000) : 0)
          .append(") seconds.\n");
    }
    return b.toString();
  }
示例#2
0
 /**
  * Gets the prepared status.
  *
  * @param ph the ph
  * @return the prepared status
  */
 @CliCommand(value = "prepQuery details", help = "Get prepared query with handle <prepare_handle>")
 public String getPreparedStatus(
     @CliOption(
             key = {"", "prepare_handle"},
             mandatory = true,
             help = "<prepare_handle>")
         String ph) {
   LensPreparedQuery prepared = getClient().getPreparedQuery(QueryPrepareHandle.fromString(ph));
   if (prepared != null) {
     StringBuilder sb =
         new StringBuilder()
             .append("User query:")
             .append(prepared.getUserQuery())
             .append("\n")
             .append("Prepare handle:")
             .append(prepared.getPrepareHandle())
             .append("\n")
             .append("User:"******"\n")
             .append("Prepared at:")
             .append(prepared.getPreparedTime())
             .append("\n")
             .append("Selected driver :")
             .append(prepared.getSelectedDriverName())
             .append("\n")
             .append("Driver query:")
             .append(prepared.getDriverQuery())
             .append("\n");
     if (prepared.getConf() != null) {
       sb.append("Conf:").append(prepared.getConf().getProperties()).append("\n");
     }
     return sb.toString();
   } else {
     return "No such handle";
   }
 }