Top Description Fields Constructors Methods
org.h2.result

public Class LocalResult

extends Object
implements ResultInterface, ResultTarget
Class Inheritance
All Implemented Interfaces
org.h2.result.ResultTarget, org.h2.result.ResultInterface, java.lang.AutoCloseable
Imports
java.util.ArrayList, .Arrays, .TreeMap, org.h2.engine.Database, .Session, .SessionLocal, .SysProperties, org.h2.expression.Expression, .ExpressionColumn, org.h2.message.DbException, org.h2.mvstore.db.MVTempResult, org.h2.table.Column, .Table, org.h2.util.Utils, org.h2.value.TypeInfo, .Value, .ValueBigint, .ValueLob, .ValueRow

A local result set contains all row data of a result set. This is the object generated by engine, and it is also used directly by the ResultSet class in the embedded mode. If the result does not fit in memory, it is written to a temporary file.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private Boolean
private Value[]
private boolean
private int[]
private TreeMap<ValueRow, Value[]>
private Expression[]
private ResultExternal
private boolean
private boolean
private long
private boolean
private int
private long
private int
private long
private long
private ArrayList<Value[]>
private final SessionLocal
private SortOrder
private int
private SortOrder

Constructor Summary

AccessConstructor and Description
public
LocalResult()

Construct a local result object.

private
public
LocalResult(SessionLocal
the session
session
,
Expression[]
the expression array
expressions
,
int
the number of visible columns
visibleColumnCount
,
int
the number of columns including visible columns and additional virtual columns for ORDER BY and DISTINCT ON clauses
resultColumnCount
)

Construct a local result object.

Method Summary

Modifier and TypeMethod and Description
public void
addRow(Value...
the row to add
values
)

Implements org.h2.result.ResultTarget.addRow.

Add a row to this object.

public void
addRowForTable(Row
the row to add
row
)

Add a row for a table.

private void
addRowInternal(Value... values)

private void
private void
private void
cloneLobs(Value[] values)

public void
close()

Implements org.h2.result.ResultInterface.close.

Close the result and delete any temporary files

public boolean

Returns:

true if the row exists
containsDistinct
(Value[]
the row
values
)

Check if this result set contains the given row.

public boolean

Returns:

true if there is a NULL value
containsNull
()

Check if this result set contains a NULL value.

private void
public LocalResult

Returns:

the copy if possible, or null if copying is not possible
createShallowCopy
(Session
the session of the copy
targetSession
)

Implements org.h2.result.ResultInterface.createShallowCopy.

Create a shallow copy of the result set.

public Value[]
currentRow()

Implements org.h2.result.ResultInterface.currentRow.

Get the current row.

public Row

Returns:

row
currentRowForTable
()

Retrieve the current row

public void
done()

This method is called after all rows have been added.

public static LocalResult

Returns:

the local result
forTable
(SessionLocal
the session
session
,
Table
the table
table
)

Constructs a new local result object for the specified table.

public String
getAlias(int
the column number (starting with 0)
i
)

Implements org.h2.result.ResultInterface.getAlias.

Get the column alias name for the column.

public String
getColumnName(int
the column number (starting with 0)
i
)

Implements org.h2.result.ResultInterface.getColumnName.

Get the column name.

public TypeInfo
getColumnType(int
the column number (starting with 0)
i
)

Implements org.h2.result.ResultInterface.getColumnType.

Get the column data type.

private ValueRow
public int
getFetchSize()

Implements org.h2.result.ResultInterface.getFetchSize.

Get the current fetch size for this result set.

public int
getNullable(int
the column number (starting with 0)
i
)

Implements org.h2.result.ResultInterface.getNullable.

Check if this column is nullable.

public long
public long
getRowId()

Implements org.h2.result.ResultInterface.getRowId.

Get the current row id, starting with 0.

public String
getSchemaName(int
the column number (starting with 0)
i
)

Implements org.h2.result.ResultInterface.getSchemaName.

Get the schema name for the column, if one exists.

public String
getTableName(int
the column number (starting with 0)
i
)

Implements org.h2.result.ResultInterface.getTableName.

Get the table name for the column, if one exists.

public int
getVisibleColumnCount()

Implements org.h2.result.ResultInterface.getVisibleColumnCount.

Get the number of visible columns.

public boolean
hasNext()

Implements org.h2.result.ResultInterface.hasNext.

Check if this result has more rows to fetch.

public boolean
isAfterLast()

Implements org.h2.result.ResultInterface.isAfterLast.

Check if the current position is after last row.

private boolean

Returns:

whether this result is a distinct result
isAnyDistinct
()

public boolean

Returns:

true if it is
isClosed
()

Implements org.h2.result.ResultInterface.isClosed.

Check if this result set is closed.

public boolean
isIdentity(int
the column number (starting with 0)
i
)

Implements org.h2.result.ResultInterface.isIdentity.

Check if this is an identity column.

public boolean
isLazy()

Implements org.h2.result.ResultInterface.isLazy.

Check if this a lazy execution result.

public void
limitsWereApplied()

Implements org.h2.result.ResultTarget.limitsWereApplied.

A hint that sorting, offset and limit may be ignored by this result because they were applied during the query.

public boolean
needToClose()

Implements org.h2.result.ResultInterface.needToClose.

Check if this result set should be closed, for example because it is buffered using a temporary file.

public boolean
next()

Implements org.h2.result.ResultInterface.next.

Go to the next row.

public void
removeDistinct(Value[]
the row
values
)

Remove the row from the result set if it exists.

public void
reset()

Implements org.h2.result.ResultInterface.reset.

Go to the beginning of the result, that means before the first row.

public void
setDistinct()

Remove duplicate rows.

public void
setDistinct(int[]
distinct indexes
distinctIndexes
)

Remove rows with duplicates in columns with specified indexes.

public void
setFetchPercent(boolean
whether limit expression specifies percentage of rows
fetchPercent
)

public void
setFetchSize(int
the new fetch size
fetchSize
)

Implements org.h2.result.ResultInterface.setFetchSize.

Set the fetch size for this result set.

public void
setForDataChangeDeltaTable()

Sets value collection mode for data change delta tables.

public void
setLimit(long
the limit (-1 means no limit, 0 means no rows)
limit
)

Set the number of rows that this result will return at the maximum.

public void
setMaxMemoryRows(int
Maximum rows count in memory.
maxValue
)

Redefine count of maximum rows holds in memory for the result.

public void
setOffset(long
the offset
offset
)

Set the offset of the first row to return.

public void
setSortOrder(SortOrder
the sort order
sort
)

Sets sort order to be used by this result.

public void
setWithTies(SortOrder
the sort order for tied rows
withTiesSortOrder
)

Enables inclusion of tied rows to result and sets the sort order for tied rows.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
trimExternal(long offset, long limit)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

closedback to summary
private boolean closed
containsLobsback to summary
private boolean containsLobs
containsNullback to summary
private Boolean containsNull
currentRowback to summary
private Value[] currentRow
distinctback to summary
private boolean distinct
distinctIndexesback to summary
private int[] distinctIndexes
distinctRowsback to summary
private TreeMap<ValueRow, Value[]> distinctRows
expressionsback to summary
private Expression[] expressions
externalback to summary
private ResultExternal external
fetchPercentback to summary
private boolean fetchPercent
forDataChangeDeltaTableback to summary
private boolean forDataChangeDeltaTable
limitback to summary
private long limit
limitsWereAppliedback to summary
private boolean limitsWereApplied
maxMemoryRowsback to summary
private int maxMemoryRows
offsetback to summary
private long offset
resultColumnCountback to summary
private int resultColumnCount
rowCountback to summary
private long rowCount
rowIdback to summary
private long rowId
rowsback to summary
private ArrayList<Value[]> rows
sessionback to summary
private final SessionLocal session
sortback to summary
private SortOrder sort
visibleColumnCountback to summary
private int visibleColumnCount
withTiesSortOrderback to summary
private SortOrder withTiesSortOrder

Constructor Detail

LocalResultback to summary
public LocalResult()

Construct a local result object.

LocalResultback to summary
private LocalResult(SessionLocal session)
LocalResultback to summary
public LocalResult(SessionLocal session, Expression[] expressions, int visibleColumnCount, int resultColumnCount)

Construct a local result object.

Parameters
session:SessionLocal

the session

expressions:Expression[]

the expression array

visibleColumnCount:int

the number of visible columns

resultColumnCount:int

the number of columns including visible columns and additional virtual columns for ORDER BY and DISTINCT ON clauses

Method Detail

addRowback to summary
public void addRow(Value... values)

Implements org.h2.result.ResultTarget.addRow.

Add a row to this object.

Parameters
values:Value[]

the row to add

Annotations
@Override
addRowForTableback to summary
public void addRowForTable(Row row)

Add a row for a table.

Parameters
row:Row

the row to add

addRowInternalback to summary
private void addRowInternal(Value... values)
addRowsToDiskback to summary
private void addRowsToDisk()
applyOffsetAndLimitback to summary
private void applyOffsetAndLimit()
cloneLobsback to summary
private void cloneLobs(Value[] values)
closeback to summary
public void close()

Implements org.h2.result.ResultInterface.close.

Doc from org.h2.result.ResultInterface.close.

Close the result and delete any temporary files

Annotations
@Override
containsDistinctback to summary
public boolean containsDistinct(Value[] values)

Check if this result set contains the given row.

Parameters
values:Value[]

the row

Returns:boolean

true if the row exists

containsNullback to summary
public boolean containsNull()

Check if this result set contains a NULL value. This method may reset this result.

Returns:boolean

true if there is a NULL value

createExternalResultback to summary
private void createExternalResult()
createShallowCopyback to summary
public LocalResult createShallowCopy(Session targetSession)

Implements org.h2.result.ResultInterface.createShallowCopy.

Create a shallow copy of the result set. The data and a temporary table (if there is any) is not copied.

Parameters
targetSession:Session

the session of the copy

Returns:LocalResult

the copy if possible, or null if copying is not possible

Annotations
@Override
currentRowback to summary
public Value[] currentRow()

Implements org.h2.result.ResultInterface.currentRow.

Doc from org.h2.result.ResultInterface.currentRow.

Get the current row.

Returns:Value[]

the row

Annotations
@Override
currentRowForTableback to summary
public Row currentRowForTable()

Retrieve the current row

Returns:Row

row

doneback to summary
public void done()

This method is called after all rows have been added.

forTableback to summary
public static LocalResult forTable(SessionLocal session, Table table)

Constructs a new local result object for the specified table.

Parameters
session:SessionLocal

the session

table:Table

the table

Returns:LocalResult

the local result

getAliasback to summary
public String getAlias(int i)

Implements org.h2.result.ResultInterface.getAlias.

Doc from org.h2.result.ResultInterface.getAlias.

Get the column alias name for the column.

Parameters
i:int

the column number (starting with 0)

Returns:String

the alias name

Annotations
@Override
getColumnNameback to summary
public String getColumnName(int i)

Implements org.h2.result.ResultInterface.getColumnName.

Doc from org.h2.result.ResultInterface.getColumnName.

Get the column name.

Parameters
i:int

the column number (starting with 0)

Returns:String

the column name

Annotations
@Override
getColumnTypeback to summary
public TypeInfo getColumnType(int i)

Implements org.h2.result.ResultInterface.getColumnType.

Doc from org.h2.result.ResultInterface.getColumnType.

Get the column data type.

Parameters
i:int

the column number (starting with 0)

Returns:TypeInfo

the column data type

Annotations
@Override
getDistinctRowback to summary
private ValueRow getDistinctRow(Value[] values)
getFetchSizeback to summary
public int getFetchSize()

Implements org.h2.result.ResultInterface.getFetchSize.

Doc from org.h2.result.ResultInterface.getFetchSize.

Get the current fetch size for this result set.

Returns:int

the fetch size

Annotations
@Override
getNullableback to summary
public int getNullable(int i)

Implements org.h2.result.ResultInterface.getNullable.

Doc from org.h2.result.ResultInterface.getNullable.

Check if this column is nullable.

Parameters
i:int

the column number (starting with 0)

Returns:int

Column.NULLABLE_*

Annotations
@Override
getRowCountback to summary
public long getRowCount()

Implements org.h2.result.ResultInterface.getRowCount, org.h2.result.ResultTarget.getRowCount.

Doc from org.h2.result.ResultInterface.getRowCount.

Get the number of rows in this object.

Returns:long

the number of rows

Annotations
@Override
getRowIdback to summary
public long getRowId()

Implements org.h2.result.ResultInterface.getRowId.

Doc from org.h2.result.ResultInterface.getRowId.

Get the current row id, starting with 0. -1 is returned when next() was not called yet.

Returns:long

the row id

Annotations
@Override
getSchemaNameback to summary
public String getSchemaName(int i)

Implements org.h2.result.ResultInterface.getSchemaName.

Doc from org.h2.result.ResultInterface.getSchemaName.

Get the schema name for the column, if one exists.

Parameters
i:int

the column number (starting with 0)

Returns:String

the schema name or null

Annotations
@Override
getTableNameback to summary
public String getTableName(int i)

Implements org.h2.result.ResultInterface.getTableName.

Doc from org.h2.result.ResultInterface.getTableName.

Get the table name for the column, if one exists.

Parameters
i:int

the column number (starting with 0)

Returns:String

the table name or null

Annotations
@Override
getVisibleColumnCountback to summary
public int getVisibleColumnCount()

Implements org.h2.result.ResultInterface.getVisibleColumnCount.

Doc from org.h2.result.ResultInterface.getVisibleColumnCount.

Get the number of visible columns. More columns may exist internally for sorting or grouping.

Returns:int

the number of columns

Annotations
@Override
hasNextback to summary
public boolean hasNext()

Implements org.h2.result.ResultInterface.hasNext.

Doc from org.h2.result.ResultInterface.hasNext.

Check if this result has more rows to fetch.

Returns:boolean

true if it has

Annotations
@Override
isAfterLastback to summary
public boolean isAfterLast()

Implements org.h2.result.ResultInterface.isAfterLast.

Doc from org.h2.result.ResultInterface.isAfterLast.

Check if the current position is after last row.

Returns:boolean

true if after last

Annotations
@Override
isAnyDistinctback to summary
private boolean isAnyDistinct()
Returns:boolean

whether this result is a distinct result

isClosedback to summary
public boolean isClosed()

Implements org.h2.result.ResultInterface.isClosed.

Check if this result set is closed.

Returns:boolean

true if it is

Annotations
@Override
isIdentityback to summary
public boolean isIdentity(int i)

Implements org.h2.result.ResultInterface.isIdentity.

Doc from org.h2.result.ResultInterface.isIdentity.

Check if this is an identity column.

Parameters
i:int

the column number (starting with 0)

Returns:boolean

true for identity columns

Annotations
@Override
isLazyback to summary
public boolean isLazy()

Implements org.h2.result.ResultInterface.isLazy.

Doc from org.h2.result.ResultInterface.isLazy.

Check if this a lazy execution result.

Returns:boolean

true if it is a lazy result

Annotations
@Override
limitsWereAppliedback to summary
public void limitsWereApplied()

Implements org.h2.result.ResultTarget.limitsWereApplied.

Doc from org.h2.result.ResultTarget.limitsWereApplied.

A 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.

Annotations
@Override
needToCloseback to summary
public boolean needToClose()

Implements org.h2.result.ResultInterface.needToClose.

Doc from org.h2.result.ResultInterface.needToClose.

Check if this result set should be closed, for example because it is buffered using a temporary file.

Returns:boolean

true if close should be called.

Annotations
@Override
nextback to summary
public boolean next()

Implements org.h2.result.ResultInterface.next.

Doc from org.h2.result.ResultInterface.next.

Go to the next row.

Returns:boolean

true if a row exists

Annotations
@Override
removeDistinctback to summary
public void removeDistinct(Value[] values)

Remove the row from the result set if it exists.

Parameters
values:Value[]

the row

resetback to summary
public void reset()

Implements org.h2.result.ResultInterface.reset.

Doc from org.h2.result.ResultInterface.reset.

Go to the beginning of the result, that means before the first row.

Annotations
@Override
setDistinctback to summary
public void setDistinct()

Remove duplicate rows.

setDistinctback to summary
public void setDistinct(int[] distinctIndexes)

Remove rows with duplicates in columns with specified indexes.

Parameters
distinctIndexes:int[]

distinct indexes

setFetchPercentback to summary
public void setFetchPercent(boolean fetchPercent)
Parameters
fetchPercent:boolean

whether limit expression specifies percentage of rows

setFetchSizeback to summary
public void setFetchSize(int fetchSize)

Implements org.h2.result.ResultInterface.setFetchSize.

Doc from org.h2.result.ResultInterface.setFetchSize.

Set the fetch size for this result set.

Parameters
fetchSize:int

the new fetch size

Annotations
@Override
setForDataChangeDeltaTableback to summary
public void setForDataChangeDeltaTable()

Sets value collection mode for data change delta tables.

setLimitback to summary
public void setLimit(long limit)

Set the number of rows that this result will return at the maximum.

Parameters
limit:long

the limit (-1 means no limit, 0 means no rows)

setMaxMemoryRowsback to summary
public void setMaxMemoryRows(int maxValue)

Redefine count of maximum rows holds in memory for the result.

Parameters
maxValue:int

Maximum rows count in memory.

See Also
SysProperties#MAX_MEMORY_ROWS
setOffsetback to summary
public void setOffset(long offset)

Set the offset of the first row to return.

Parameters
offset:long

the offset

setSortOrderback to summary
public void setSortOrder(SortOrder sort)

Sets sort order to be used by this result. When rows are presorted by the query this method should not be used.

Parameters
sort:SortOrder

the sort order

setWithTiesback to summary
public void setWithTies(SortOrder withTiesSortOrder)

Enables inclusion of tied rows to result and sets the sort order for tied rows. The specified sort order must be the same as sort order if sort order was set. Passed value will be used if sort order was not set that is possible when rows are presorted.

Parameters
withTiesSortOrder:SortOrder

the sort order for tied rows

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
trimExternalback to summary
private void trimExternal(long offset, long limit)