Package com.tangosol.util.aggregator
Class ScriptAggregator<K,V,P,R>
java.lang.Object
com.tangosol.util.AbstractScript
com.tangosol.util.aggregator.ScriptAggregator<K,V,P,R>
- Type Parameters:
K- the type of the Map entry keysV- the type of the Map entry valuesP- the type of the partial resultR- the type of the final result
- All Implemented Interfaces:
ExternalizableLite,PortableObject,SerializationSupport,InvocableMap.EntryAggregator<K,,V, R> InvocableMap.StreamingAggregator<K,,V, P, R> Serializable
public class ScriptAggregator<K,V,P,R>
extends AbstractScript
implements InvocableMap.StreamingAggregator<K,V,P,R>, SerializationSupport
ScriptAggregator is a
InvocableMap.StreamingAggregator that wraps a script written
in one of the languages supported by Graal VM.- Since:
- 14.1.1.0
- Author:
- mk 2019.09.24
- See Also:
-
Field Summary
Fields inherited from class com.tangosol.util.AbstractScript
m_aoArgs, m_sLanguage, m_sNameFields inherited from interface com.tangosol.util.InvocableMap.StreamingAggregator
ALLOW_INCONSISTENCIES, BY_MEMBER, BY_PARTITION, PARALLEL, PRESENT_ONLY, RETAINS_ENTRIES, SERIAL -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for ExternalizableLite.ScriptAggregator(String language, String name, int characteristics, Object... args) Create aInvocableMap.StreamingAggregatorthat wraps the specified script. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccumulate(InvocableMap.Entry<? extends K, ? extends V> entry) Accumulate one entry into the result.intA bit mask representing the set of characteristics of this aggregator.booleanMerge another partial result into the result.Return the final result of the aggregation.Return the partial result of the aggregation.voidRestore the contents of a user type instance by reading its state using the specified PofReader object.voidRestore the contents of this object by loading the object's state from the passed DataInput object.Designate a replacement for an object after an instance of it is read from the buffer.supply()Create a new instance of this aggregator.voidwriteExternal(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.voidwriteExternal(DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object.Methods inherited from class com.tangosol.util.AbstractScript
getArgs, getLanguage, getNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tangosol.util.InvocableMap.StreamingAggregator
accumulate, aggregate, isAllowInconsistencies, isByMember, isByPartition, isParallel, isPresentOnly, isRetainsEntries, isSerialMethods inherited from interface com.tangosol.io.SerializationSupport
writeReplace
-
Constructor Details
-
ScriptAggregator
public ScriptAggregator()Default constructor for ExternalizableLite. -
ScriptAggregator
Create aInvocableMap.StreamingAggregatorthat wraps the specified script.- Parameters:
language- the language the script is written.name- the name of theFilterthat needs to be evaluatedcharacteristics- a bit mask representing the set of characteristics of this aggregatorargs- the arguments to be passed to the script during evaluation
-
-
Method Details
-
characteristics
public int characteristics()Description copied from interface:InvocableMap.StreamingAggregatorA bit mask representing the set of characteristics of this aggregator.By default, characteristics are a combination of
InvocableMap.StreamingAggregator.PARALLELandInvocableMap.StreamingAggregator.RETAINS_ENTRIES, which is sub-optimal and should be overridden by the aggregator implementation if the aggregator does not need to retain entries (which is often the case).- Specified by:
characteristicsin interfaceInvocableMap.StreamingAggregator<K,V, P, R> - Returns:
- a bit mask representing the set of characteristics of this aggregator
- See Also:
-
supply
Description copied from interface:InvocableMap.StreamingAggregatorCreate a new instance of this aggregator. -
accumulate
Description copied from interface:InvocableMap.StreamingAggregatorAccumulate one entry into the result.- Specified by:
accumulatein interfaceInvocableMap.StreamingAggregator<K,V, P, R> - Parameters:
entry- the entry to accumulate into the aggregation result- Returns:
trueto continue the aggregation, andfalseto signal to the caller that the result is ready and the aggregation can be short-circuited
-
combine
Description copied from interface:InvocableMap.StreamingAggregatorMerge another partial result into the result. -
getPartialResult
Description copied from interface:InvocableMap.StreamingAggregatorReturn the partial result of the aggregation.- Specified by:
getPartialResultin interfaceInvocableMap.StreamingAggregator<K,V, P, R> - Returns:
- the partial result of the aggregation
-
finalizeResult
Description copied from interface:InvocableMap.StreamingAggregatorReturn the final result of the aggregation.- Specified by:
finalizeResultin interfaceInvocableMap.StreamingAggregator<K,V, P, R> - Returns:
- the final result of the aggregation
-
readExternal
Description copied from interface:PortableObjectRestore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternalin interfacePortableObject- Overrides:
readExternalin classAbstractScript- Parameters:
in- the PofReader from which to read the object's state- Throws:
IOException- if an I/O error occurs
-
writeExternal
Description copied from interface:PortableObjectSave the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternalin interfacePortableObject- Overrides:
writeExternalin classAbstractScript- Parameters:
out- the PofWriter to which to write the object's state- Throws:
IOException- if an I/O error occurs
-
readExternal
Description copied from interface:ExternalizableLiteRestore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternalin interfaceExternalizableLite- Overrides:
readExternalin classAbstractScript- Parameters:
in- the DataInput stream to read data from in order to restore the state of this object- Throws:
IOException- if an I/O exception occurs
-
writeExternal
Description copied from interface:ExternalizableLiteSave the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternalin interfaceExternalizableLite- Overrides:
writeExternalin classAbstractScript- Parameters:
out- the DataOutput stream to write the state of this object to- Throws:
IOException- if an I/O exception occurs
-
readResolve
Description copied from interface:SerializationSupportDesignate a replacement for an object after an instance of it is read from the buffer.This method is invoked by the
Serializerif the object implementsSerializationSupportinterface.- Specified by:
readResolvein interfaceSerializationSupport- Returns:
- an object that should be returned instead of the deserialized one
- Throws:
ObjectStreamException
-