Class LongCombiner

  • All Implemented Interfaces:
    OptionDescriber, SortedKeyValueIterator<Key,​Value>, YieldingKeyValueIterator<Key,​Value>
    Direct Known Subclasses:
    MaxCombiner, MinCombiner, SummingCombiner

    public abstract class LongCombiner
    extends TypedValueCombiner<Long>
    A TypedValueCombiner that translates each Value to a Long before reducing, then encodes the reduced Long back to a Value. Subclasses must implement a typedReduce method: public Long typedReduce(Key key, Iterator<Long> iter); This typedReduce method will be passed the most recent Key and an iterator over the Values (translated to Longs) for all non-deleted versions of that Key. A required option for this Combiner is "type" which indicates which type of Encoder to use to encode and decode Longs into Values. Supported types are VARNUM, LONG, and STRING which indicate the VarNumEncoder, LongEncoder, and StringEncoder respectively.
    • Constructor Detail

      • LongCombiner

        public LongCombiner()
    • Method Detail

      • validateOptions

        public boolean validateOptions​(Map<String,​String> options)
        Description copied from interface: OptionDescriber
        Check to see if an options map contains all options required by an iterator and that the option values are in the expected formats.
        Specified by:
        validateOptions in interface OptionDescriber
        Overrides:
        validateOptions in class TypedValueCombiner<Long>
        Parameters:
        options - a map of option names to option values
        Returns:
        true if options are valid, false otherwise (IllegalArgumentException preferred)
      • safeAdd

        public static long safeAdd​(long a,
                                   long b)
      • setEncodingType

        public static void setEncodingType​(IteratorSetting is,
                                           LongCombiner.Type type)
        A convenience method for setting the long encoding type.
        Parameters:
        is - IteratorSetting object to configure.
        type - LongCombiner.Type specifying the encoding type.
      • setEncodingType

        public static void setEncodingType​(IteratorSetting is,
                                           Class<? extends Encoder<Long>> encoderClass)
        A convenience method for setting the long encoding type.
        Parameters:
        is - IteratorSetting object to configure.
        encoderClass - Class<? extends Encoder<Long>> specifying the encoding type.
      • setEncodingType

        public static void setEncodingType​(IteratorSetting is,
                                           String encoderClassName)
        A convenience method for setting the long encoding type.
        Parameters:
        is - IteratorSetting object to configure.
        encoderClassName - name of a class specifying the encoding type.