int getSize(ResultSet rs) {
    try {
      if (rs.getType() == ResultSet.TYPE_FORWARD_ONLY) {
        return -1;
      }
      rs.last();
      int total = rs.getRow();
      rs.beforeFirst();
      return total;
    } catch (SQLException sqle) {
      return -1;
    }
    // JDBC 1 driver error
    catch (AbstractMethodError ame) {
      return -1;
    }
  }
Try to obtain the current size of the specified {@link ResultSet} by jumping to the last row
and getting the row number.

@param rs
         the {@link ResultSet} to get the size for
@return the size, or -1 if it could not be obtained
beeline/src/java/org/apache/hive/beeline/BeeLine.java