Class MVSortedTempResult
java.lang.Object
org.h2.mvstore.db.MVTempResult
org.h2.mvstore.db.MVSortedTempResult
- All Implemented Interfaces:
ResultExternal
Sorted temporary result.
This result is used for distinct and/or sorted results.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Value[]Current value for thenext()method.Cursor for thenext()method.private final booleanWhether this result is a standard distinct result.private final int[]Distinct indexes for DISTINCT ON results.Optional index.private final int[]Mapping of indexes of columns to its positions in the store, ornullif columns are not reordered.Map with rows as keys and counts of duplicate rows as values.private ValueDataTypeUsed for DISTINCT ON in presence of ORDER BY.private longCount of remaining duplicate rows for thenext()method.Fields inherited from class MVTempResult
childCount, closed, expressions, parent, resultColumnCount, rowCount, store, visibleColumnCount -
Constructor Summary
ConstructorsModifierConstructorDescription(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
Modifier and TypeMethodDescriptionintAdd a row to this object.booleanCheck if the given row exists in this object.Create a shallow copy of this object if possible.private ValueRowReorder values if required and convert them intoValueRow.private Value[]Reorder values back if required.Value[]next()Get the next row from the result.intRemove 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 MVTempResult
addRows, close, of
-
Field Details
-
distinct
private final boolean distinctWhether this result is a standard distinct result. -
distinctIndexes
private final int[] distinctIndexesDistinct indexes for DISTINCT ON results. -
indexes
private final int[] indexesMapping of indexes of columns to its positions in the store, ornullif columns are not reordered. -
map
-
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
Used for DISTINCT ON in presence of ORDER BY. -
cursor
-
current
-
valueCount
private long valueCountCount of remaining duplicate rows for thenext()method. Used in non-distinct results.
-
-
Constructor Details
-
MVSortedTempResult
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 Details
-
addRow
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
Description copied from interface:ResultExternalCheck if the given row exists in this object.- Parameters:
values- the row- Returns:
- true if it exists
-
createShallowCopy
Description copied from interface:ResultExternalCreate a shallow copy of this object if possible.- Returns:
- the shallow copy, or null
-
getKey
-
getValue
-
next
Description copied from interface:ResultExternalGet the next row from the result.- Returns:
- the next row or null
-
removeRow
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.
-