Package org.h2.mvstore.db
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 boolean
Whether 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, ornull
if columns are not reordered.Map with rows as keys and counts of duplicate rows as values.private ValueDataType
Used for DISTINCT ON in presence of ORDER BY.private long
Count 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
ConstructorsModifierConstructorDescription(package private)
MVSortedTempResult
(Database database, Expression[] expressions, boolean distinct, int[] distinctIndexes, int visibleColumnCount, int resultColumnCount, SortOrder sort) Creates a new sorted temporary result.private
MVSortedTempResult
(MVSortedTempResult parent) Creates a shallow copy of the result. -
Method Summary
Modifier and TypeMethodDescriptionint
Add a row to this object.boolean
Check if the given row exists in this object.Create a shallow copy of this object if possible.private ValueRow
Reorder values if required and convert them intoValueRow
.private Value[]
Reorder values back if required.Value[]
next()
Get the next row from the result.int
Remove the row with the given values from this object if such a row exists.void
reset()
Reset the current position of this object.Methods inherited from class org.h2.mvstore.db.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, ornull
if columns are not reordered. -
map
Map with rows as keys and counts of duplicate rows as values. If this map is distinct all values are 1. -
index
Optional index. This index is created only if result is distinct andcolumnCount != distinctColumnCount
or 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
Cursor for thenext()
method. -
current
Current value for thenext()
method. Used in non-distinct results with duplicate rows. -
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, ornull
if this result does not need any sorting
-
-
Method Details
-
addRow
Description copied from interface:ResultExternal
Add 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:ResultExternal
Check if the given row exists in this object.- Parameters:
values
- the row- Returns:
- true if it exists
-
createShallowCopy
Description copied from interface:ResultExternal
Create a shallow copy of this object if possible.- Returns:
- the shallow copy, or null
-
getKey
Reorder values if required and convert them intoValueRow
.- Parameters:
values
- values- Returns:
- ValueRow for maps
-
getValue
Reorder values back if required.- Parameters:
key
- reordered values- Returns:
- original values
-
next
Description copied from interface:ResultExternal
Get the next row from the result.- Returns:
- the next row or null
-
removeRow
Description copied from interface:ResultExternal
Remove 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:ResultExternal
Reset the current position of this object.
-