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_sName
Fields 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.StreamingAggregator
that wraps the specified script. -
Method Summary
Modifier and TypeMethodDescriptionboolean
accumulate
(InvocableMap.Entry<? extends K, ? extends V> entry) Accumulate one entry into the result.int
A bit mask representing the set of characteristics of this aggregator.boolean
Merge another partial result into the result.Return the final result of the aggregation.Return the partial result of the aggregation.void
Restore the contents of a user type instance by reading its state using the specified PofReader object.void
Restore 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.void
writeExternal
(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.void
writeExternal
(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, getName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tangosol.util.InvocableMap.StreamingAggregator
accumulate, aggregate, isAllowInconsistencies, isByMember, isByPartition, isParallel, isPresentOnly, isRetainsEntries, isSerial
Methods inherited from interface com.tangosol.io.SerializationSupport
writeReplace
-
Constructor Details
-
ScriptAggregator
public ScriptAggregator()Default constructor for ExternalizableLite. -
ScriptAggregator
Create aInvocableMap.StreamingAggregator
that wraps the specified script.- Parameters:
language
- the language the script is written.name
- the name of theFilter
that 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.StreamingAggregator
A bit mask representing the set of characteristics of this aggregator.By default, characteristics are a combination of
InvocableMap.StreamingAggregator.PARALLEL
andInvocableMap.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:
characteristics
in 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.StreamingAggregator
Create a new instance of this aggregator. -
accumulate
Description copied from interface:InvocableMap.StreamingAggregator
Accumulate one entry into the result.- Specified by:
accumulate
in interfaceInvocableMap.StreamingAggregator<K,
V, P, R> - Parameters:
entry
- the entry to accumulate into the aggregation result- Returns:
true
to continue the aggregation, andfalse
to signal to the caller that the result is ready and the aggregation can be short-circuited
-
combine
Description copied from interface:InvocableMap.StreamingAggregator
Merge another partial result into the result. -
getPartialResult
Description copied from interface:InvocableMap.StreamingAggregator
Return the partial result of the aggregation.- Specified by:
getPartialResult
in interfaceInvocableMap.StreamingAggregator<K,
V, P, R> - Returns:
- the partial result of the aggregation
-
finalizeResult
Description copied from interface:InvocableMap.StreamingAggregator
Return the final result of the aggregation.- Specified by:
finalizeResult
in interfaceInvocableMap.StreamingAggregator<K,
V, P, R> - Returns:
- the final result of the aggregation
-
readExternal
Description copied from interface:PortableObject
Restore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternal
in interfacePortableObject
- Overrides:
readExternal
in 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:PortableObject
Save the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternal
in interfacePortableObject
- Overrides:
writeExternal
in 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:ExternalizableLite
Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternal
in interfaceExternalizableLite
- Overrides:
readExternal
in 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:ExternalizableLite
Save the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternal
in interfaceExternalizableLite
- Overrides:
writeExternal
in 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:SerializationSupport
Designate a replacement for an object after an instance of it is read from the buffer.This method is invoked by the
Serializer
if the object implementsSerializationSupport
interface.- Specified by:
readResolve
in interfaceSerializationSupport
- Returns:
- an object that should be returned instead of the deserialized one
- Throws:
ObjectStreamException
-