|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hazelcast.mapreduce.aggregation.Supplier<KeyIn,ValueIn,ValueOut>
KeyIn
- the input key typeValueIn
- the input value typeValueOut
- the supplied value type@Beta public abstract class Supplier<KeyIn,ValueIn,ValueOut>
The Supplier interface is used to supply values from input data structures like
IMap
or MultiMap
to an
aggregation. Suppliers can also be used to filter elements based on keys or values
using KeyPredicate
s or
Predicate
s.
Additionally you can provide a PropertyExtractor
implementation to extract or transform selected values to another value type. This is necessary
if you don't want to aggregate the actual value type of the maps but an attribute of it.
// Select all values, no need to transform Supplier supplier = Supplier.all(); // Select all values but transform to Integer Supplier supplier = Supplier.all((value) -> value.intValue()); // Select only values where the value is bigger than 50 Supplier supplier = Supplier.fromPredicate((entry) -> entry.getValue().intValue() > 50); // Select only values where the value is bigger than 50 and than chain it to a // supplier transformation to transform it into an Integer Supplier supplier = Supplier.fromPredicate((entry) -> entry.getValue().intValue() > 50, Supplier.all((value) -> value.intValue())); // Select only values where the key starts with "Foo" Supplier supplier = Supplier.fromKeyPredicate((key) -> key.startsWith("Foo")); // Select only values where the key starts with "Foo" and than chain it to a // supplier transformation to transform it into an Integer Supplier supplier = Supplier.fromKeyPredicate((key) -> key.startsWith("Foo"), Supplier.all((value) -> value.intValue()));
Constructor Summary | |
---|---|
Supplier()
|
Method Summary | ||
---|---|---|
static
|
all()
The predefined Supplier selects all values and does not perform any kind of data transformation. |
|
static
|
all(PropertyExtractor<ValueIn,ValueOut> propertyExtractor)
The predefined Supplier selects all values and performs the given PropertyExtractor s transformation to the
input data. |
|
abstract ValueOut |
apply(Map.Entry<KeyIn,ValueIn> entry)
The apply method is used to apply the actual filtering or extraction / transformation to the input entry. If the input value should be ignored by the aggregation, the Supplier has to return |
|
static
|
fromKeyPredicate(KeyPredicate<KeyIn> keyPredicate)
The predefined Supplier selects values using the given KeyPredicate
and does not perform any kind of data transformation. |
|
static
|
fromKeyPredicate(KeyPredicate<KeyIn> keyPredicate,
Supplier<KeyIn,ValueIn,ValueOut> chainedSupplier)
The predefined Supplier selects values using the given KeyPredicate
and chains the filtered value to the given Supplier which might perform data transformation. |
|
static
|
fromPredicate(Predicate<KeyIn,ValueIn> predicate)
The predefined Supplier selects values using the given Predicate
and does not perform any kind of data transformation. |
|
static
|
fromPredicate(Predicate<KeyIn,ValueIn> predicate,
Supplier<KeyIn,ValueIn,ValueOut> chainedSupplier)
The predefined Supplier selects values using the given Predicate
and chains the filtered value to the given Supplier which might perform data transformation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Supplier()
Method Detail |
---|
public abstract ValueOut apply(Map.Entry<KeyIn,ValueIn> entry)
nullas the supplied value, therefor
nullis not a legal value itself!
entry
- the entry key-value pair to supply to the aggregation
public static <KeyIn,ValueIn,ValueOut> Supplier<KeyIn,ValueIn,ValueOut> all()
KeyIn
- the input key typeValueIn
- the input value typeValueOut
- the supplied value type
public static <KeyIn,ValueIn,ValueOut> Supplier<KeyIn,ValueIn,ValueOut> all(PropertyExtractor<ValueIn,ValueOut> propertyExtractor)
PropertyExtractor
s transformation to the
input data. The returned value's type of the transformation needs to match the expected
value type of the aggregation.
KeyIn
- the input key typeValueIn
- the input value typeValueOut
- the supplied value type
public static <KeyIn,ValueIn,ValueOut> Supplier<KeyIn,ValueIn,ValueOut> fromPredicate(Predicate<KeyIn,ValueIn> predicate)
Predicate
and does not perform any kind of data transformation. Input value types need to match the
aggregations expected value type to make this Supplier work.
KeyIn
- the input key typeValueIn
- the input value typeValueOut
- the supplied value type
public static <KeyIn,ValueIn,ValueOut> Supplier<KeyIn,ValueIn,ValueOut> fromPredicate(Predicate<KeyIn,ValueIn> predicate, Supplier<KeyIn,ValueIn,ValueOut> chainedSupplier)
Predicate
and chains the filtered value to the given Supplier which might perform data transformation.
KeyIn
- the input key typeValueIn
- the input value typeValueOut
- the supplied value type
public static <KeyIn,ValueIn,ValueOut> Supplier<KeyIn,ValueIn,ValueOut> fromKeyPredicate(KeyPredicate<KeyIn> keyPredicate)
KeyPredicate
and does not perform any kind of data transformation. Input value types need to match the
aggregations expected value type to make this Supplier work.
KeyIn
- the input key typeValueIn
- the input value typeValueOut
- the supplied value type
public static <KeyIn,ValueIn,ValueOut> Supplier<KeyIn,ValueIn,ValueOut> fromKeyPredicate(KeyPredicate<KeyIn> keyPredicate, Supplier<KeyIn,ValueIn,ValueOut> chainedSupplier)
KeyPredicate
and chains the filtered value to the given Supplier which might perform data transformation.
KeyIn
- the input key typeValueIn
- the input value typeValueOut
- the supplied value type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |