org.apache.accumulo.examples.simple.combiner
Class StatsCombiner
java.lang.Object
org.apache.accumulo.core.iterators.WrappingIterator
org.apache.accumulo.core.iterators.Combiner
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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RADIX_OPTION
public static final String RADIX_OPTION
- See Also:
- Constant Field Values
StatsCombiner
public StatsCombiner()
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 configurebase
- The expected base/radix of the numbers.
Copyright © 2012 The Apache Software Foundation. All Rights Reserved.