org.apache.accumulo.core.iterators
Class LongCombiner

java.lang.Object
  extended by org.apache.accumulo.core.iterators.WrappingIterator
      extended by org.apache.accumulo.core.iterators.Combiner
          extended by org.apache.accumulo.core.iterators.TypedValueCombiner<Long>
              extended by org.apache.accumulo.core.iterators.LongCombiner
All Implemented Interfaces:
OptionDescriber, SortedKeyValueIterator<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 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.


Nested Class Summary
static class LongCombiner.FixedLenEncoder
          An Encoder that uses an 8-byte encoding for Longs.
static class LongCombiner.StringEncoder
          An Encoder that uses a String representation of Longs.
static class LongCombiner.Type
           
static class LongCombiner.VarLenEncoder
          An Encoder that uses a variable-length encoding for Longs.
 
Nested classes/interfaces inherited from class org.apache.accumulo.core.iterators.TypedValueCombiner
TypedValueCombiner.Encoder<V>
 
Nested classes/interfaces inherited from class org.apache.accumulo.core.iterators.Combiner
Combiner.ValueIterator
 
Nested classes/interfaces inherited from interface org.apache.accumulo.core.iterators.OptionDescriber
OptionDescriber.IteratorOptions
 
Field Summary
protected static String CLASS_PREFIX
           
static TypedValueCombiner.Encoder<Long> FIXED_LEN_ENCODER
           
static TypedValueCombiner.Encoder<Long> STRING_ENCODER
           
protected static String TYPE
           
static TypedValueCombiner.Encoder<Long> VAR_LEN_ENCODER
           
 
Fields inherited from class org.apache.accumulo.core.iterators.TypedValueCombiner
LOSSY
 
Fields inherited from class org.apache.accumulo.core.iterators.Combiner
ALL_OPTION, COLUMNS_OPTION
 
Constructor Summary
LongCombiner()
           
 
Method Summary
 OptionDescriber.IteratorOptions describeOptions()
          Gets an iterator options object that contains information needed to configure this iterator.
 void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env)
          Initializes the iterator.
static long safeAdd(long a, long b)
           
static void setEncodingType(IteratorSetting is, Class<? extends TypedValueCombiner.Encoder<Long>> encoderClass)
          A convenience method for setting the long encoding type.
static void setEncodingType(IteratorSetting is, LongCombiner.Type type)
          A convenience method for setting the long encoding type.
static void setEncodingType(IteratorSetting is, String encoderClassName)
          A convenience method for setting the long encoding type.
 boolean validateOptions(Map<String,String> options)
          Check to see if an options map contains all options required by an iterator and that the option values are in the expected formats.
 
Methods inherited from class org.apache.accumulo.core.iterators.TypedValueCombiner
deepCopy, reduce, setEncoder, setEncoder, setLossyness, testEncoder, testEncoder, typedReduce
 
Methods inherited from class org.apache.accumulo.core.iterators.Combiner
getTopKey, getTopValue, hasTop, next, seek, setColumns, setCombineAllColumns
 
Methods inherited from class org.apache.accumulo.core.iterators.WrappingIterator
getSource, setSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIXED_LEN_ENCODER

public static final TypedValueCombiner.Encoder<Long> FIXED_LEN_ENCODER

VAR_LEN_ENCODER

public static final TypedValueCombiner.Encoder<Long> VAR_LEN_ENCODER

STRING_ENCODER

public static final TypedValueCombiner.Encoder<Long> STRING_ENCODER

TYPE

protected static final String TYPE
See Also:
Constant Field Values

CLASS_PREFIX

protected static final String CLASS_PREFIX
See Also:
Constant Field Values
Constructor Detail

LongCombiner

public LongCombiner()
Method Detail

init

public void init(SortedKeyValueIterator<Key,Value> source,
                 Map<String,String> options,
                 IteratorEnvironment env)
          throws IOException
Description copied from interface: SortedKeyValueIterator
Initializes the iterator. Data should not be read from the source in this method.

Specified by:
init in interface SortedKeyValueIterator<Key,Value>
Overrides:
init in class TypedValueCombiner<Long>
Parameters:
source - SortedKeyValueIterator source to read data from.
options - Map map of string option names to option values.
env - IteratorEnvironment environment in which iterator is being run.
Throws:
IOException - unused.

describeOptions

public OptionDescriber.IteratorOptions describeOptions()
Description copied from interface: OptionDescriber
Gets an iterator options object that contains information needed to configure this iterator. This object will be used by the accumulo shell to prompt the user to input the appropriate information.

Specified by:
describeOptions in interface OptionDescriber
Overrides:
describeOptions in class TypedValueCombiner<Long>
Returns:
an iterator options object

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

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 TypedValueCombiner.Encoder<Long>> encoderClass)
A convenience method for setting the long encoding type.

Parameters:
is - IteratorSetting object to configure.
encoderClass - Class> 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.


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.