public class Count<K,V> extends Base implements InvocableMap.StreamingAggregator<K,V,Integer,Integer>, ExternalizableLite, PortableObject
Base.LoggingWriter, Base.StackFrame
LOG_ALWAYS, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
ALLOW_INCONSISTENCIES, BY_MEMBER, BY_PARTITION, PARALLEL, PRESENT_ONLY, RETAINS_ENTRIES, SERIAL
Constructor and Description |
---|
Count()
Default constructor (necessary for the ExternalizableLite interface).
|
Modifier and Type | Method and Description |
---|---|
boolean |
accumulate(InvocableMap.Entry<? extends K,? extends V> entry)
Accumulate one entry into the result.
|
boolean |
accumulate(Streamer<? extends InvocableMap.Entry<? extends K,? extends V>> streamer)
Accumulate multiple entries into the result.
|
int |
characteristics()
A bit mask representing the set of characteristics of this aggregator.
|
boolean |
combine(Integer partialResult)
Merge another partial result into the result.
|
Integer |
finalizeResult()
Return the final result of the aggregation.
|
Integer |
getPartialResult()
Return the partial result of the aggregation.
|
void |
readExternal(DataInput in)
Restore the contents of this object by loading the object's state from
the passed DataInput object.
|
void |
readExternal(PofReader in)
Restore the contents of a user type instance by reading its state using
the specified PofReader object.
|
InvocableMap.StreamingAggregator<K,V,Integer,Integer> |
supply()
Create a new instance of this aggregator.
|
void |
writeExternal(DataOutput out)
Save the contents of this object by storing the object's state into
the passed DataOutput object.
|
void |
writeExternal(PofWriter out)
Save the contents of a POF user type instance by writing its state using
the specified PofWriter object.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
aggregate, isAllowInconsistencies, isByMember, isByPartition, isParallel, isPresentOnly, isRetainsEntries, isSerial
public Count()
public InvocableMap.StreamingAggregator<K,V,Integer,Integer> supply()
InvocableMap.StreamingAggregator
public boolean accumulate(Streamer<? extends InvocableMap.Entry<? extends K,? extends V>> streamer)
InvocableMap.StreamingAggregator
Important note: The default implementation of this method provides necessary logic for aggregation short-circuiting and should rarely (if ever) be overridden by the custom aggregator implementation.
accumulate
in interface InvocableMap.StreamingAggregator<K,V,Integer,Integer>
streamer
- a Streamer
that can be used to iterate over
entries to addtrue
to continue the aggregation, and false
to
signal to the caller that the result is ready and the
aggregation can be short-circuitedpublic boolean accumulate(InvocableMap.Entry<? extends K,? extends V> entry)
InvocableMap.StreamingAggregator
accumulate
in interface InvocableMap.StreamingAggregator<K,V,Integer,Integer>
entry
- the entry to accumulate into the aggregation resulttrue
to continue the aggregation, and false
to
signal to the caller that the result is ready and the
aggregation can be short-circuitedpublic boolean combine(Integer partialResult)
InvocableMap.StreamingAggregator
public Integer getPartialResult()
InvocableMap.StreamingAggregator
getPartialResult
in interface InvocableMap.StreamingAggregator<K,V,Integer,Integer>
public Integer finalizeResult()
InvocableMap.StreamingAggregator
finalizeResult
in interface InvocableMap.StreamingAggregator<K,V,Integer,Integer>
public int characteristics()
InvocableMap.StreamingAggregator
Be default, characteristics are a combination of InvocableMap.StreamingAggregator.PARALLEL
and InvocableMap.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).
characteristics
in interface InvocableMap.StreamingAggregator<K,V,Integer,Integer>
InvocableMap.StreamingAggregator.PARALLEL
,
InvocableMap.StreamingAggregator.SERIAL
,
InvocableMap.StreamingAggregator.BY_MEMBER
,
InvocableMap.StreamingAggregator.BY_PARTITION
,
InvocableMap.StreamingAggregator.RETAINS_ENTRIES
,
InvocableMap.StreamingAggregator.PRESENT_ONLY
public void readExternal(DataInput in) throws IOException
readExternal
in interface ExternalizableLite
in
- the DataInput stream to read data from in order to restore
the state of this objectIOException
- if an I/O exception occursNotActiveException
- if the object is not in its initial
state, and therefore cannot be deserialized intopublic void writeExternal(DataOutput out) throws IOException
writeExternal
in interface ExternalizableLite
out
- the DataOutput stream to write the state of this object toIOException
- if an I/O exception occurspublic void readExternal(PofReader in) throws IOException
readExternal
in interface PortableObject
in
- the PofReader from which to read the object's stateIOException
- if an I/O error occurspublic void writeExternal(PofWriter out) throws IOException
writeExternal
in interface PortableObject
out
- the PofWriter to which to write the object's stateIOException
- if an I/O error occurs