Top Description Fields Constructors Methods
org.h2.mvstore.db

pack-priv Class MVSortedTempResult

extends MVTempResult
Class Inheritance
Imports
java.util.Arrays, .BitSet, org.h2.engine.Database, org.h2.expression.Expression, org.h2.message.DbException, org.h2.mvstore.Cursor, .MVMap, .MVMap.Builder, org.h2.mvstore.type.DataType, .LongDataType, org.h2.result.ResultExternal, .RowFactory.DefaultRowFactory, .SortOrder, org.h2.value.TypeInfo, .Value, .ValueNull, .ValueRow

Sorted temporary result.

This result is used for distinct and/or sorted results.

Field Summary

Modifier and TypeField and Description
private Value[]
current

Current value for the next() method.

private Cursor<ValueRow, Long>
cursor

Cursor for the next() method.

private final boolean
distinct

Whether this result is a standard distinct result.

private final int[]
distinctIndexes

Distinct indexes for DISTINCT ON results.

private MVMap<ValueRow, Value>
index

Optional index.

private final int[]
indexes

Mapping of indexes of columns to its positions in the store, or null if columns are not reordered.

private final MVMap<ValueRow, Long>
map

Map with rows as keys and counts of duplicate rows as values.

private ValueDataType
orderedDistinctOnType

Used for DISTINCT ON in presence of ORDER BY.

private long
valueCount

Count of remaining duplicate rows for the next() method.

Inherited from org.h2.mvstore.db.MVTempResult:
childCountclosedexpressionsparentresultColumnCountrowCountstorevisibleColumnCount

Constructor Summary

AccessConstructor and Description
private
MVSortedTempResult(MVSortedTempResult
parent result
parent
)

Creates a shallow copy of the result.

pack-priv
MVSortedTempResult(Database
database
database
,
Expression[]
column expressions
expressions
,
boolean
whether this result should be distinct
distinct
,
int[]
indexes of distinct columns for DISTINCT ON results
distinctIndexes
,
int
count of visible columns
visibleColumnCount
,
int
the number of columns including visible columns and additional virtual columns for ORDER BY and DISTINCT ON clauses
resultColumnCount
,
SortOrder
sort order, or null if this result does not need any sorting
sort
)

Creates a new sorted temporary result.

Method Summary

Modifier and TypeMethod and Description
public int
addRow(Value[]
the row to add
values
)

Implements org.h2.result.ResultExternal.addRow.

Add a row to this object.

public boolean
contains(Value[]
the row
values
)

Implements org.h2.result.ResultExternal.contains.

Check if the given row exists in this object.

public synchronized ResultExternal
createShallowCopy()

Implements org.h2.result.ResultExternal.createShallowCopy.

Create a shallow copy of this object if possible.

private ValueRow

Returns:

ValueRow for maps
getKey
(Value[]
values
values
)

Reorder values if required and convert them into ValueRow.

private Value[]

Returns:

original values
getValue
(Value[]
reordered values
key
)

Reorder values back if required.

public Value[]
next()

Implements org.h2.result.ResultExternal.next.

Get the next row from the result.

public int
removeRow(Value[]
the row
values
)

Implements org.h2.result.ResultExternal.removeRow.

Remove the row with the given values from this object if such a row exists.

public void
reset()

Implements org.h2.result.ResultExternal.reset.

Reset the current position of this object.

Inherited from org.h2.mvstore.db.MVTempResult:
addRowscloseof

Field Detail

currentback to summary
private Value[] current

Current value for the next() method. Used in non-distinct results with duplicate rows.

cursorback to summary
private Cursor<ValueRow, Long> cursor

Cursor for the next() method.

distinctback to summary
private final boolean distinct

Whether this result is a standard distinct result.

distinctIndexesback to summary
private final int[] distinctIndexes

Distinct indexes for DISTINCT ON results.

indexback to summary
private MVMap<ValueRow, Value> index

Optional index. This index is created only if result is distinct and columnCount != distinctColumnCount or if contains(Value[]) method is invoked. Only the root result should have an index if required.

indexesback to summary
private final int[] indexes

Mapping of indexes of columns to its positions in the store, or null if columns are not reordered.

mapback to summary
private final MVMap<ValueRow, Long> map

Map with rows as keys and counts of duplicate rows as values. If this map is distinct all values are 1.

orderedDistinctOnTypeback to summary
private ValueDataType orderedDistinctOnType

Used for DISTINCT ON in presence of ORDER BY.

valueCountback to summary
private long valueCount

Count of remaining duplicate rows for the next() method. Used in non-distinct results.

Constructor Detail

MVSortedTempResultback to summary
private MVSortedTempResult(MVSortedTempResult parent)

Creates a shallow copy of the result.

Parameters
parent:MVSortedTempResult

parent result

MVSortedTempResultback to summary
pack-priv MVSortedTempResult(Database database, Expression[] expressions, boolean distinct, int[] distinctIndexes, int visibleColumnCount, int resultColumnCount, SortOrder sort)

Creates a new sorted temporary result.

Parameters
database:Database

database

expressions:Expression[]

column expressions

distinct:boolean

whether this result should be distinct

distinctIndexes:int[]

indexes of distinct columns for DISTINCT ON results

visibleColumnCount:int

count of visible columns

resultColumnCount:int

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

sort:SortOrder

sort order, or null if this result does not need any sorting

Method Detail

addRowback to summary
public int addRow(Value[] values)

Implements org.h2.result.ResultExternal.addRow.

Doc from org.h2.result.ResultExternal.addRow.

Add a row to this object.

Parameters
values:Value[]

the row to add

Returns:int

the new number of rows in this object

Annotations
@Override
containsback to summary
public boolean contains(Value[] values)

Implements org.h2.result.ResultExternal.contains.

Doc from org.h2.result.ResultExternal.contains.

Check if the given row exists in this object.

Parameters
values:Value[]

the row

Returns:boolean

true if it exists

Annotations
@Override
createShallowCopyback to summary
public synchronized ResultExternal createShallowCopy()

Implements org.h2.result.ResultExternal.createShallowCopy.

Doc from org.h2.result.ResultExternal.createShallowCopy.

Create a shallow copy of this object if possible.

Returns:ResultExternal

the shallow copy, or null

Annotations
@Override
getKeyback to summary
private ValueRow getKey(Value[] values)

Reorder values if required and convert them into ValueRow.

Parameters
values:Value[]

values

Returns:ValueRow

ValueRow for maps

getValueback to summary
private Value[] getValue(Value[] key)

Reorder values back if required.

Parameters
key:Value[]

reordered values

Returns:Value[]

original values

nextback to summary
public Value[] next()

Implements org.h2.result.ResultExternal.next.

Doc from org.h2.result.ResultExternal.next.

Get the next row from the result.

Returns:Value[]

the next row or null

Annotations
@Override
removeRowback to summary
public int removeRow(Value[] values)

Implements org.h2.result.ResultExternal.removeRow.

Doc from org.h2.result.ResultExternal.removeRow.

Remove the row with the given values from this object if such a row exists.

Parameters
values:Value[]

the row

Returns:int

the new row count

Annotations
@Override
resetback to summary
public void reset()

Implements org.h2.result.ResultExternal.reset.

Doc from org.h2.result.ResultExternal.reset.

Reset the current position of this object.

Annotations
@Override