Top Description Inners Fields Constructors Methods
org.h2.command.query

public abstract Class SelectGroups

extends Object
Class Inheritance
Known Direct Subclasses
org.h2.command.query.SelectGroups.Grouped, org.h2.command.query.SelectGroups.Plain
Imports
java.util.ArrayList, .Arrays, .HashMap, .Iterator, .Map, .Map.Entry, .TreeMap, org.h2.engine.SessionLocal, org.h2.expression.Expression, org.h2.expression.analysis.DataAnalysisOperation, .PartitionData, org.h2.value.Value, .ValueRow

Grouped data for aggregates.

Call sequence:

Call sequence for lazy group sorted result:

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
pack-priv Object[]
currentGroupByExprData

The array of current group-by expression data e.g. AggregateData.

pack-priv int
currentGroupRowId

The id of the current group.

pack-priv final ArrayList<Expression>
expressions

The query's column list, including invisible expressions such as order by expressions.

private final HashMap<Expression, Integer>
exprToIndexInGroupByData

Maps an expression object to an index, to use in accessing the Object[] pointed to by groupByData.

pack-priv final SessionLocal
session

The database session.

private final HashMap<DataAnalysisOperation, PartitionData>
windowData

Maps an window expression object to its data.

private final HashMap<DataAnalysisOperation, TreeMap<Value, PartitionData>>
windowPartitionData

Maps an partitioned window expression object to its data.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv final Object[]

Returns:

new object array to holds group-by data.
createRow
()

Creates new object arrays to holds group-by data.

public void
done()

Invoked after all source rows are evaluated.

public final Object

Returns:

expression data or null
getCurrentGroupExprData
(Expression
expression
expr
)

Get the group-by data for the current group and the passed in expression.

public int

Returns:

identity of the current row
getCurrentGroupRowId
()

Returns identity of the current row.

public static SelectGroups

Returns:

new instance of the grouped data.
getInstance
(SessionLocal
the session
session
,
ArrayList<Expression>
the expressions
expressions
,
boolean
is this query is a group query
isGroupQuery
,
int[]
the indexes of group expressions, or null
groupIndex
)

Creates new instance of grouped data.

public final PartitionData

Returns:

expression data or null
getWindowExprData
(DataAnalysisOperation
expression
expr
,
Value
a key of partition
partitionKey
)

Get the window data for the specified expression.

public boolean

Returns:

true if there is currently a group-by active, otherwise returns false.
isCurrentGroup
()

Is there currently a group-by active.

public abstract ValueRow

Returns:

the key of the next group, or null
next
()

Returns the key of the next group.

public void
nextLazyGroup()

Moves group data to the next group in lazy mode.

public void
nextLazyRow()

Moves group data to the next row in lazy mode.

public abstract void
nextSource()

Invoked for each source row to evaluate group key and setup all necessary data for aggregates.

public void
remove()

Removes the data for the current key.

public void
reset()

Resets this group data for reuse.

public void
resetLazy()

Resets this group data for reuse in lazy mode.

public final void
setCurrentGroupExprData(Expression
expression
expr
,
Object
expression data to set
obj
)

Set the group-by data for the current group and the passed in expression.

public final void
setWindowExprData(DataAnalysisOperation
expression
expr
,
Value
a key of partition
partitionKey
,
PartitionData
window expression data to set
obj
)

Set the window data for the specified expression.

pack-priv abstract void
updateCurrentGroupExprData()

Update group-by data specified by implementation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentGroupByExprDataback to summary
pack-priv Object[] currentGroupByExprData

The array of current group-by expression data e.g. AggregateData.

currentGroupRowIdback to summary
pack-priv int currentGroupRowId

The id of the current group.

expressionsback to summary
pack-priv final ArrayList<Expression> expressions

The query's column list, including invisible expressions such as order by expressions.

exprToIndexInGroupByDataback to summary
private final HashMap<Expression, Integer> exprToIndexInGroupByData

Maps an expression object to an index, to use in accessing the Object[] pointed to by groupByData.

sessionback to summary
pack-priv final SessionLocal session

The database session.

windowDataback to summary
private final HashMap<DataAnalysisOperation, PartitionData> windowData

Maps an window expression object to its data.

windowPartitionDataback to summary
private final HashMap<DataAnalysisOperation, TreeMap<Value, PartitionData>> windowPartitionData

Maps an partitioned window expression object to its data.

Constructor Detail

SelectGroupsback to summary
pack-priv SelectGroups(SessionLocal session, ArrayList<Expression> expressions)

Method Detail

createRowback to summary
pack-priv final Object[] createRow()

Creates new object arrays to holds group-by data.

Returns:Object[]

new object array to holds group-by data.

doneback to summary
public void done()

Invoked after all source rows are evaluated.

getCurrentGroupExprDataback to summary
public final Object getCurrentGroupExprData(Expression expr)

Get the group-by data for the current group and the passed in expression.

Parameters
expr:Expression

expression

Returns:Object

expression data or null

getCurrentGroupRowIdback to summary
public int getCurrentGroupRowId()

Returns identity of the current row. Used by aggregates to check whether they already processed this row or not.

Returns:int

identity of the current row

getInstanceback to summary
public static SelectGroups getInstance(SessionLocal session, ArrayList<Expression> expressions, boolean isGroupQuery, int[] groupIndex)

Creates new instance of grouped data.

Parameters
session:SessionLocal

the session

expressions:ArrayList<Expression>

the expressions

isGroupQuery:boolean

is this query is a group query

groupIndex:int[]

the indexes of group expressions, or null

Returns:SelectGroups

new instance of the grouped data.

getWindowExprDataback to summary
public final PartitionData getWindowExprData(DataAnalysisOperation expr, Value partitionKey)

Get the window data for the specified expression.

Parameters
expr:DataAnalysisOperation

expression

partitionKey:Value

a key of partition

Returns:PartitionData

expression data or null

isCurrentGroupback to summary
public boolean isCurrentGroup()

Is there currently a group-by active.

Returns:boolean

true if there is currently a group-by active, otherwise returns false.

nextback to summary
public abstract ValueRow next()

Returns the key of the next group.

Returns:ValueRow

the key of the next group, or null

nextLazyGroupback to summary
public void nextLazyGroup()

Moves group data to the next group in lazy mode.

nextLazyRowback to summary
public void nextLazyRow()

Moves group data to the next row in lazy mode.

nextSourceback to summary
public abstract void nextSource()

Invoked for each source row to evaluate group key and setup all necessary data for aggregates.

removeback to summary
public void remove()

Removes the data for the current key.

See Also
next()
resetback to summary
public void reset()

Resets this group data for reuse.

resetLazyback to summary
public void resetLazy()

Resets this group data for reuse in lazy mode.

setCurrentGroupExprDataback to summary
public final void setCurrentGroupExprData(Expression expr, Object obj)

Set the group-by data for the current group and the passed in expression.

Parameters
expr:Expression

expression

obj:Object

expression data to set

setWindowExprDataback to summary
public final void setWindowExprData(DataAnalysisOperation expr, Value partitionKey, PartitionData obj)

Set the window data for the specified expression.

Parameters
expr:DataAnalysisOperation

expression

partitionKey:Value

a key of partition

obj:PartitionData

window expression data to set

updateCurrentGroupExprDataback to summary
pack-priv abstract void updateCurrentGroupExprData()

Update group-by data specified by implementation.

org.h2.command.query back to summary

private final Class SelectGroups.Grouped

extends SelectGroups
Class Inheritance

Field Summary

Modifier and TypeField and Description
private ValueRow
currentGroupsKey

Key into groupByData that produces currentGroupByExprData.

private Iterator<Map.Entry<ValueRow, Object[]>>
cursor

Cursor for next() method.

private TreeMap<ValueRow, Object[]>
groupByData

Map of group-by key to group-by expression data e.g. AggregateData

private final int[]
Inherited from org.h2.command.query.SelectGroups:
currentGroupByExprDatacurrentGroupRowIdexpressionssession

Constructor Summary

AccessConstructor and Description
pack-priv
Grouped(SessionLocal session, ArrayList<Expression> expressions, int[] groupIndex)

Method Summary

Modifier and TypeMethod and Description
public void
done()

Overrides org.h2.command.query.SelectGroups.done.

Invoked after all source rows are evaluated.

public ValueRow
next()

Implements abstract org.h2.command.query.SelectGroups.next.

Returns the key of the next group.

public void
nextSource()

Implements abstract org.h2.command.query.SelectGroups.nextSource.

Invoked for each source row to evaluate group key and setup all necessary data for aggregates.

public void
remove()

Overrides org.h2.command.query.SelectGroups.remove.

Removes the data for the current key.

public void
reset()

Overrides org.h2.command.query.SelectGroups.reset.

Resets this group data for reuse.

public void
resetLazy()

Overrides org.h2.command.query.SelectGroups.resetLazy.

Resets this group data for reuse in lazy mode.

pack-priv void
updateCurrentGroupExprData()

Implements abstract org.h2.command.query.SelectGroups.updateCurrentGroupExprData.

Update group-by data specified by implementation.

Inherited from org.h2.command.query.SelectGroups:
createRowgetCurrentGroupExprDatagetCurrentGroupRowIdgetInstancegetWindowExprDataisCurrentGroupnextLazyGroupnextLazyRowsetCurrentGroupExprDatasetWindowExprData

Field Detail

currentGroupsKeyback to summary
private ValueRow currentGroupsKey

Key into groupByData that produces currentGroupByExprData. Not used in lazy mode.

cursorback to summary
private Iterator<Map.Entry<ValueRow, Object[]>> cursor

Cursor for next() method.

groupByDataback to summary
private TreeMap<ValueRow, Object[]> groupByData

Map of group-by key to group-by expression data e.g. AggregateData

groupIndexback to summary
private final int[] groupIndex

Constructor Detail

Groupedback to summary
pack-priv Grouped(SessionLocal session, ArrayList<Expression> expressions, int[] groupIndex)

Method Detail

doneback to summary
public void done()

Overrides org.h2.command.query.SelectGroups.done.

Doc from org.h2.command.query.SelectGroups.done.

Invoked after all source rows are evaluated.

Annotations
@Override
nextback to summary
public ValueRow next()

Implements abstract org.h2.command.query.SelectGroups.next.

Doc from org.h2.command.query.SelectGroups.next.

Returns the key of the next group.

Returns:ValueRow

the key of the next group, or null

Annotations
@Override
nextSourceback to summary
public void nextSource()

Implements abstract org.h2.command.query.SelectGroups.nextSource.

Doc from org.h2.command.query.SelectGroups.nextSource.

Invoked for each source row to evaluate group key and setup all necessary data for aggregates.

Annotations
@Override
removeback to summary
public void remove()

Overrides org.h2.command.query.SelectGroups.remove.

Doc from org.h2.command.query.SelectGroups.remove.

Removes the data for the current key.

Annotations
@Override
resetback to summary
public void reset()

Overrides org.h2.command.query.SelectGroups.reset.

Doc from org.h2.command.query.SelectGroups.reset.

Resets this group data for reuse.

Annotations
@Override
resetLazyback to summary
public void resetLazy()

Overrides org.h2.command.query.SelectGroups.resetLazy.

Doc from org.h2.command.query.SelectGroups.resetLazy.

Resets this group data for reuse in lazy mode.

Annotations
@Override
updateCurrentGroupExprDataback to summary
pack-priv void updateCurrentGroupExprData()

Implements abstract org.h2.command.query.SelectGroups.updateCurrentGroupExprData.

Doc from org.h2.command.query.SelectGroups.updateCurrentGroupExprData.

Update group-by data specified by implementation.

Annotations
@Override
org.h2.command.query back to summary

private final Class SelectGroups.Plain

extends SelectGroups
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Iterator<Object[]>
cursor

Cursor for next() method.

private ArrayList<Object[]>
Inherited from org.h2.command.query.SelectGroups:
currentGroupByExprDatacurrentGroupRowIdexpressionssession

Constructor Summary

AccessConstructor and Description
pack-priv
Plain(SessionLocal session, ArrayList<Expression> expressions)

Method Summary

Modifier and TypeMethod and Description
public void
done()

Overrides org.h2.command.query.SelectGroups.done.

Invoked after all source rows are evaluated.

public ValueRow
next()

Implements abstract org.h2.command.query.SelectGroups.next.

Returns the key of the next group.

public void
nextSource()

Implements abstract org.h2.command.query.SelectGroups.nextSource.

Invoked for each source row to evaluate group key and setup all necessary data for aggregates.

public void
reset()

Overrides org.h2.command.query.SelectGroups.reset.

Resets this group data for reuse.

pack-priv void
updateCurrentGroupExprData()

Implements abstract org.h2.command.query.SelectGroups.updateCurrentGroupExprData.

Update group-by data specified by implementation.

Inherited from org.h2.command.query.SelectGroups:
createRowgetCurrentGroupExprDatagetCurrentGroupRowIdgetInstancegetWindowExprDataisCurrentGroupnextLazyGroupnextLazyRowremoveresetLazysetCurrentGroupExprDatasetWindowExprData

Field Detail

cursorback to summary
private Iterator<Object[]> cursor

Cursor for next() method.

rowsback to summary
private ArrayList<Object[]> rows

Constructor Detail

Plainback to summary
pack-priv Plain(SessionLocal session, ArrayList<Expression> expressions)

Method Detail

doneback to summary
public void done()

Overrides org.h2.command.query.SelectGroups.done.

Doc from org.h2.command.query.SelectGroups.done.

Invoked after all source rows are evaluated.

Annotations
@Override
nextback to summary
public ValueRow next()

Implements abstract org.h2.command.query.SelectGroups.next.

Doc from org.h2.command.query.SelectGroups.next.

Returns the key of the next group.

Returns:ValueRow

the key of the next group, or null

Annotations
@Override
nextSourceback to summary
public void nextSource()

Implements abstract org.h2.command.query.SelectGroups.nextSource.

Doc from org.h2.command.query.SelectGroups.nextSource.

Invoked for each source row to evaluate group key and setup all necessary data for aggregates.

Annotations
@Override
resetback to summary
public void reset()

Overrides org.h2.command.query.SelectGroups.reset.

Doc from org.h2.command.query.SelectGroups.reset.

Resets this group data for reuse.

Annotations
@Override
updateCurrentGroupExprDataback to summary
pack-priv void updateCurrentGroupExprData()

Implements abstract org.h2.command.query.SelectGroups.updateCurrentGroupExprData.

Doc from org.h2.command.query.SelectGroups.updateCurrentGroupExprData.

Update group-by data specified by implementation.

Annotations
@Override