Package org.h2.result
Class SimpleResult
java.lang.Object
org.h2.result.SimpleResult
- All Implemented Interfaces:
AutoCloseable,ResultInterface,ResultTarget
Simple in-memory result.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates new instance of simple result.SimpleResult(String schemaName, String tableName) Creates new instance of simple result. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd column to the result.voidAdd column to the result.voidAdd column to the result.voidAdd the row to the result set.voidclose()Close the result and delete any temporary filescreateShallowCopy(Session targetSession) Create a shallow copy of the result set.Value[]Get the current row.getAlias(int i) Get the column alias name for the column.getColumnName(int i) Get the column name.getColumnType(int i) Get the column data type.intGet the current fetch size for this result set.intgetNullable(int i) Check if this column is nullable.longGet the number of rows in this object.longgetRowId()Get the current row id, starting with 0.getSchemaName(int i) Get the schema name for the column, if one exists.getTableName(int i) Get the table name for the column, if one exists.intGet the number of visible columns.booleanhasNext()Check if this result has more rows to fetch.booleanCheck if the current position is after last row.booleanisClosed()Check if this result set is closed.booleanisIdentity(int i) Check if this is an identity column.booleanisLazy()Check if this a lazy execution result.voidA hint that sorting, offset and limit may be ignored by this result because they were applied during the query.booleanCheck if this result set should be closed, for example because it is buffered using a temporary file.booleannext()Go to the next row.voidreset()Go to the beginning of the result, that means before the first row.voidsetFetchSize(int fetchSize) Set the fetch size for this result set.voidsortRows(Comparator<? super Value[]> comparator) Sort rows in the list.
-
Constructor Details
-
SimpleResult
public SimpleResult()Creates new instance of simple result. -
SimpleResult
Creates new instance of simple result.- Parameters:
schemaName- the name of the schematableName- the name of the table
-
-
Method Details
-
addColumn
public void addColumn(String alias, String columnName, int columnType, long columnPrecision, int columnScale) Add column to the result.- Parameters:
alias- Column's alias.columnName- Column's name.columnType- Column's value type.columnPrecision- Column's precision.columnScale- Column's scale.
-
addColumn
Add column to the result.- Parameters:
columnName- Column's name.columnType- Column's type.
-
addColumn
Add column to the result.- Parameters:
alias- Column's alias.columnName- Column's name.columnType- Column's type.
-
addRow
Description copied from interface:ResultTargetAdd the row to the result set.- Specified by:
addRowin interfaceResultTarget- Parameters:
values- the values
-
reset
public void reset()Description copied from interface:ResultInterfaceGo to the beginning of the result, that means before the first row.- Specified by:
resetin interfaceResultInterface
-
currentRow
Description copied from interface:ResultInterfaceGet the current row.- Specified by:
currentRowin interfaceResultInterface- Returns:
- the row
-
next
public boolean next()Description copied from interface:ResultInterfaceGo to the next row.- Specified by:
nextin interfaceResultInterface- Returns:
- true if a row exists
-
getRowId
public long getRowId()Description copied from interface:ResultInterfaceGet the current row id, starting with 0. -1 is returned when next() was not called yet.- Specified by:
getRowIdin interfaceResultInterface- Returns:
- the row id
-
isAfterLast
public boolean isAfterLast()Description copied from interface:ResultInterfaceCheck if the current position is after last row.- Specified by:
isAfterLastin interfaceResultInterface- Returns:
- true if after last
-
getVisibleColumnCount
public int getVisibleColumnCount()Description copied from interface:ResultInterfaceGet the number of visible columns. More columns may exist internally for sorting or grouping.- Specified by:
getVisibleColumnCountin interfaceResultInterface- Returns:
- the number of columns
-
getRowCount
public long getRowCount()Description copied from interface:ResultInterfaceGet the number of rows in this object.- Specified by:
getRowCountin interfaceResultInterface- Specified by:
getRowCountin interfaceResultTarget- Returns:
- the number of rows
-
hasNext
public boolean hasNext()Description copied from interface:ResultInterfaceCheck if this result has more rows to fetch.- Specified by:
hasNextin interfaceResultInterface- Returns:
- true if it has
-
needToClose
public boolean needToClose()Description copied from interface:ResultInterfaceCheck if this result set should be closed, for example because it is buffered using a temporary file.- Specified by:
needToClosein interfaceResultInterface- Returns:
- true if close should be called.
-
close
public void close()Description copied from interface:ResultInterfaceClose the result and delete any temporary files- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceResultInterface
-
getAlias
Description copied from interface:ResultInterfaceGet the column alias name for the column.- Specified by:
getAliasin interfaceResultInterface- Parameters:
i- the column number (starting with 0)- Returns:
- the alias name
-
getSchemaName
Description copied from interface:ResultInterfaceGet the schema name for the column, if one exists.- Specified by:
getSchemaNamein interfaceResultInterface- Parameters:
i- the column number (starting with 0)- Returns:
- the schema name or null
-
getTableName
Description copied from interface:ResultInterfaceGet the table name for the column, if one exists.- Specified by:
getTableNamein interfaceResultInterface- Parameters:
i- the column number (starting with 0)- Returns:
- the table name or null
-
getColumnName
Description copied from interface:ResultInterfaceGet the column name.- Specified by:
getColumnNamein interfaceResultInterface- Parameters:
i- the column number (starting with 0)- Returns:
- the column name
-
getColumnType
Description copied from interface:ResultInterfaceGet the column data type.- Specified by:
getColumnTypein interfaceResultInterface- Parameters:
i- the column number (starting with 0)- Returns:
- the column data type
-
isIdentity
public boolean isIdentity(int i) Description copied from interface:ResultInterfaceCheck if this is an identity column.- Specified by:
isIdentityin interfaceResultInterface- Parameters:
i- the column number (starting with 0)- Returns:
- true for identity columns
-
getNullable
public int getNullable(int i) Description copied from interface:ResultInterfaceCheck if this column is nullable.- Specified by:
getNullablein interfaceResultInterface- Parameters:
i- the column number (starting with 0)- Returns:
- Column.NULLABLE_*
-
setFetchSize
public void setFetchSize(int fetchSize) Description copied from interface:ResultInterfaceSet the fetch size for this result set.- Specified by:
setFetchSizein interfaceResultInterface- Parameters:
fetchSize- the new fetch size
-
getFetchSize
public int getFetchSize()Description copied from interface:ResultInterfaceGet the current fetch size for this result set.- Specified by:
getFetchSizein interfaceResultInterface- Returns:
- the fetch size
-
isLazy
public boolean isLazy()Description copied from interface:ResultInterfaceCheck if this a lazy execution result.- Specified by:
isLazyin interfaceResultInterface- Returns:
- true if it is a lazy result
-
isClosed
public boolean isClosed()Description copied from interface:ResultInterfaceCheck if this result set is closed.- Specified by:
isClosedin interfaceResultInterface- Returns:
- true if it is
-
createShallowCopy
Description copied from interface:ResultInterfaceCreate a shallow copy of the result set. The data and a temporary table (if there is any) is not copied.- Specified by:
createShallowCopyin interfaceResultInterface- Parameters:
targetSession- the session of the copy- Returns:
- the copy if possible, or null if copying is not possible
-
limitsWereApplied
public void limitsWereApplied()Description copied from interface:ResultTargetA hint that sorting, offset and limit may be ignored by this result because they were applied during the query. This is useful for WITH TIES clause because result may contain tied rows above limit.- Specified by:
limitsWereAppliedin interfaceResultTarget
-
sortRows
Sort rows in the list.- Parameters:
comparator- the comparator
-