コード例 #1
0
ファイル: LocalResult.java プロジェクト: openddal/openddal
 /**
  * Construct a local result set by reading all data from a regular result set.
  *
  * @param session the session
  * @param rs the result set
  * @param maxrows the maximum number of rows to read (0 for no limit)
  * @return the local result set
  */
 public static LocalResult read(Session session, ResultSet rs, int maxrows) {
   Expression[] cols = Expression.getExpressionColumns(session, rs);
   int columnCount = cols.length;
   LocalResult result = new LocalResult(session, cols, columnCount);
   try {
     for (int i = 0; (maxrows == 0 || i < maxrows) && rs.next(); i++) {
       Value[] list = new Value[columnCount];
       for (int j = 0; j < columnCount; j++) {
         int type = result.getColumnType(j);
         list[j] = DataType.readValue(rs, j + 1, type);
       }
       result.addRow(list);
     }
   } catch (SQLException e) {
     throw DbException.convert(e);
   }
   result.done();
   return result;
 }
コード例 #2
0
ファイル: LocalResult.java プロジェクト: openddal/openddal
 /**
  * Create a shallow copy of the result set. The data and a temporary table (if there is any) is
  * not copied.
  *
  * @param targetSession the session of the copy
  * @return the copy if possible, or null if copying is not possible
  */
 public LocalResult createShallowCopy(Session targetSession) {
   if (rows == null || rows.size() < rowCount) {
     return null;
   }
   LocalResult copy = new LocalResult();
   copy.maxMemoryRows = this.maxMemoryRows;
   copy.session = targetSession;
   copy.visibleColumnCount = this.visibleColumnCount;
   copy.expressions = this.expressions;
   copy.rowId = -1;
   copy.rowCount = this.rowCount;
   copy.rows = this.rows;
   copy.sort = this.sort;
   copy.distinctRows = this.distinctRows;
   copy.distinct = distinct;
   copy.randomAccess = randomAccess;
   copy.currentRow = null;
   copy.offset = 0;
   copy.limit = -1;
   return copy;
 }