org.apache.accumulo.examples.simple.combiner
Class StatsCombiner

java.lang.Object
  extended by org.apache.accumulo.core.iterators.WrappingIterator
      extended by org.apache.accumulo.core.iterators.Combiner
          extended by org.apache.accumulo.examples.simple.combiner.StatsCombiner
All Implemented Interfaces:
OptionDescriber, SortedKeyValueIterator<Key,Value>

public class StatsCombiner
extends Combiner

This combiner calculates the max, min, sum, and count of long integers represented as strings in values. It stores the result in a comma-separated value of the form max,min,sum,count. If such a value is encountered while combining, its information is incorporated into the running calculations of max, min, sum, and count. See Combiner for more information on which values are combined together. See docs/examples/README.combiner for instructions.


Nested Class Summary
 
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
static String RADIX_OPTION
           
 
Fields inherited from class org.apache.accumulo.core.iterators.Combiner
ALL_OPTION, COLUMNS_OPTION
 
Constructor Summary
StatsCombiner()
           
 
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.
 Value reduce(Key key, Iterator<Value> iter)
          Reduces a list of Values into a single Value.
static void setRadix(IteratorSetting iterConfig, int base)
          A convenience method for setting the expected base/radix of the numbers
 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.Combiner
deepCopy, 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

RADIX_OPTION

public static final String RADIX_OPTION
See Also:
Constant Field Values
Constructor Detail

StatsCombiner

public StatsCombiner()
Method Detail

reduce

public Value reduce(Key key,
                    Iterator<Value> iter)
Description copied from class: Combiner
Reduces a list of Values into a single Value.

Specified by:
reduce in class Combiner
Parameters:
key - The most recent version of the Key being reduced.
iter - An iterator over the Values for different versions of the key.
Returns:
The combined Value.

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 Combiner
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 Combiner
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 Combiner
Parameters:
options - a map of option names to option values
Returns:
true if options are valid, false otherwise

setRadix

public static void setRadix(IteratorSetting iterConfig,
                            int base)
A convenience method for setting the expected base/radix of the numbers

Parameters:
iterConfig - Iterator settings to configure
base - The expected base/radix of the numbers.


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