org.h2.result

## Class LocalResult

- java.lang.Object
- - org.h2.result.LocalResult

All Implemented Interfaces:
  ResultInterface, ResultTarget

    public class LocalResult
    extends java.lang.Object
    implements ResultInterface, ResultTarget

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.

### Constructor Summary

Constructors
Constructor and Description
`LocalResult()` Construct a local result object.
`LocalResult(Session session, Expression[] expressions, int visibleColumnCount)` Construct a local result object.

### Method Summary

Methods
`void` `addRow(Value[] values)` Add a row to this object.
`void` `close()` Close the result and delete any temporary files
`boolean` `containsDistinct(Value[] values)` Check if this result set contains the given row.
`LocalResult` `createShallowCopy(Session targetSession)` Create a shallow copy of the result set.
`Value[]` `currentRow()` Get the current row.
`void` `done()` This method is called after all rows have been added.
`java.lang.String` `getAlias(int i)` Get the column alias name for the column.
`java.lang.String` `getColumnName(int i)` Get the column name.
`long` `getColumnPrecision(int i)` Get the precision for this column.
`int` `getColumnScale(int i)` Get the scale for this column.
`int` `getColumnType(int i)` Get the column data type.
`int` `getDisplaySize(int i)` Get the display size for this column.
`int` `getFetchSize()` Get the current fetch size for this result set.
`int` `getNullable(int i)` Check if this column is nullable.
`int` `getRowCount()` Get the number of rows in this object.
`int` `getRowId()` Get the current row id, starting with 0.
`java.lang.String` `getSchemaName(int i)` Get the schema name for the column, if one exists.
`java.lang.String` `getTableName(int i)` Get the table name for the column, if one exists.
`int` `getVisibleColumnCount()` Get the number of visible columns.
`boolean` `isAutoIncrement(int i)` Check if this is an auto-increment column.
`boolean` `isClosed()` Check if this result set is closed.
`boolean` `needToClose()` Check if this result set should be closed, for example because it is buffered using a temporary file.
`boolean` `next()` Go to the next row.
`static LocalResult` `read(Session session, java.sql.ResultSet rs, int maxrows)` Construct a local result set by reading all data from a regular result set.
`void` `removeDistinct(Value[] values)` Remove the row from the result set if it exists.
`void` `reset()` Go to the beginning of the result, that means before the first row.
`void` `setDistinct()` Remove duplicate rows.
`void` `setFetchSize(int fetchSize)` Set the fetch size for this result set.
`void` `setLimit(int limit)` Set the number of rows that this result will return at the maximum.
`void` `setMaxMemoryRows(int maxValue)`
`void` `setOffset(int offset)` Set the offset of the first row to return.
`void` `setRandomAccess()` Random access is required (containsDistinct).
`void` `setSortOrder(SortOrder sort)` Set the sort order.
`java.lang.String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### LocalResult

    public LocalResult()

Construct a local result object.

#### LocalResult

    public LocalResult(Session session,
               Expression[] expressions,
               int visibleColumnCount)

Construct a local result object.

Parameters:
  `session` - the session
  `expressions` - the expression array
  `visibleColumnCount` - the number of visible columns

### Method Detail

#### setMaxMemoryRows

    public void setMaxMemoryRows(int maxValue)

#### read

    public static LocalResult read(Session session,
                   java.sql.ResultSet rs,
                   int maxrows)

Construct a local result set by reading all data from a regular result set.

Parameters:
  `session` - the session
  `rs` - the result set
  `maxrows` - the maximum number of rows to read (0 for no limit)
Returns:
  the local result set

#### createShallowCopy

    public LocalResult createShallowCopy(Session targetSession)

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

Parameters:
  `targetSession` - the session of the copy
Returns:
  the copy if possible, or null if copying is not possible

#### setSortOrder

    public void setSortOrder(SortOrder sort)

Set the sort order.

Parameters:
  `sort` - the sort order

#### setDistinct

    public void setDistinct()

Remove duplicate rows.

#### setRandomAccess

    public void setRandomAccess()

Random access is required (containsDistinct).

#### removeDistinct

    public void removeDistinct(Value[] values)

Remove the row from the result set if it exists.

Parameters:
  `values` - the row

#### containsDistinct

    public boolean containsDistinct(Value[] values)

Check if this result set contains the given row.

Parameters:
  `values` - the row
Returns:
  true if the row exists

#### reset

    public void reset()

Description copied from interface: `ResultInterface`
Go to the beginning of the result, that means before the first row.

Specified by:
  `reset` in interface `ResultInterface`

#### currentRow

    public Value[] currentRow()

Description copied from interface: `ResultInterface`
Get the current row.

Specified by:
  `currentRow` in interface `ResultInterface`
Returns:
  the row

#### next

    public boolean next()

Description copied from interface: `ResultInterface`
Go to the next row.

Specified by:
  `next` in interface `ResultInterface`
Returns:
  true if a row exists

#### getRowId

    public int getRowId()

Description copied from interface: `ResultInterface`
Get the current row id, starting with 0. -1 is returned when next() was not called yet.

Specified by:
  `getRowId` in interface `ResultInterface`
Returns:
  the row id

#### addRow

    public void addRow(Value[] values)

Add a row to this object.

Specified by:
  `addRow` in interface `ResultTarget`
Parameters:
  `values` - the row to add

#### getVisibleColumnCount

    public int getVisibleColumnCount()

Description copied from interface: `ResultInterface`
Get the number of visible columns. More columns may exist internally for sorting or grouping.

Specified by:
  `getVisibleColumnCount` in interface `ResultInterface`
Returns:
  the number of columns

#### done

    public void done()

This method is called after all rows have been added.

#### getRowCount

    public int getRowCount()

Description copied from interface: `ResultInterface`
Get the number of rows in this object.

Specified by:
  `getRowCount` in interface `ResultInterface`
Specified by:
  `getRowCount` in interface `ResultTarget`
Returns:
  the number of rows

#### setLimit

    public void setLimit(int limit)

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

Parameters:
  `limit` - the limit (-1 means no limit, 0 means no rows)

#### needToClose

    public boolean needToClose()

Description copied from interface: `ResultInterface`
Check if this result set should be closed, for example because it is buffered using a temporary file.

Specified by:
  `needToClose` in interface `ResultInterface`
Returns:
  true if close should be called.

#### close

    public void close()

Description copied from interface: `ResultInterface`
Close the result and delete any temporary files

Specified by:
  `close` in interface `ResultInterface`

#### getAlias

    public java.lang.String getAlias(int i)

Description copied from interface: `ResultInterface`
Get the column alias name for the column.

Specified by:
  `getAlias` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  the alias name

#### getTableName

    public java.lang.String getTableName(int i)

Description copied from interface: `ResultInterface`
Get the table name for the column, if one exists.

Specified by:
  `getTableName` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  the table name or null

#### getSchemaName

    public java.lang.String getSchemaName(int i)

Description copied from interface: `ResultInterface`
Get the schema name for the column, if one exists.

Specified by:
  `getSchemaName` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  the schema name or null

#### getDisplaySize

    public int getDisplaySize(int i)

Description copied from interface: `ResultInterface`
Get the display size for this column.

Specified by:
  `getDisplaySize` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  the display size

#### getColumnName

    public java.lang.String getColumnName(int i)

Description copied from interface: `ResultInterface`
Get the column name.

Specified by:
  `getColumnName` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  the column name

#### getColumnType

    public int getColumnType(int i)

Description copied from interface: `ResultInterface`
Get the column data type.

Specified by:
  `getColumnType` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  the column data type

#### getColumnPrecision

    public long getColumnPrecision(int i)

Description copied from interface: `ResultInterface`
Get the precision for this column.

Specified by:
  `getColumnPrecision` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  the precision

#### getNullable

    public int getNullable(int i)

Description copied from interface: `ResultInterface`
Check if this column is nullable.

Specified by:
  `getNullable` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  Column.NULLABLE_*

#### isAutoIncrement

    public boolean isAutoIncrement(int i)

Description copied from interface: `ResultInterface`
Check if this is an auto-increment column.

Specified by:
  `isAutoIncrement` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  true for auto-increment columns

#### getColumnScale

    public int getColumnScale(int i)

Description copied from interface: `ResultInterface`
Get the scale for this column.

Specified by:
  `getColumnScale` in interface `ResultInterface`
Parameters:
  `i` - the column number (starting with 0)
Returns:
  the scale

#### setOffset

    public void setOffset(int offset)

Set the offset of the first row to return.

Parameters:
  `offset` - the offset

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### isClosed

    public boolean isClosed()

Check if this result set is closed.

Returns:
  true if it is

#### getFetchSize

    public int getFetchSize()

Description copied from interface: `ResultInterface`
Get the current fetch size for this result set.

Specified by:
  `getFetchSize` in interface `ResultInterface`
Returns:
  the fetch size

#### setFetchSize

    public void setFetchSize(int fetchSize)

Description copied from interface: `ResultInterface`
Set the fetch size for this result set.

Specified by:
  `setFetchSize` in interface `ResultInterface`
Parameters:
  `fetchSize` - the new fetch size