Class AbstractAggregator<K,​V,​T,​E,​R>

    • Field Detail

      • m_fParallel

        protected boolean m_fParallel
        Set to true if this aggregator realizes that it is going to be used in parallel.
    • Constructor Detail

      • AbstractAggregator

        public AbstractAggregator()
        Deserialization constructor.
      • AbstractAggregator

        public AbstractAggregator​(ValueExtractor<? super T,​? extends E> extractor)
        Construct an AbstractAggregator that will aggregate values extracted from a set of InvocableMap.Entry objects.
        Parameters:
        extractor - the extractor that provides values to aggregate
      • AbstractAggregator

        public AbstractAggregator​(String sMethod)
        Construct an AbstractAggregator that will aggregate values extracted from a set of InvocableMap.Entry objects.
        Parameters:
        sMethod - the name of the method that could be invoked via reflection and that returns values to aggregate; this parameter can also be a dot-delimited sequence of method names which would result in an aggregator based on the ChainedExtractor that is based on an array of corresponding ReflectionExtractor objects
    • Method Detail

      • accumulate

        public boolean accumulate​(Streamer<? extends InvocableMap.Entry<? extends K,​? extends V>> streamer)
        Description copied from interface: InvocableMap.StreamingAggregator
        Accumulate multiple entries into the result.

        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.

        Specified by:
        accumulate in interface InvocableMap.StreamingAggregator<K,​V,​T,​E>
        Parameters:
        streamer - a Streamer that can be used to iterate over entries to add
        Returns:
        true to continue the aggregation, and false to signal to the caller that the result is ready and the aggregation can be short-circuited
      • accumulate

        public boolean accumulate​(InvocableMap.Entry<? extends K,​? extends V> entry)
        Description copied from interface: InvocableMap.StreamingAggregator
        Accumulate one entry into the result.
        Specified by:
        accumulate in interface InvocableMap.StreamingAggregator<K,​V,​T,​E>
        Parameters:
        entry - the entry to accumulate into the aggregation result
        Returns:
        true to continue the aggregation, and false to signal to the caller that the result is ready and the aggregation can be short-circuited
      • combine

        public boolean combine​(Object partialResult)
        Description copied from interface: InvocableMap.StreamingAggregator
        Merge another partial result into the result.
        Specified by:
        combine in interface InvocableMap.StreamingAggregator<K,​V,​T,​E>
        Parameters:
        partialResult - the partial result to merge
        Returns:
        true to continue the aggregation, and false to signal to the caller that the result is ready and the aggregation can be short-circuited
      • ensureInitialized

        protected void ensureInitialized​(boolean fFinal)
        Ensure that this aggregator is initialized.
        Parameters:
        fFinal - true is passed if the aggregation process that is being initialized must produce a final aggregation result; this will only be false if a parallel approach is being used and the initial (partial) aggregation process is being initialized
      • processEntry

        protected void processEntry​(InvocableMap.Entry<? extends K,​? extends V> entry)
        Incorporate one aggregatable entry into the result.
        Parameters:
        entry - the entry to incorporate into the aggregation result
      • getValueExtractor

        public ValueExtractor<? super T,​? extends E> getValueExtractor()
        Determine the ValueExtractor whose values this aggregator is aggregating.
        Returns:
        the ValueExtractor used by this aggregator
      • init

        protected abstract void init​(boolean fFinal)
        Initialize the aggregation result.
        Parameters:
        fFinal - true is passed if the aggregation process that is being initialized must produce a final aggregation result; this will only be false if a parallel approach is being used and the initial (partial) aggregation process is being initialized
      • process

        protected abstract void process​(Object o,
                                        boolean fFinal)
        Incorporate one aggregatable value into the result.

        If the fFinal parameter is true, the given object is a partial result (returned by an individual parallel aggregator) that should be incorporated into the final result; otherwise, the object is a value extracted from an InvocableMap.Entry.

        Parameters:
        o - the value to incorporate into the aggregated result
        fFinal - true to indicate that the given object is a partial result returned by a parallel aggregator
      • finalizeResult

        protected abstract Object finalizeResult​(boolean fFinal)
        Obtain the result of the aggregation.

        If the fFinal parameter is true, the returned object must be the final result of the aggregation; otherwise, the returned object will be treated as a partial result that should be incorporated into the final result.

        Parameters:
        fFinal - true to indicate that the final result of the aggregation process should be returned; this will only be false if a parallel approach is being used
        Returns:
        the result of the aggregation process
      • toString

        public String toString()
        Provide a human-readable representation of this object.
        Overrides:
        toString in class Object
        Returns:
        a String whose contents represent the value of this object
      • hashCode

        public int hashCode()
        Returns a hash code value for this object.
        Overrides:
        hashCode in class Object
        Returns:
        a hash code value for this object
      • equals

        public boolean equals​(Object o)
        Compares this object with another object for equality.
        Overrides:
        equals in class Object
        Parameters:
        o - an object reference or null
        Returns:
        true iff the passed object reference is of the same class and has the same state as this object
      • readExternal

        public void readExternal​(DataInput in)
                          throws IOException
        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 interface ExternalizableLite
        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
        NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into
      • writeExternal

        public void writeExternal​(DataOutput out)
                           throws IOException
        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 interface ExternalizableLite
        Parameters:
        out - the DataOutput stream to write the state of this object to
        Throws:
        IOException - if an I/O exception occurs
      • readExternal

        public void readExternal​(PofReader in)
                          throws IOException
        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 interface PortableObject
        Parameters:
        in - the PofReader from which to read the object's state
        Throws:
        IOException - if an I/O error occurs
      • writeExternal

        public void writeExternal​(PofWriter out)
                           throws IOException
        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 interface PortableObject
        Parameters:
        out - the PofWriter to which to write the object's state
        Throws:
        IOException - if an I/O error occurs