S
- source type, can be anythingG
- aggregate type, can be anythingpublic abstract class GroupedCursor<S,G> extends AbstractCursor<G>
SortedCursor
Modifier | Constructor and Description |
---|---|
protected |
GroupedCursor(Cursor<S> cursor,
java.lang.Class<S> type,
java.lang.String... groupProperties)
Create a GroupedCursor using properties to define the group
comparator.
|
protected |
GroupedCursor(Cursor<S> cursor,
java.util.Comparator<S> groupComparator)
Create a GroupedCursor with an existing group comparator.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addToGroup(S groupMember)
This method is called when more entries are found for the current
group.
|
protected abstract void |
beginGroup(S groupLeader)
This method is called for the first entry in a group.
|
void |
close()
Call close to release any resources being held by this cursor.
|
java.util.Comparator<S> |
comparator()
Returns the comparator used to identify group boundaries.
|
protected abstract G |
finishGroup()
This method is called when a group is finished, and it can return an
aggregate.
|
boolean |
hasNext()
Returns true if this cursor has more elements.
|
G |
next()
Returns the next element from this cursor.
|
int |
skipNext(int amount)
Skips forward by the specified amount of elements, returning the actual
amount skipped.
|
copyInto, copyInto, toList, toList
protected GroupedCursor(Cursor<S> cursor, java.util.Comparator<S> groupComparator)
cursor
- source of elements which must be ordered properlygroupComparator
- comparator which defines ordering of source cursorprotected GroupedCursor(Cursor<S> cursor, java.lang.Class<S> type, java.lang.String... groupProperties)
cursor
- source of elements which must be ordered properlytype
- type of storable to create cursor forgroupProperties
- list of properties to group byjava.lang.IllegalArgumentException
- if any property is null or not a member
of storable typepublic java.util.Comparator<S> comparator()
protected abstract void beginGroup(S groupLeader) throws FetchException
groupLeader
- first entry in groupFetchException
protected abstract void addToGroup(S groupMember) throws FetchException
groupMember
- additional entry in groupFetchException
protected abstract G finishGroup() throws FetchException
FetchException
public void close() throws FetchException
Cursor
FetchException
public boolean hasNext() throws FetchException
Cursor
next
would return an element rather than throwing
an exception.FetchException
- if storage layer throws an exceptionpublic G next() throws FetchException
Cursor
FetchException
- if storage layer throws an exceptionpublic int skipNext(int amount) throws FetchException
Cursor
skipNext
in interface Cursor<G>
skipNext
in class AbstractCursor<G>
amount
- maximum amount of elements to skipFetchException
- if storage layer throws an exceptionCopyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.