|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jagg.Aggregation.Builder
public static class Aggregation.Builder
This Builder
class follows the "Builder" pattern to create
an Aggregation
object.
Constructor Summary | |
---|---|
Aggregation.Builder()
Constructs a Builder with no aggregators, no properties,
parallelism of 1, and not using multiset discrimination. |
Method Summary | |
---|---|
Aggregation |
build()
Build the Aggregation object. |
Aggregation.Builder |
setAggregators(java.util.List<Aggregator> aggregators)
Sets the List of Aggregators to use. |
Aggregation.Builder |
setCube(java.util.List<java.lang.Integer> cube)
Sets the set of cube properties to use. |
Aggregation.Builder |
setGroupingSets(java.util.List<java.util.List<java.lang.Integer>> groupingSets)
Sets the grouping sets to use. |
Aggregation.Builder |
setParallelism(int parallelism)
Sets the degree of parallelism. |
Aggregation.Builder |
setProperties(java.util.List<java.lang.String> properties)
Sets the List of properties. |
Aggregation.Builder |
setRollup(java.util.List<java.lang.Integer> rollup)
Sets the rollup properties to use. |
Aggregation.Builder |
setRollups(java.util.List<java.util.List<java.lang.Integer>> rollups)
Sets multiple sets of rollup properties to use. |
Aggregation.Builder |
setUseMsd(boolean useMsd)
Sets whether multiset discrimination is to be used to distinguish sets of objects with shared attributes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Aggregation.Builder()
Builder
with no aggregators, no properties,
parallelism of 1, and not using multiset discrimination.
Method Detail |
---|
public Aggregation.Builder setAggregators(java.util.List<Aggregator> aggregators)
List
of Aggregators
to use. The
Aggregators
define which aggregate operatons to perform.
aggregators
- A List
of Aggregators
.
Aggregators can be created in two ways: direct instantiation, or by
using the factory method.
Aggregator agg = new SumAggregator("value");
Aggregator agg = Aggregator.getAggregator("Sum(value)");
Builder
.Aggregator
public Aggregation.Builder setProperties(java.util.List<java.lang.String> properties)
List
of properties. jAgg uses this list of
properties to "group by" the different property values. For optional
super aggregation, this is the list to which the 0-based indices
reference the properties.
properties
- The List<String>
of properties to
"group by". If this call is omitted, then values to be aggregated
must be Comparable
.
Builder
.public Aggregation.Builder setParallelism(int parallelism)
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
.
Builder
.Runtime.availableProcessors()
public Aggregation.Builder setUseMsd(boolean useMsd)
false
(use sorting).
useMsd
- Whether multiset discrimination is to be used. This is
ignored if the objects to be aggregated are being distinguished
using the fact that they are Comparable
.
Builder
.public Aggregation.Builder setGroupingSets(java.util.List<java.util.List<java.lang.Integer>> groupingSets)
setProperties
. If this is not called, then it
defaults to one grouping set consisting of all properties, e.g.
{{0, 1, ..., n - 1}}
.
groupingSets
- A List
of Lists
of
integer references. E.g. If there are 3 properties, then the
following examples would be valid grouping sets:
{{}}
Group by no properties. (The empty grouping set
produces grand totals.)
{{0, 1, 2}}
The default: "group by all".
{{}, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}}
Create a data cube.
{{1, 2}, {0, 1, 2}}
Create a rollup on the first
(index 0) property.
{{1}, {0, 2}, {0, 1, 2}}
Other combinations are
possible.
Builder
.
java.lang.IllegalArgumentException
- If the "group by" properties have not
been set yet; if any index is outside the range from 0 to
n -1, where n is the number of "group by"
properties; if any index is repeated within the same grouping set;
if any grouping set is a duplicate of any other, even if the fields
are in a different order.setProperties(java.util.List)
public Aggregation.Builder setRollup(java.util.List<java.lang.Integer> rollup)
Sets the rollup properties to use. The list contains a list of
integer references, ranging from 0 to n - 1, if n is
the number of properties already specified through
setProperties
. This produces a set of
grouping sets that together form a "rollup" of the referenced
properties. E.g.
setProperties("prop0", "prop1", "prop2", "prop3", "prop4")
.setRollup({1, 2, 3})
yields grouping sets
{{0, 1, 2, 3, 4}, {0, 1, 2, 4}, {0, 1, 4}, {0, 4}
.
This method acts as if all rollup grouping set combinations are
found, then they are passed to setGroupingSets
.
rollup
- A List
of integer references. Grouping
sets are created that each contain all properties not referenced
here, and each individual grouping set contains a different number
of referenced properties in order.
Builder
.
java.lang.IllegalArgumentException
- If any index is specified more than
once; if any index is out of range from 0 to n -1, where
n is the number of "group by" properties.setGroupingSets(java.util.List>)
,
setProperties(java.util.List)
public Aggregation.Builder setRollups(java.util.List<java.util.List<java.lang.Integer>> rollups)
Sets multiple sets of rollup properties to use. Each list contains a
list of integer references, ranging from 0 to n - 1, if
n is the number of properties already specified through
setProperties
. This produces a set of
grouping sets that together form "rollups" of the referenced
properties. E.g.
setProperties("prop0", "prop1", "prop2", "prop3", "prop4")
.setRollups({{0, 1}, {2, 3})
yields grouping sets
{{0, 1, 2, 3, 4}, {0, 2, 3, 4}, {0, 1, 2, 4}, {2, 3, 4},
{0, 2, 4}, {0, 1, 4}, {2, 4}, {0, 4}, {4}}
. Grouping sets for
the first rollup are created, and each grouping set is used to create
any subsequent rollups. Notice how a property reference not listed
("4") exists in every grouping set.
This method acts as if all rollup grouping set combinations are
found, then they are passed to setGroupingSets
.
rollups
- A List
of integer references. Grouping
sets are created that each contain all properties not referenced
here, and each individual grouping set contains a different number
of referenced properties in order.
Builder
.
java.lang.IllegalArgumentException
- If any index is specified more than
once; if any index is out of range from 0 to n -1, where
n is the number of "group by" properties.setGroupingSets(java.util.List>)
,
setProperties(java.util.List)
public Aggregation.Builder setCube(java.util.List<java.lang.Integer> cube)
Sets the set of cube properties to use. The list contains a
integer references, ranging from 0 to n - 1, if n is
the number of properties already specified through
setProperties
. This produces a set of
grouping sets that together form a "cube" of the referenced
properties. E.g.
setProperties("prop0", "prop1", "prop2", "prop3", "prop4")
.setCube({{0, 1, 3})
yields grouping sets
{{0, 1, 2, 3, 4}, {0, 1, 2, 4}, {0, 2, 3, 4}, {1, 2, 3, 4},
{0, 2, 4}, {1, 2, 4}, {2, 3, 4}, {2, 4}}
. Notice how all
property references not listed ("2, 4") exist in every grouping set.
This method acts as if all cube grouping set combinations are
found, then they are passed to setGroupingSets
.
Because cube(x, y)
is the same as
cube(x), cube(y)
, this method only accepts a simple list,
instead of a list of lists.
cube
- A List
of integer references. Grouping
sets are created that each contain all properties not referenced
here, and each individual grouping set contains a different number
of referenced properties in order.
Builder
.
java.lang.IllegalArgumentException
- If any index is specified more than
once; if any index is out of range from 0 to n -1, where
n is the number of "group by" properties.setGroupingSets(java.util.List>)
,
setProperties(java.util.List)
public Aggregation build()
Aggregation
object.
Aggregation
object that can be used to perform
the actual aggregate calculations.
java.lang.IllegalArgumentException
- If at least one
Aggregator
was not supplied with the
setAggregators
method.setAggregators(java.util.List)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |