Package org.h2.mvstore.db
Class MVSortedTempResult
- java.lang.Object
-
- org.h2.mvstore.db.MVTempResult
-
- org.h2.mvstore.db.MVSortedTempResult
-
- All Implemented Interfaces:
ResultExternal
class MVSortedTempResult extends MVTempResult
Sorted temporary result.This result is used for distinct and/or sorted results.
-
-
Field Summary
Fields Modifier and Type Field Description private Value[]currentCurrent value for thenext()method.private Cursor<ValueRow,java.lang.Long>cursorCursor for thenext()method.private booleandistinctWhether this result is a standard distinct result.private int[]distinctIndexesDistinct indexes for DISTINCT ON results.private MVMap<ValueRow,Value>indexOptional index.private int[]indexesMapping of indexes of columns to its positions in the store, ornullif columns are not reordered.private MVMap<ValueRow,java.lang.Long>mapMap with rows as keys and counts of duplicate rows as values.private ValueDataTypeorderedDistinctOnTypeUsed for DISTINCT ON in presence of ORDER BY.private longvalueCountCount of remaining duplicate rows for thenext()method.-
Fields inherited from class org.h2.mvstore.db.MVTempResult
childCount, closed, expressions, parent, resultColumnCount, rowCount, store, visibleColumnCount
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)MVSortedTempResult(Database database, Expression[] expressions, boolean distinct, int[] distinctIndexes, int visibleColumnCount, int resultColumnCount, SortOrder sort)Creates a new sorted temporary result.privateMVSortedTempResult(MVSortedTempResult parent)Creates a shallow copy of the result.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddRow(Value[] values)Add a row to this object.booleancontains(Value[] values)Check if the given row exists in this object.ResultExternalcreateShallowCopy()Create a shallow copy of this object if possible.private ValueRowgetKey(Value[] values)Reorder values if required and convert them intoValueRow.private Value[]getValue(Value[] key)Reorder values back if required.Value[]next()Get the next row from the result.intremoveRow(Value[] values)Remove the row with the given values from this object if such a row exists.voidreset()Reset the current position of this object.-
Methods inherited from class org.h2.mvstore.db.MVTempResult
addRows, close, of
-
-
-
-
Field Detail
-
distinct
private final boolean distinct
Whether this result is a standard distinct result.
-
distinctIndexes
private final int[] distinctIndexes
Distinct indexes for DISTINCT ON results.
-
indexes
private final int[] indexes
Mapping of indexes of columns to its positions in the store, ornullif columns are not reordered.
-
map
private final MVMap<ValueRow,java.lang.Long> map
Map with rows as keys and counts of duplicate rows as values. If this map is distinct all values are 1.
-
index
private MVMap<ValueRow,Value> index
Optional index. This index is created only if result is distinct andcolumnCount != distinctColumnCountor ifcontains(Value[])method is invoked. Only the root result should have an index if required.
-
orderedDistinctOnType
private ValueDataType orderedDistinctOnType
Used for DISTINCT ON in presence of ORDER BY.
-
current
private Value[] current
Current value for thenext()method. Used in non-distinct results with duplicate rows.
-
valueCount
private long valueCount
Count of remaining duplicate rows for thenext()method. Used in non-distinct results.
-
-
Constructor Detail
-
MVSortedTempResult
private MVSortedTempResult(MVSortedTempResult parent)
Creates a shallow copy of the result.- Parameters:
parent- parent result
-
MVSortedTempResult
MVSortedTempResult(Database database, Expression[] expressions, boolean distinct, int[] distinctIndexes, int visibleColumnCount, int resultColumnCount, SortOrder sort)
Creates a new sorted temporary result.- Parameters:
database- databaseexpressions- column expressionsdistinct- whether this result should be distinctdistinctIndexes- indexes of distinct columns for DISTINCT ON resultsvisibleColumnCount- count of visible columnsresultColumnCount- the number of columns including visible columns and additional virtual columns for ORDER BY and DISTINCT ON clausessort- sort order, ornullif this result does not need any sorting
-
-
Method Detail
-
addRow
public int addRow(Value[] values)
Description copied from interface:ResultExternalAdd a row to this object.- Parameters:
values- the row to add- Returns:
- the new number of rows in this object
-
contains
public boolean contains(Value[] values)
Description copied from interface:ResultExternalCheck if the given row exists in this object.- Parameters:
values- the row- Returns:
- true if it exists
-
createShallowCopy
public ResultExternal createShallowCopy()
Description copied from interface:ResultExternalCreate a shallow copy of this object if possible.- Returns:
- the shallow copy, or null
-
getKey
private ValueRow getKey(Value[] values)
Reorder values if required and convert them intoValueRow.- Parameters:
values- values- Returns:
- ValueRow for maps
-
getValue
private Value[] getValue(Value[] key)
Reorder values back if required.- Parameters:
key- reordered values- Returns:
- original values
-
next
public Value[] next()
Description copied from interface:ResultExternalGet the next row from the result.- Returns:
- the next row or null
-
removeRow
public int removeRow(Value[] values)
Description copied from interface:ResultExternalRemove the row with the given values from this object if such a row exists.- Parameters:
values- the row- Returns:
- the new row count
-
reset
public void reset()
Description copied from interface:ResultExternalReset the current position of this object.
-
-