|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jagg.Aggregations
public class Aggregations
This class is a utility class that represents an alternate API for some
jAgg operations. Before 0.7.0, this class was the sole API. As of 0.7.0,
this class no longer represents the complete API. For the operations it
does support, it defers to the new API (Aggregation
class).
It supports "group by" functionality that allows aggregate
functions, or Aggregators
, to return aggregate values
over a List
of Objects
.
It can aggregate over Comparable
objects or, with a supplied
list of properties, any objects. Parallel execution is also avaialable.
To use super-aggregation, e.g. rollups, cubes, or grouping sets, please
use the Aggregation
class (and its Builder
class)
directly.
Aggregation
,
Aggregation.Builder
Method Summary | ||
---|---|---|
static
|
groupBy(java.util.List<T> values,
java.util.List<Aggregator> aggregators)
Perform one or more aggregate operations on a List<T> . |
|
static
|
groupBy(java.util.List<T> values,
java.util.List<Aggregator> aggregators,
int parallelism)
Perform one or more aggregate operations on a List<T> . |
|
static
|
groupBy(java.util.List<T> values,
java.util.List<java.lang.String> properties,
java.util.List<Aggregator> aggregators)
Perform one or more aggregate operations on a List<T> . |
|
static
|
groupBy(java.util.List<T> values,
java.util.List<java.lang.String> properties,
java.util.List<Aggregator> aggregators,
boolean useMsd)
Perform one or more aggregate operations on a List<T> . |
|
static
|
groupBy(java.util.List<T> values,
java.util.List<java.lang.String> properties,
java.util.List<Aggregator> aggregators,
int parallelism)
Perform one or more aggregate operations on a List<T> . |
|
static
|
groupBy(java.util.List<T> values,
java.util.List<java.lang.String> properties,
java.util.List<Aggregator> aggregators,
int parallelism,
boolean useMsd)
Perform one or more aggregate operations on a List<T> . |
|
static
|
indexOfLastMatching(java.util.List<T> list,
java.util.Comparator<? super T> comparator,
int startIdx)
In the already sorted list, return the highest index whose item in the list compares equal to the item at the given start index. |
|
static
|
indexOfLastMatching(java.util.List<T> list,
java.util.Comparator<? super T> comparator,
int startIdx,
int maxIdx)
In the already sorted list, return the highest index whose item in the list compares equal to the item at the given start index, except that no value larger than the maximum index will be returned. |
|
static
|
mergeLists(java.util.List<net.sf.jagg.PositionedAggregatorList<T>> listOfPals,
java.util.Comparator<? super T> comparator,
boolean useSuperAggregation,
java.util.List<java.lang.String> properties)
Merge Lists of PositionedAggregatorLists , by
taking the following structure and merging and terminating any unfinished
Aggregators : |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T extends java.lang.Comparable<? super T>> java.util.List<AggregateValue<T>> groupBy(java.util.List<T> values, java.util.List<Aggregator> aggregators)
List<T>
.
T
should have a "natural ordering", that is, it must be
Comparable
, and compareTo
defines the
properties with which to "group by" with its consideration of different
properties to determine order.
T
- The object type to aggregate.values
- The List<T>
of objects to aggregate.aggregators
- The List
of Aggregators
to
apply to values
.
List<AggregateValue<T>>
.Aggregator
public static <T extends java.lang.Comparable<? super T>> java.util.List<AggregateValue<T>> groupBy(java.util.List<T> values, java.util.List<Aggregator> aggregators, int parallelism)
List<T>
.
T
should have a "natural ordering", that is, it must be
Comparable
, and compareTo
defines the
properties with which to "group by" with its consideration of different
properties to determine order. This version accepts an integer argument
corresponding to the parallelization desired.
T
- The object type to aggregate.values
- The List<T>
of objects to aggregate.aggregators
- The List
of Aggregators
to
apply to values
.parallelism
- The degree of parallelism desired; if less than 1,
then 1 will be used; if more than 1, then minimum of this number and
the number of processors available to the JVM will be used, as
determined by Runtime.availableProcessors
.
List<AggregateValue<T>>
.Aggregator
,
Runtime.availableProcessors()
public static <T> java.util.List<AggregateValue<T>> groupBy(java.util.List<T> values, java.util.List<java.lang.String> properties, java.util.List<Aggregator> aggregators)
List<T>
.
T
does not need to be Comparable
. The given
properties list defines the properties with which to "group by". This
method sorts a copy of the list based on the list of properties.
T
- The object type to aggregate.values
- The List<T>
of objects to aggregate.properties
- The List<String>
of properties to
"group by".aggregators
- The List
of Aggregators
to
apply to values
.
List<AggregateValue<T>>
Aggregator
public static <T> java.util.List<AggregateValue<T>> groupBy(java.util.List<T> values, java.util.List<java.lang.String> properties, java.util.List<Aggregator> aggregators, boolean useMsd)
List<T>
.
T
does not need to be Comparable
. The given
properties list defines the properties with which to "group by". This
method allows a choice to use multiset discrimination to group the
elements.
T
- The object type to aggregate.values
- The List<T>
of objects to aggregate.properties
- The List<String>
of properties to
"group by".aggregators
- The List
of Aggregators
to
apply to values
.useMsd
- true
to use multiset discrimination,
false
to only use sorting. If multiset discrimination
fails, then this method falls back on sorting.
List<AggregateValue<T>>
Aggregator
public static <T> java.util.List<AggregateValue<T>> groupBy(java.util.List<T> values, java.util.List<java.lang.String> properties, java.util.List<Aggregator> aggregators, int parallelism)
List<T>
.
T
does not need to be Comparable
. The given
properties list defines the properties with which to "group by". This
version accepts an integer argument corresponding to the parallelization
desired. This method sorts a copy of the list based on the list of
properties.
T
- The object type to aggregate.values
- The List<T>
of objects to aggregate.properties
- The List<String>
of properties to
"group by".aggregators
- The List
of Aggregators
to
apply to values
.parallelism
- The degree of parallelism desired; if less than 1,
then 1 will be used; if more than 1, then minimum of this number and
the number of processors available to the JVM will be used, as
determined by Runtime.availableProcessors
.
List<AggregateValue<T>>
Aggregator
,
Runtime.availableProcessors()
public static <T> java.util.List<AggregateValue<T>> groupBy(java.util.List<T> values, java.util.List<java.lang.String> properties, java.util.List<Aggregator> aggregators, int parallelism, boolean useMsd)
List<T>
.
T
does not need to be Comparable
. The given
properties list defines the properties with which to "group by". This
version accepts an integer argument corresponding to the parallelization
desired. This method allows a choice to use multiset discrimination to
group the elements.
T
- The object type to aggregate.values
- The List<T>
of objects to aggregate.properties
- The List<String>
of properties to
"group by".aggregators
- The List
of Aggregators
to
apply to values
.parallelism
- The degree of parallelism desired; if less than 1,
then 1 will be used; if more than 1, then minimum of this number and
the number of processors available to the JVM will be used, as
determined by Runtime.availableProcessors
.useMsd
- true
to use multiset discrimination,
false
to only use sorting. If multiset discrimination
fails, then this method falls back on sorting.
List<AggregateValue<T>>
Aggregator
,
Runtime.availableProcessors()
public static <T> java.util.List<AggregateValue<T>> mergeLists(java.util.List<net.sf.jagg.PositionedAggregatorList<T>> listOfPals, java.util.Comparator<? super T> comparator, boolean useSuperAggregation, java.util.List<java.lang.String> properties)
Merge Lists
of PositionedAggregatorLists
, by
taking the following structure and merging and terminating any unfinished
Aggregators
:
listOfPals[0] {initObject: T, initAggregators: List<Aggregator>,
midAggValues: List<AggregateValue<T>>,
endingObject: T, endingAggregators; List<Aggregator>}
listOfPals[1] {initObject: T, initAggregators: List<Aggregator>,
midAggValues: List<AggregateValue<T>>,
endingObject: T, endingAggregators; List<Aggregator>}
...
listOfPals[n - 1] {initObject: T, initAggregators: List<Aggregator>,
midAggValues: List<AggregateValue<T>>,
endingObject: T, endingAggregators; List<Aggregator>}
Above, this will terminate all Aggregators
in the initial
list of the first PositionedAggregatorLists
and create the
first AggregateValue
. Then it will include all middle
AggregateValues
, which have already been calculated. On the
borders between PositionedAggregatorLists
, it will determine
if the ending object of one is equal to the initial object of the next.
If so, it will merge the Aggregators
before creating one
AggregateValue
, else it will create separate
AggregateValues
. It will determine if the same object is
represented in multiple PositionedAggregatorLists
, and merge
them all together. Finally, it will terminate all
Aggregators
in the ending list of the last
PositionedAggregatorLists
and create the last
AggregateValue
.
If super-aggregation will occur, then this will store the associated
List
of Aggregators
with each completed
AggregateValue
.
listOfPals
- A List
of
PositionedAggregatorLists
.comparator
- A Comparator
of T values.useSuperAggregation
- If true, store the list of aggregators with
each AggregateValue
, instead of setting them as not used.properties
- The List
of properties.
List
(of one item) of Lists
of
Aggregators
.public static <T> int indexOfLastMatching(java.util.List<T> list, java.util.Comparator<? super T> comparator, int startIdx)
T
- The type of objects in the List
of values.list
- The List
of values.comparator
- Decides how to compare values for equality.startIdx
- Start looking for the last match at this index.
List
that compares equal to the object represented by
the start index.public static <T> int indexOfLastMatching(java.util.List<T> list, java.util.Comparator<? super T> comparator, int startIdx, int maxIdx)
T
- The type of objects in the List
of values.list
- The List
of values.comparator
- Decides how to compare values for equality.startIdx
- Start looking for the last match at this index.maxIdx
- Don't look past this index.
List
that compares equal to the object represented
by the start index, and maxIdx
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |