You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2015/01/09 03:44:40 UTC
[36/66] [abbrv] accumulo git commit: ACCUMULO-3451 Format master
branch (1.7.0-SNAPSHOT)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java
index dd693f1..fcca805 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java
@@ -30,48 +30,48 @@ import org.apache.accumulo.core.data.Value;
import org.apache.hadoop.io.Text;
public class FirstEntryInRowIterator extends SkippingIterator implements OptionDescriber {
-
+
// options
static final String NUM_SCANS_STRING_NAME = "scansBeforeSeek";
-
+
// iterator predecessor seek options to pass through
private Range latestRange;
private Collection<ByteSequence> latestColumnFamilies;
private boolean latestInclusive;
-
+
// private fields
private Text lastRowFound;
private int numscans;
-
+
/**
* convenience method to set the option to optimize the frequency of scans vs. seeks
*/
public static void setNumScansBeforeSeek(IteratorSetting cfg, int num) {
cfg.addOption(NUM_SCANS_STRING_NAME, Integer.toString(num));
}
-
+
// this must be public for OptionsDescriber
public FirstEntryInRowIterator() {
super();
}
-
+
public FirstEntryInRowIterator(FirstEntryInRowIterator other, IteratorEnvironment env) {
super();
setSource(other.getSource().deepCopy(env));
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new FirstEntryInRowIterator(this, env);
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
String o = options.get(NUM_SCANS_STRING_NAME);
numscans = o == null ? 10 : Integer.parseInt(o);
}
-
+
// this is only ever called immediately after getting "next" entry
@Override
protected void consume() throws IOException {
@@ -79,7 +79,7 @@ public class FirstEntryInRowIterator extends SkippingIterator implements OptionD
return;
int count = 0;
while (getSource().hasTop() && lastRowFound.equals(getSource().getTopKey().getRow())) {
-
+
// try to efficiently jump to the next matching key
if (count < numscans) {
++count;
@@ -87,7 +87,7 @@ public class FirstEntryInRowIterator extends SkippingIterator implements OptionD
} else {
// too many scans, just seek
count = 0;
-
+
// determine where to seek to, but don't go beyond the user-specified range
Key nextKey = getSource().getTopKey().followingKey(PartialKey.ROW);
if (!latestRange.afterEndKey(nextKey))
@@ -100,14 +100,14 @@ public class FirstEntryInRowIterator extends SkippingIterator implements OptionD
}
lastRowFound = getSource().hasTop() ? getSource().getTopKey().getRow(lastRowFound) : null;
}
-
+
private boolean finished = true;
-
+
@Override
public boolean hasTop() {
return !finished && getSource().hasTop();
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
// save parameters for future internal seeks
@@ -115,19 +115,19 @@ public class FirstEntryInRowIterator extends SkippingIterator implements OptionD
latestColumnFamilies = columnFamilies;
latestInclusive = inclusive;
lastRowFound = null;
-
+
Key startKey = range.getStartKey();
Range seekRange = new Range(startKey == null ? null : new Key(startKey.getRow()), true, range.getEndKey(), range.isEndKeyInclusive());
super.seek(seekRange, columnFamilies, inclusive);
finished = false;
-
+
if (getSource().hasTop()) {
lastRowFound = getSource().getTopKey().getRow();
if (range.beforeStartKey(getSource().getTopKey()))
consume();
}
}
-
+
@Override
public IteratorOptions describeOptions() {
String name = "firstEntry";
@@ -136,7 +136,7 @@ public class FirstEntryInRowIterator extends SkippingIterator implements OptionD
namedOptions.put(NUM_SCANS_STRING_NAME, "Number of scans to try before seeking [10]");
return new IteratorOptions(name, desc, namedOptions, null);
}
-
+
@Override
public boolean validateOptions(Map<String,String> options) {
try {
@@ -148,5 +148,5 @@ public class FirstEntryInRowIterator extends SkippingIterator implements OptionD
}
return true;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/GrepIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/GrepIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/GrepIterator.java
index f7a68e9..5c44c31 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/GrepIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/GrepIterator.java
@@ -18,10 +18,10 @@ package org.apache.accumulo.core.iterators;
/**
* This class remains here for backwards compatibility.
- *
+ *
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.GrepIterator}
*/
@Deprecated
public class GrepIterator extends org.apache.accumulo.core.iterators.user.GrepIterator {
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/IntersectingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/IntersectingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/IntersectingIterator.java
index 3f6ee9f..5765982 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/IntersectingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/IntersectingIterator.java
@@ -18,10 +18,10 @@ package org.apache.accumulo.core.iterators;
/**
* This class remains here for backwards compatibility.
- *
+ *
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.IntersectingIterator}
*/
@Deprecated
public class IntersectingIterator extends org.apache.accumulo.core.iterators.user.IntersectingIterator {
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/IterationInterruptedException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/IterationInterruptedException.java b/core/src/main/java/org/apache/accumulo/core/iterators/IterationInterruptedException.java
index 63f6d01..4bfc4aa 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/IterationInterruptedException.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/IterationInterruptedException.java
@@ -17,13 +17,13 @@
package org.apache.accumulo.core.iterators;
public class IterationInterruptedException extends RuntimeException {
-
+
private static final long serialVersionUID = 1L;
-
+
public IterationInterruptedException() {
super();
}
-
+
public IterationInterruptedException(String msg) {
super(msg);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java
index 9e20cb1..f708db7 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorEnvironment.java
@@ -24,15 +24,15 @@ import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
public interface IteratorEnvironment {
-
+
SortedKeyValueIterator<Key,Value> reserveMapFileReader(String mapFileName) throws IOException;
-
+
AccumuloConfiguration getConfig();
-
+
IteratorScope getIteratorScope();
-
+
boolean isFullMajorCompaction();
-
+
void registerSideChannel(SortedKeyValueIterator<Key,Value> iter);
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java
index 2b2c699..98392f6 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java
@@ -50,16 +50,16 @@ import org.apache.thrift.TSerializer;
import org.apache.thrift.protocol.TBinaryProtocol;
import com.google.common.base.Preconditions;
+
public class IteratorUtil {
-
+
private static final Logger log = Logger.getLogger(IteratorUtil.class);
-
+
public static enum IteratorScope {
majc, minc, scan;
/**
- * Fetch the correct configuration key prefix for the given scope. Throws an
- * IllegalArgumentException if no property exists for the given scope.
+ * Fetch the correct configuration key prefix for the given scope. Throws an IllegalArgumentException if no property exists for the given scope.
*/
public static Property getProperty(IteratorScope scope) {
Preconditions.checkNotNull(scope);
@@ -75,7 +75,7 @@ public class IteratorUtil {
}
}
}
-
+
public static class IterInfoComparator implements Comparator<IterInfo>, Serializable {
private static final long serialVersionUID = 1L;
@@ -83,44 +83,45 @@ public class IteratorUtil {
public int compare(IterInfo o1, IterInfo o2) {
return (o1.priority < o2.priority ? -1 : (o1.priority == o2.priority ? 0 : 1));
}
-
+
}
-
+
/**
* Generate the initial (default) properties for a table
+ *
* @param limitVersion
- * include a VersioningIterator at priority 20 that retains a single version of a given K/V pair.
+ * include a VersioningIterator at priority 20 that retains a single version of a given K/V pair.
* @return A map of Table properties
*/
public static Map<String,String> generateInitialTableProperties(boolean limitVersion) {
TreeMap<String,String> props = new TreeMap<String,String>();
-
+
if (limitVersion) {
- for (IteratorScope iterScope : IteratorScope.values()) {
- props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers", "20," + VersioningIterator.class.getName());
- props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers.opt.maxVersions", "1");
- }
+ for (IteratorScope iterScope : IteratorScope.values()) {
+ props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers", "20," + VersioningIterator.class.getName());
+ props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers.opt.maxVersions", "1");
+ }
}
props.put(Property.TABLE_CONSTRAINT_PREFIX.toString() + "1", DefaultKeySizeConstraint.class.getName());
return props;
}
-
+
public static int getMaxPriority(IteratorScope scope, AccumuloConfiguration conf) {
List<IterInfo> iters = new ArrayList<IterInfo>();
parseIterConf(scope, iters, new HashMap<String,Map<String,String>>(), conf);
-
+
int max = 0;
-
+
for (IterInfo iterInfo : iters) {
if (iterInfo.priority > max)
max = iterInfo.priority;
}
-
+
return max;
}
-
+
protected static void parseIterConf(IteratorScope scope, List<IterInfo> iters, Map<String,Map<String,String>> allOptions, AccumuloConfiguration conf) {
final Property scopeProperty = IteratorScope.getProperty(scope);
final String scopePropertyKey = scopeProperty.getKey();
@@ -128,7 +129,7 @@ public class IteratorUtil {
for (Entry<String,String> entry : conf.getAllPropertiesWithPrefix(scopeProperty).entrySet()) {
String suffix = entry.getKey().substring(scopePropertyKey.length());
String suffixSplit[] = suffix.split("\\.", 3);
-
+
if (suffixSplit.length == 1) {
String sa[] = entry.getValue().split(",");
int prio = Integer.parseInt(sa[0]);
@@ -137,15 +138,15 @@ public class IteratorUtil {
} else if (suffixSplit.length == 3 && suffixSplit[1].equals("opt")) {
String iterName = suffixSplit[0];
String optName = suffixSplit[2];
-
+
Map<String,String> options = allOptions.get(iterName);
if (options == null) {
options = new HashMap<String,String>();
allOptions.put(iterName, options);
}
-
+
options.put(optName, entry.getValue());
-
+
} else {
log.warn("Unrecognizable option: " + entry.getKey());
}
@@ -153,13 +154,13 @@ public class IteratorUtil {
Collections.sort(iters, new IterInfoComparator());
}
-
+
public static String findIterator(IteratorScope scope, String className, AccumuloConfiguration conf, Map<String,String> opts) {
ArrayList<IterInfo> iters = new ArrayList<IterInfo>();
Map<String,Map<String,String>> allOptions = new HashMap<String,Map<String,String>>();
-
+
parseIterConf(scope, iters, allOptions, conf);
-
+
for (IterInfo iterInfo : iters)
if (iterInfo.className.equals(className)) {
Map<String,String> tmpOpts = allOptions.get(iterInfo.iterName);
@@ -168,46 +169,46 @@ public class IteratorUtil {
}
return iterInfo.iterName;
}
-
+
return null;
}
-
+
public static <K extends WritableComparable<?>,V extends Writable> SortedKeyValueIterator<K,V> loadIterators(IteratorScope scope,
SortedKeyValueIterator<K,V> source, KeyExtent extent, AccumuloConfiguration conf, IteratorEnvironment env) throws IOException {
List<IterInfo> emptyList = Collections.emptyList();
Map<String,Map<String,String>> emptyMap = Collections.emptyMap();
return loadIterators(scope, source, extent, conf, emptyList, emptyMap, env);
}
-
+
public static <K extends WritableComparable<?>,V extends Writable> SortedKeyValueIterator<K,V> loadIterators(IteratorScope scope,
SortedKeyValueIterator<K,V> source, KeyExtent extent, AccumuloConfiguration conf, List<IteratorSetting> iterators, IteratorEnvironment env)
throws IOException {
-
+
List<IterInfo> ssiList = new ArrayList<IterInfo>();
Map<String,Map<String,String>> ssio = new HashMap<String,Map<String,String>>();
-
+
for (IteratorSetting is : iterators) {
ssiList.add(new IterInfo(is.getPriority(), is.getIteratorClass(), is.getName()));
ssio.put(is.getName(), is.getOptions());
}
-
+
return loadIterators(scope, source, extent, conf, ssiList, ssio, env, true);
}
-
+
public static <K extends WritableComparable<?>,V extends Writable> SortedKeyValueIterator<K,V> loadIterators(IteratorScope scope,
SortedKeyValueIterator<K,V> source, KeyExtent extent, AccumuloConfiguration conf, List<IterInfo> ssiList, Map<String,Map<String,String>> ssio,
IteratorEnvironment env) throws IOException {
return loadIterators(scope, source, extent, conf, ssiList, ssio, env, true);
}
-
+
public static <K extends WritableComparable<?>,V extends Writable> SortedKeyValueIterator<K,V> loadIterators(IteratorScope scope,
SortedKeyValueIterator<K,V> source, KeyExtent extent, AccumuloConfiguration conf, List<IterInfo> ssiList, Map<String,Map<String,String>> ssio,
IteratorEnvironment env, boolean useAccumuloClassLoader) throws IOException {
List<IterInfo> iters = new ArrayList<IterInfo>(ssiList);
Map<String,Map<String,String>> allOptions = new HashMap<String,Map<String,String>>();
-
+
parseIterConf(scope, iters, allOptions, conf);
-
+
for (Entry<String,Map<String,String>> entry : ssio.entrySet()) {
if (entry.getValue() == null)
continue;
@@ -218,37 +219,37 @@ public class IteratorUtil {
options.putAll(entry.getValue());
}
}
-
+
return loadIterators(source, iters, allOptions, env, useAccumuloClassLoader, conf.get(Property.TABLE_CLASSPATH));
}
-
+
@SuppressWarnings("unchecked")
public static <K extends WritableComparable<?>,V extends Writable> SortedKeyValueIterator<K,V> loadIterators(SortedKeyValueIterator<K,V> source,
Collection<IterInfo> iters, Map<String,Map<String,String>> iterOpts, IteratorEnvironment env, boolean useAccumuloClassLoader, String context)
throws IOException {
// wrap the source in a SynchronizedIterator in case any of the additional configured iterators want to use threading
SortedKeyValueIterator<K,V> prev = new SynchronizedIterator<K,V>(source);
-
+
try {
for (IterInfo iterInfo : iters) {
-
+
Class<? extends SortedKeyValueIterator<K,V>> clazz;
- if (useAccumuloClassLoader){
+ if (useAccumuloClassLoader) {
if (context != null && !context.equals(""))
clazz = (Class<? extends SortedKeyValueIterator<K,V>>) AccumuloVFSClassLoader.getContextManager().loadClass(context, iterInfo.className,
SortedKeyValueIterator.class);
else
clazz = (Class<? extends SortedKeyValueIterator<K,V>>) AccumuloVFSClassLoader.loadClass(iterInfo.className, SortedKeyValueIterator.class);
- }else{
+ } else {
clazz = (Class<? extends SortedKeyValueIterator<K,V>>) Class.forName(iterInfo.className).asSubclass(SortedKeyValueIterator.class);
}
SortedKeyValueIterator<K,V> skvi = clazz.newInstance();
-
+
Map<String,String> options = iterOpts.get(iterInfo.iterName);
-
+
if (options == null)
options = Collections.emptyMap();
-
+
skvi.init(prev, options, env);
prev = skvi;
}
@@ -264,73 +265,72 @@ public class IteratorUtil {
}
return prev;
}
-
+
public static Range maximizeStartKeyTimeStamp(Range range) {
Range seekRange = range;
-
+
if (range.getStartKey() != null && range.getStartKey().getTimestamp() != Long.MAX_VALUE) {
Key seekKey = new Key(seekRange.getStartKey());
seekKey.setTimestamp(Long.MAX_VALUE);
seekRange = new Range(seekKey, true, range.getEndKey(), range.isEndKeyInclusive());
}
-
+
return seekRange;
}
-
+
public static Range minimizeEndKeyTimeStamp(Range range) {
Range seekRange = range;
-
+
if (range.getEndKey() != null && range.getEndKey().getTimestamp() != Long.MIN_VALUE) {
Key seekKey = new Key(seekRange.getEndKey());
seekKey.setTimestamp(Long.MIN_VALUE);
seekRange = new Range(range.getStartKey(), range.isStartKeyInclusive(), seekKey, true);
}
-
+
return seekRange;
}
-
+
public static TIteratorSetting toTIteratorSetting(IteratorSetting is) {
return new TIteratorSetting(is.getPriority(), is.getName(), is.getIteratorClass(), is.getOptions());
}
-
+
public static IteratorSetting toIteratorSetting(TIteratorSetting tis) {
return new IteratorSetting(tis.getPriority(), tis.getName(), tis.getIteratorClass(), tis.getProperties());
}
public static IteratorConfig toIteratorConfig(List<IteratorSetting> iterators) {
ArrayList<TIteratorSetting> tisList = new ArrayList<TIteratorSetting>();
-
+
for (IteratorSetting iteratorSetting : iterators) {
tisList.add(toTIteratorSetting(iteratorSetting));
}
-
+
return new IteratorConfig(tisList);
}
-
+
public static List<IteratorSetting> toIteratorSettings(IteratorConfig ic) {
List<IteratorSetting> ret = new ArrayList<IteratorSetting>();
for (TIteratorSetting tIteratorSetting : ic.getIterators()) {
ret.add(toIteratorSetting(tIteratorSetting));
}
-
+
return ret;
}
public static byte[] encodeIteratorSettings(IteratorConfig iterators) {
TSerializer tser = new TSerializer(new TBinaryProtocol.Factory());
-
+
try {
return tser.serialize(iterators);
} catch (TException e) {
throw new RuntimeException(e);
}
}
-
+
public static byte[] encodeIteratorSettings(List<IteratorSetting> iterators) {
return encodeIteratorSettings(toIteratorConfig(iterators));
}
-
public static List<IteratorSetting> decodeIteratorSettings(byte[] enc) {
TDeserializer tdser = new TDeserializer(new TBinaryProtocol.Factory());
IteratorConfig ic = new IteratorConfig();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/LargeRowFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/LargeRowFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/LargeRowFilter.java
index 4194202..75155f9 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/LargeRowFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/LargeRowFilter.java
@@ -18,10 +18,10 @@ package org.apache.accumulo.core.iterators;
/**
* This class remains here for backwards compatibility.
- *
+ *
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.LargeRowFilter}
*/
@Deprecated
public class LargeRowFilter extends org.apache.accumulo.core.iterators.user.LargeRowFilter {
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
index 3c6c6d2..ad44b15 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
@@ -32,11 +32,11 @@ import org.apache.hadoop.io.WritableUtils;
/**
* 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.
*/
@@ -44,10 +44,10 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
public static final Encoder<Long> FIXED_LEN_ENCODER = new FixedLenEncoder();
public static final Encoder<Long> VAR_LEN_ENCODER = new VarLenEncoder();
public static final Encoder<Long> STRING_ENCODER = new StringEncoder();
-
+
protected static final String TYPE = "type";
protected static final String CLASS_PREFIX = "class:";
-
+
public static enum Type {
/**
* indicates a variable-length encoding of a Long using {@link LongCombiner.VarLenEncoder}
@@ -62,13 +62,13 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
*/
STRING
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
setEncoder(options);
}
-
+
private void setEncoder(Map<String,String> options) {
String type = options.get(TYPE);
if (type == null)
@@ -92,7 +92,7 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
}
}
}
-
+
@Override
public IteratorOptions describeOptions() {
IteratorOptions io = super.describeOptions();
@@ -101,7 +101,7 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
io.addNamedOption(TYPE, "<VARLEN|FIXEDLEN|STRING|fullClassName>");
return io;
}
-
+
@Override
public boolean validateOptions(Map<String,String> options) {
if (super.validateOptions(options) == false)
@@ -113,7 +113,7 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
}
return true;
}
-
+
/**
* An Encoder that uses a variable-length encoding for Longs. It uses WritableUtils.writeVLong and WritableUtils.readVLong for encoding and decoding.
*/
@@ -122,16 +122,16 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
public byte[] encode(Long v) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
-
+
try {
WritableUtils.writeVLong(dos, v);
} catch (IOException e) {
throw new NumberFormatException(e.getMessage());
}
-
+
return baos.toByteArray();
}
-
+
@Override
public Long decode(byte[] b) {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(b));
@@ -142,7 +142,7 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
}
}
}
-
+
/**
* An Encoder that uses an 8-byte encoding for Longs.
*/
@@ -160,12 +160,12 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
b[7] = (byte) (l >>> 0);
return b;
}
-
+
@Override
public Long decode(byte[] b) {
return decode(b, 0);
}
-
+
public static long decode(byte[] b, int offset) {
if (b.length < offset + 8)
throw new ValueFormatException("trying to convert to long, but byte array isn't long enough, wanted " + (offset + 8) + " found " + b.length);
@@ -173,7 +173,7 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
+ ((long) (b[offset + 4] & 255) << 24) + ((b[offset + 5] & 255) << 16) + ((b[offset + 6] & 255) << 8) + ((b[offset + 7] & 255) << 0));
}
}
-
+
/**
* An Encoder that uses a String representation of Longs. It uses Long.toString and Long.parseLong for encoding and decoding.
*/
@@ -182,7 +182,7 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
public byte[] encode(Long v) {
return Long.toString(v).getBytes(UTF_8);
}
-
+
@Override
public Long decode(byte[] b) {
try {
@@ -192,7 +192,7 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
}
}
}
-
+
public static long safeAdd(long a, long b) {
long aSign = Long.signum(a);
long bSign = Long.signum(b);
@@ -207,10 +207,10 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
}
return a + b;
}
-
+
/**
* A convenience method for setting the long encoding type.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param type
@@ -219,10 +219,10 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
public static void setEncodingType(IteratorSetting is, LongCombiner.Type type) {
is.addOption(TYPE, type.toString());
}
-
+
/**
* A convenience method for setting the long encoding type.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param encoderClass
@@ -231,10 +231,10 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
public static void setEncodingType(IteratorSetting is, Class<? extends Encoder<Long>> encoderClass) {
is.addOption(TYPE, CLASS_PREFIX + encoderClass.getName());
}
-
+
/**
* A convenience method for setting the long encoding type.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param encoderClassName
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java b/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java
index 6069a39..97fd29a 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java
@@ -25,10 +25,10 @@ import java.util.Map;
* The OptionDescriber interface allows you to set up iterator properties interactively in the accumulo shell. If your iterator and/or filter must implement
* this interface for the interactive part. The alternative would be to manually set configuration options with the config -t tableName property=value. If you
* go the manual route, be careful to use the correct structure for the property and to set all the properties required for the iterator.
- *
+ *
* OptionDescribers will need to implement two methods: {@code describeOptions()} which returns an instance of {@link IteratorOptions} and
* {@code validateOptions(Map<String,String> options)} which is intended to throw an exception or return false if the options are not acceptable.
- *
+ *
*/
public interface OptionDescriber {
public class IteratorOptions {
@@ -36,10 +36,10 @@ public interface OptionDescriber {
public ArrayList<String> unnamedOptionDescriptions;
public String name;
public String description;
-
+
/**
* IteratorOptions holds the name, description, and option information for an iterator.
- *
+ *
* @param name
* is the distinguishing name for the iterator or filter
* @param description
@@ -63,63 +63,63 @@ public interface OptionDescriber {
this.unnamedOptionDescriptions = new ArrayList<String>(unnamedOptionDescriptions);
this.description = description;
}
-
+
public Map<String,String> getNamedOptions() {
return namedOptions;
}
-
+
public List<String> getUnnamedOptionDescriptions() {
return unnamedOptionDescriptions;
}
-
+
public String getName() {
return name;
}
-
+
public String getDescription() {
return description;
}
-
+
public void setNamedOptions(Map<String,String> namedOptions) {
this.namedOptions = new LinkedHashMap<String,String>(namedOptions);
}
-
+
public void setUnnamedOptionDescriptions(List<String> unnamedOptionDescriptions) {
this.unnamedOptionDescriptions = new ArrayList<String>(unnamedOptionDescriptions);
}
-
+
public void setName(String name) {
this.name = name;
}
-
+
public void setDescription(String description) {
this.description = description;
}
-
+
public void addNamedOption(String name, String description) {
if (namedOptions == null)
namedOptions = new LinkedHashMap<String,String>();
namedOptions.put(name, description);
}
-
+
public void addUnnamedOption(String description) {
if (unnamedOptionDescriptions == null)
unnamedOptionDescriptions = new ArrayList<String>();
unnamedOptionDescriptions.add(description);
}
}
-
+
/**
* 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.
- *
+ *
* @return an iterator options object
*/
IteratorOptions describeOptions();
-
+
/**
* Check to see if an options map contains all options required by an iterator and that the option values are in the expected formats.
- *
+ *
* @param options
* a map of option names to option values
* @return true if options are valid, false otherwise (IllegalArgumentException preferred)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/OrIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/OrIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/OrIterator.java
index 361c494..98c8cac 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/OrIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/OrIterator.java
@@ -36,31 +36,31 @@ import org.apache.hadoop.io.Text;
*/
public class OrIterator implements SortedKeyValueIterator<Key,Value> {
-
+
private TermSource currentTerm;
private ArrayList<TermSource> sources;
private PriorityQueue<TermSource> sorted = new PriorityQueue<TermSource>(5);
private static final Text nullText = new Text();
private static final Key nullKey = new Key();
-
+
protected static class TermSource implements Comparable<TermSource> {
public SortedKeyValueIterator<Key,Value> iter;
public Text term;
public Collection<ByteSequence> seekColfams;
-
+
public TermSource(TermSource other) {
this.iter = other.iter;
this.term = other.term;
this.seekColfams = other.seekColfams;
}
-
+
public TermSource(SortedKeyValueIterator<Key,Value> iter, Text term) {
this.iter = iter;
this.term = term;
// The desired column families for this source is the term itself
- this.seekColfams = Collections.<ByteSequence>singletonList(new ArrayByteSequence(term.getBytes(), 0, term.getLength()));
+ this.seekColfams = Collections.<ByteSequence> singletonList(new ArrayByteSequence(term.getBytes(), 0, term.getLength()));
}
-
+
public int compareTo(TermSource o) {
// NOTE: If your implementation can have more than one row in a tablet,
// you must compare row key here first, then column qualifier.
@@ -69,40 +69,40 @@ public class OrIterator implements SortedKeyValueIterator<Key,Value> {
return this.iter.getTopKey().compareColumnQualifier(o.iter.getTopKey().getColumnQualifier());
}
}
-
+
public OrIterator() {
this.sources = new ArrayList<TermSource>();
}
-
+
private OrIterator(OrIterator other, IteratorEnvironment env) {
this.sources = new ArrayList<TermSource>();
-
+
for (TermSource TS : other.sources)
this.sources.add(new TermSource(TS.iter.deepCopy(env), TS.term));
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new OrIterator(this, env);
}
-
+
public void addTerm(SortedKeyValueIterator<Key,Value> source, Text term, IteratorEnvironment env) {
this.sources.add(new TermSource(source.deepCopy(env), term));
}
-
+
@Override
final public void next() throws IOException {
-
+
if (currentTerm == null)
return;
-
+
// Advance currentTerm
currentTerm.iter.next();
-
+
// See if currentTerm is still valid, remove if not
if (!(currentTerm.iter.hasTop()) || ((currentTerm.term != null) && (currentTerm.term.compareTo(currentTerm.iter.getTopKey().getColumnFamily()) != 0)))
currentTerm = null;
-
+
// optimization.
// if size == 0, currentTerm is the only item left,
// OR there are no items left.
@@ -115,25 +115,25 @@ public class OrIterator implements SortedKeyValueIterator<Key,Value> {
currentTerm = sorted.poll();
}
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
-
+
// If sources.size is 0, there is nothing to process, so just return.
if (sources.size() == 0) {
currentTerm = null;
return;
}
-
+
// Optimization for when there is only one term.
// Yes, this is lots of duplicate code, but the speed works...
// and we don't have a priority queue of size 0 or 1.
if (sources.size() == 1) {
-
+
if (currentTerm == null)
currentTerm = sources.get(0);
Range newRange = null;
-
+
if (range != null) {
if ((range.getStartKey() == null) || (range.getStartKey().getRow() == null))
newRange = range;
@@ -147,7 +147,7 @@ public class OrIterator implements SortedKeyValueIterator<Key,Value> {
}
}
currentTerm.iter.seek(newRange, currentTerm.seekColfams, true);
-
+
// If there is no top key
// OR we are:
// 1) NOT an iterator
@@ -155,14 +155,14 @@ public class OrIterator implements SortedKeyValueIterator<Key,Value> {
// then ignore it as a valid source
if (!(currentTerm.iter.hasTop()) || ((currentTerm.term != null) && (currentTerm.term.compareTo(currentTerm.iter.getTopKey().getColumnFamily()) != 0)))
currentTerm = null;
-
+
// Otherwise, source is valid.
return;
}
-
+
// Clear the PriorityQueue so that we can re-populate it.
sorted.clear();
-
+
// This check is put in here to guard against the "initial seek"
// crashing us because the topkey term does not match.
// Note: It is safe to do the "sources.size() == 1" above
@@ -170,14 +170,14 @@ public class OrIterator implements SortedKeyValueIterator<Key,Value> {
if (currentTerm == null) {
for (TermSource TS : sources) {
TS.iter.seek(range, TS.seekColfams, true);
-
+
if ((TS.iter.hasTop()) && ((TS.term != null) && (TS.term.compareTo(TS.iter.getTopKey().getColumnFamily()) == 0)))
sorted.add(TS);
}
currentTerm = sorted.poll();
return;
}
-
+
TermSource TS = null;
Iterator<TermSource> iter = sources.iterator();
// For each term, seek forward.
@@ -185,7 +185,7 @@ public class OrIterator implements SortedKeyValueIterator<Key,Value> {
while (iter.hasNext()) {
TS = iter.next();
Range newRange = null;
-
+
if (range != null) {
if ((range.getStartKey() == null) || (range.getStartKey().getRow() == null))
newRange = range;
@@ -198,10 +198,10 @@ public class OrIterator implements SortedKeyValueIterator<Key,Value> {
newRange = new Range((newKey == null) ? nullKey : newKey, true, range.getEndKey(), false);
}
}
-
+
// Seek only to the term for this source as a column family
TS.iter.seek(newRange, TS.seekColfams, true);
-
+
// If there is no top key
// OR we are:
// 1) NOT an iterator
@@ -209,30 +209,30 @@ public class OrIterator implements SortedKeyValueIterator<Key,Value> {
// then ignore it as a valid source
if (!(TS.iter.hasTop()) || ((TS.term != null) && (TS.term.compareTo(TS.iter.getTopKey().getColumnFamily()) != 0)))
iter.remove();
-
+
// Otherwise, source is valid. Add it to the sources.
sorted.add(TS);
}
-
+
// And set currentTerm = the next valid key/term.
currentTerm = sorted.poll();
}
-
+
@Override
final public Key getTopKey() {
return currentTerm.iter.getTopKey();
}
-
+
@Override
final public Value getTopValue() {
return currentTerm.iter.getTopValue();
}
-
+
@Override
final public boolean hasTop() {
return currentTerm != null;
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
throw new UnsupportedOperationException();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/RowDeletingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/RowDeletingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/RowDeletingIterator.java
index a79a6ee..ee6989f 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/RowDeletingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/RowDeletingIterator.java
@@ -18,10 +18,10 @@ package org.apache.accumulo.core.iterators;
/**
* This class remains here for backwards compatibility.
- *
+ *
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.RowDeletingIterator}
*/
@Deprecated
public class RowDeletingIterator extends org.apache.accumulo.core.iterators.user.RowDeletingIterator {
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java
index ba45e27..896eb67 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java
@@ -23,28 +23,28 @@ import org.apache.accumulo.core.data.Value;
public class SortedKeyIterator extends WrappingIterator implements OptionDescriber {
private static final Value NOVALUE = new Value(new byte[0]);
-
+
public SortedKeyIterator() {}
-
+
public SortedKeyIterator(SortedKeyIterator other, IteratorEnvironment env) {
setSource(other.getSource().deepCopy(env));
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new SortedKeyIterator(this, env);
}
-
+
@Override
public Value getTopValue() {
return NOVALUE;
}
-
+
@Override
public IteratorOptions describeOptions() {
return new IteratorOptions("keyset", SortedKeyIterator.class.getSimpleName() + " filters out values, but leaves keys intact", null, null);
}
-
+
@Override
public boolean validateOptions(Map<String,String> options) {
return true;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyValueIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyValueIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyValueIterator.java
index 5b6c4ec..7c65565 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyValueIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyValueIterator.java
@@ -33,7 +33,7 @@ import org.apache.hadoop.io.WritableComparable;
public interface SortedKeyValueIterator<K extends WritableComparable<?>,V extends Writable> {
/**
* Initializes the iterator. Data should not be read from the source in this method.
- *
+ *
* @param source
* <tt>SortedKeyValueIterator</tt> source to read data from.
* @param options
@@ -48,21 +48,21 @@ public interface SortedKeyValueIterator<K extends WritableComparable<?>,V extend
* if not supported.
*/
void init(SortedKeyValueIterator<K,V> source, Map<String,String> options, IteratorEnvironment env) throws IOException;
-
+
/**
* Returns true if the iterator has more elements.
- *
+ *
* @return <tt>true</tt> if the iterator has more elements.
* @exception IllegalStateException
* if called before seek.
*/
boolean hasTop();
-
+
/**
* Advances to the next K,V pair. Note that in minor compaction scope and in non-full major compaction scopes the iterator may see deletion entries. These
* entries should be preserved by all iterators except ones that are strictly scan-time iterators that will never be configured for the minc or majc scopes.
* Deletion entries are only removed during full major compactions.
- *
+ *
* @throws IOException
* if an I/O error occurs.
* @exception IllegalStateException
@@ -71,24 +71,24 @@ public interface SortedKeyValueIterator<K extends WritableComparable<?>,V extend
* if next element doesn't exist.
*/
void next() throws IOException;
-
+
/**
* Seeks to the first key in the Range, restricting the resulting K,V pairs to those with the specified columns. An iterator does not have to stop at the end
* of the range. The whole range is provided so that iterators can make optimizations.
- *
+ *
* Seek may be called multiple times with different parameters after {@link #init} is called.
- *
+ *
* Iterators that examine groups of adjacent key/value pairs (e.g. rows) to determine their top key and value should be sure that they properly handle a seek
* to a key in the middle of such a group (e.g. the middle of a row). Even if the client always seeks to a range containing an entire group (a,c), the tablet
* server could send back a batch of entries corresponding to (a,b], then reseek the iterator to range (b,c) when the scan is continued.
*
- * {@code columnFamilies} is used, at the lowest level, to determine which data blocks inside of an RFile need to be opened for this iterator. This set of data
- * blocks is also the set of locality groups defined for the given table. If no columnFamilies are provided, the data blocks for all locality groups inside of
- * the correct RFile will be opened and seeked in an attempt to find the correct start key, regardless of the startKey in the {@code range}.
+ * {@code columnFamilies} is used, at the lowest level, to determine which data blocks inside of an RFile need to be opened for this iterator. This set of
+ * data blocks is also the set of locality groups defined for the given table. If no columnFamilies are provided, the data blocks for all locality groups
+ * inside of the correct RFile will be opened and seeked in an attempt to find the correct start key, regardless of the startKey in the {@code range}.
*
* In an Accumulo instance in which multiple locality groups exist for a table, it is important to ensure that {@code columnFamilies} is properly set to the
* minimum required column families to ensure that data from separate locality groups is not inadvertently read.
- *
+ *
* @param range
* <tt>Range</tt> of keys to iterate over.
* @param columnFamilies
@@ -101,12 +101,12 @@ public interface SortedKeyValueIterator<K extends WritableComparable<?>,V extend
* if there are problems with the parameters.
*/
void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException;
-
+
/**
* Returns top key. Can be called 0 or more times without affecting behavior of next() or hasTop(). Note that in minor compaction scope and in non-full major
* compaction scopes the iterator may see deletion entries. These entries should be preserved by all iterators except ones that are strictly scan-time
* iterators that will never be configured for the minc or majc scopes. Deletion entries are only removed during full major compactions.
- *
+ *
* @return <tt>K</tt>
* @exception IllegalStateException
* if called before seek.
@@ -114,10 +114,10 @@ public interface SortedKeyValueIterator<K extends WritableComparable<?>,V extend
* if top element doesn't exist.
*/
K getTopKey();
-
+
/**
* Returns top value. Can be called 0 or more times without affecting behavior of next() or hasTop().
- *
+ *
* @return <tt>V</tt>
* @exception IllegalStateException
* if called before seek.
@@ -125,12 +125,12 @@ public interface SortedKeyValueIterator<K extends WritableComparable<?>,V extend
* if top element doesn't exist.
*/
V getTopValue();
-
+
/**
* Creates a deep copy of this iterator as though seek had not yet been called. init should be called on an iterator before deepCopy is called. init should
* not need to be called on the copy that is returned by deepCopy; that is, when necessary init should be called in the deepCopy method on the iterator it
* returns. The behavior is unspecified if init is called after deepCopy either on the original or the copy.
- *
+ *
* @param env
* <tt>IteratorEnvironment</tt> environment in which iterator is being run.
* @return <tt>SortedKeyValueIterator</tt> a copy of this iterator (with the same source and settings).
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/SortedMapIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/SortedMapIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/SortedMapIterator.java
index 2371e4d..cf385a9 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/SortedMapIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/SortedMapIterator.java
@@ -32,67 +32,66 @@ import org.apache.accumulo.core.iterators.system.InterruptibleIterator;
/**
* A simple iterator over a Java SortedMap
- *
- * Note that this class is intended as an in-memory replacement for RFile$Reader, so its behavior reflects
- * the same assumptions; namely, that this iterator is not responsible for respecting the columnFamilies
- * passed into seek(). If you want a Map-backed Iterator that returns only sought CFs, construct a new
+ *
+ * Note that this class is intended as an in-memory replacement for RFile$Reader, so its behavior reflects the same assumptions; namely, that this iterator is
+ * not responsible for respecting the columnFamilies passed into seek(). If you want a Map-backed Iterator that returns only sought CFs, construct a new
* ColumnFamilySkippingIterator(new SortedMapIterator(map)).
- *
+ *
* @see org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator
- *
+ *
*/
public class SortedMapIterator implements InterruptibleIterator {
private Iterator<Entry<Key,Value>> iter;
private Entry<Key,Value> entry;
-
+
private SortedMap<Key,Value> map;
private Range range;
-
+
private AtomicBoolean interruptFlag;
private int interruptCheckCount = 0;
-
+
public SortedMapIterator deepCopy(IteratorEnvironment env) {
return new SortedMapIterator(map, interruptFlag);
}
-
+
private SortedMapIterator(SortedMap<Key,Value> map, AtomicBoolean interruptFlag) {
this.map = map;
iter = null;
this.range = new Range();
entry = null;
-
+
this.interruptFlag = interruptFlag;
}
-
+
public SortedMapIterator(SortedMap<Key,Value> map) {
this(map, null);
}
-
+
@Override
public Key getTopKey() {
return entry.getKey();
}
-
+
@Override
public Value getTopValue() {
return entry.getValue();
}
-
+
@Override
public boolean hasTop() {
return entry != null;
}
-
+
@Override
public void next() throws IOException {
-
+
if (entry == null)
throw new IllegalStateException();
-
+
if (interruptFlag != null && interruptCheckCount++ % 100 == 0 && interruptFlag.get())
throw new IterationInterruptedException();
-
+
if (iter.hasNext()) {
entry = iter.next();
if (range.afterEndKey((Key) entry.getKey())) {
@@ -100,22 +99,22 @@ public class SortedMapIterator implements InterruptibleIterator {
}
} else
entry = null;
-
+
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
-
+
if (interruptFlag != null && interruptFlag.get())
throw new IterationInterruptedException();
-
+
this.range = range;
-
+
Key key = range.getStartKey();
if (key == null) {
key = new Key();
}
-
+
iter = map.tailMap(key).entrySet().iterator();
if (iter.hasNext()) {
entry = iter.next();
@@ -124,16 +123,16 @@ public class SortedMapIterator implements InterruptibleIterator {
}
} else
entry = null;
-
+
while (hasTop() && range.beforeStartKey(getTopKey())) {
next();
}
}
-
+
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
throw new UnsupportedOperationException();
}
-
+
@Override
public void setInterruptFlag(AtomicBoolean flag) {
this.interruptFlag = flag;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
index 6577f51..63fff81 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
@@ -28,19 +28,19 @@ import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
/**
* A Combiner that decodes each Value to type V before reducing, then encodes the result of typedReduce back to Value.
- *
+ *
* Subclasses must implement a typedReduce method: public V typedReduce(Key key, Iterator<V> iter);
- *
+ *
* This typedReduce method will be passed the most recent Key and an iterator over the Values (translated to Vs) for all non-deleted versions of that Key.
- *
+ *
* Subclasses may implement a switch on the "type" variable to choose an Encoder in their init method.
*/
public abstract class TypedValueCombiner<V> extends Combiner {
private Encoder<V> encoder = null;
private boolean lossy = false;
-
+
protected static final String LOSSY = "lossy";
-
+
/**
* A Java Iterator that translates an Iterator<Value> to an Iterator<V> using the decode method of an Encoder.
*/
@@ -48,16 +48,16 @@ public abstract class TypedValueCombiner<V> extends Combiner {
private Iterator<Value> source;
private Encoder<V> encoder;
private boolean lossy;
-
+
/**
* Constructs an Iterator<V> from an Iterator<Value>
- *
+ *
* @param iter
* The source iterator
- *
+ *
* @param encoder
* The Encoder whose decode method is used to translate from Value to V
- *
+ *
* @param lossy
* Determines whether to error on failure to decode or ignore and move on
*/
@@ -66,15 +66,15 @@ public abstract class TypedValueCombiner<V> extends Combiner {
this.encoder = encoder;
this.lossy = lossy;
}
-
+
V next = null;
boolean hasNext = false;
-
+
@Override
public boolean hasNext() {
if (hasNext)
return true;
-
+
while (true) {
if (!source.hasNext())
return false;
@@ -87,7 +87,7 @@ public abstract class TypedValueCombiner<V> extends Combiner {
}
}
}
-
+
@Override
public V next() {
if (!hasNext && !hasNext())
@@ -97,32 +97,32 @@ public abstract class TypedValueCombiner<V> extends Combiner {
hasNext = false;
return toRet;
}
-
+
@Override
public void remove() {
source.remove();
}
}
-
+
/**
* An interface for translating from byte[] to V and back.
*/
public interface Encoder<V> {
byte[] encode(V v);
-
+
V decode(byte[] b) throws ValueFormatException;
}
-
+
/**
* Sets the Encoder<V> used to translate Values to V and back.
*/
protected void setEncoder(Encoder<V> encoder) {
this.encoder = encoder;
}
-
+
/**
* Instantiates and sets the Encoder<V> used to translate Values to V and back.
- *
+ *
* @throws IllegalArgumentException
* if ClassNotFoundException, InstantiationException, or IllegalAccessException occurs
*/
@@ -139,10 +139,10 @@ public abstract class TypedValueCombiner<V> extends Combiner {
throw new IllegalArgumentException(e);
}
}
-
+
/**
* Tests whether v remains the same when encoded and decoded with the current encoder.
- *
+ *
* @throws IllegalStateException
* if an encoder has not been set.
* @throws IllegalArgumentException
@@ -153,10 +153,10 @@ public abstract class TypedValueCombiner<V> extends Combiner {
throw new IllegalStateException("encoder has not been initialized");
testEncoder(encoder, v);
}
-
+
/**
* Tests whether v remains the same when encoded and decoded with the given encoder.
- *
+ *
* @throws IllegalArgumentException
* if the test fails.
*/
@@ -168,7 +168,7 @@ public abstract class TypedValueCombiner<V> extends Combiner {
throw new IllegalArgumentException(encoder.getClass().getName() + " doesn't encode " + v.getClass().getName());
}
}
-
+
@SuppressWarnings("unchecked")
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
@@ -176,18 +176,18 @@ public abstract class TypedValueCombiner<V> extends Combiner {
newInstance.setEncoder(encoder);
return newInstance;
}
-
+
@Override
public Value reduce(Key key, Iterator<Value> iter) {
return new Value(encoder.encode(typedReduce(key, new VIterator<V>(iter, encoder, lossy))));
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
setLossyness(options);
}
-
+
private void setLossyness(Map<String,String> options) {
String loss = options.get(LOSSY);
if (loss == null)
@@ -195,14 +195,14 @@ public abstract class TypedValueCombiner<V> extends Combiner {
else
lossy = Boolean.parseBoolean(loss);
}
-
+
@Override
public IteratorOptions describeOptions() {
IteratorOptions io = super.describeOptions();
io.addNamedOption(LOSSY, "if true, failed decodes are ignored. Otherwise combiner will error on failed decodes (default false): <TRUE|FALSE>");
return io;
}
-
+
@Override
public boolean validateOptions(Map<String,String> options) {
if (super.validateOptions(options) == false)
@@ -214,11 +214,11 @@ public abstract class TypedValueCombiner<V> extends Combiner {
}
return true;
}
-
+
/**
* A convenience method to set the "lossy" option on a TypedValueCombiner. If true, the combiner will ignore any values which fail to decode. Otherwise, the
* combiner will throw an error which will interrupt the action (and prevent potential data loss). False is the default behavior.
- *
+ *
* @param is
* iterator settings object to configure
* @param lossy
@@ -227,16 +227,16 @@ public abstract class TypedValueCombiner<V> extends Combiner {
public static void setLossyness(IteratorSetting is, boolean lossy) {
is.addOption(LOSSY, Boolean.toString(lossy));
}
-
+
/**
* Reduces a list of V into a single V.
- *
+ *
* @param key
* The most recent version of the Key being reduced.
- *
+ *
* @param iter
* An iterator over the V for different versions of the key.
- *
+ *
* @return The combined V.
*/
public abstract V typedReduce(Key key, Iterator<V> iter);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/ValueFormatException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/ValueFormatException.java b/core/src/main/java/org/apache/accumulo/core/iterators/ValueFormatException.java
index 7ede7fe..6e52794 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/ValueFormatException.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/ValueFormatException.java
@@ -20,7 +20,7 @@ package org.apache.accumulo.core.iterators;
* Exception used for TypedValueCombiner and it's Encoders decode() function
*/
public class ValueFormatException extends IllegalArgumentException {
-
+
public ValueFormatException(String string) {
super(string);
}
@@ -30,5 +30,5 @@ public class ValueFormatException extends IllegalArgumentException {
}
private static final long serialVersionUID = 4170291568272971821L;
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/VersioningIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/VersioningIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/VersioningIterator.java
index cc37067..d849275 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/VersioningIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/VersioningIterator.java
@@ -21,13 +21,13 @@ import org.apache.accumulo.core.data.Value;
/**
* This class remains here for backwards compatibility.
- *
+ *
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.VersioningIterator}
*/
@Deprecated
public class VersioningIterator extends org.apache.accumulo.core.iterators.user.VersioningIterator {
public VersioningIterator() {}
-
+
public VersioningIterator(SortedKeyValueIterator<Key,Value> iterator, int maxVersions) {
super();
this.setSource(iterator);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/WholeRowIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/WholeRowIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/WholeRowIterator.java
index 6bc0bde..7432a88 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/WholeRowIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/WholeRowIterator.java
@@ -18,10 +18,10 @@ package org.apache.accumulo.core.iterators;
/**
* This class remains here for backwards compatibility.
- *
+ *
* @deprecated since 1.4, replaced by {@link org.apache.accumulo.core.iterators.user.WholeRowIterator}
*/
@Deprecated
public class WholeRowIterator extends org.apache.accumulo.core.iterators.user.WholeRowIterator {
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/WrappingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/WrappingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/WrappingIterator.java
index 060fa76..7723ef1 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/WrappingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/WrappingIterator.java
@@ -28,32 +28,32 @@ import org.apache.accumulo.core.data.Value;
/**
* A convenience class for implementing iterators that select, but do not modify, entries read from a source iterator. Default implementations exist for all
* methods, but {@link #deepCopy} will throw an <code>UnsupportedOperationException</code>.
- *
+ *
* This iterator has some checks in place to enforce the iterator contract. Specifically, it verifies that it has a source iterator and that {@link #seek} has
* been called before any data is read. If either of these conditions does not hold true, an <code>IllegalStateException</code> will be thrown. In particular,
* this means that <code>getSource().seek</code> and <code>super.seek</code> no longer perform identical actions. Implementors should take note of this and if
* <code>seek</code> is overridden, ensure that <code>super.seek</code> is called before data is read.
*/
public abstract class WrappingIterator implements SortedKeyValueIterator<Key,Value> {
-
+
private SortedKeyValueIterator<Key,Value> source = null;
boolean seenSeek = false;
-
+
protected void setSource(SortedKeyValueIterator<Key,Value> source) {
this.source = source;
}
-
+
protected SortedKeyValueIterator<Key,Value> getSource() {
if (source == null)
throw new IllegalStateException("getting null source");
return source;
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
throw new UnsupportedOperationException();
}
-
+
@Override
public Key getTopKey() {
if (source == null)
@@ -62,7 +62,7 @@ public abstract class WrappingIterator implements SortedKeyValueIterator<Key,Val
throw new IllegalStateException("never been seeked");
return getSource().getTopKey();
}
-
+
@Override
public Value getTopValue() {
if (source == null)
@@ -71,7 +71,7 @@ public abstract class WrappingIterator implements SortedKeyValueIterator<Key,Val
throw new IllegalStateException("never been seeked");
return getSource().getTopValue();
}
-
+
@Override
public boolean hasTop() {
if (source == null)
@@ -80,13 +80,13 @@ public abstract class WrappingIterator implements SortedKeyValueIterator<Key,Val
throw new IllegalStateException("never been seeked");
return getSource().hasTop();
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
this.setSource(source);
-
+
}
-
+
@Override
public void next() throws IOException {
if (source == null)
@@ -95,11 +95,11 @@ public abstract class WrappingIterator implements SortedKeyValueIterator<Key,Val
throw new IllegalStateException("never been seeked");
getSource().next();
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
getSource().seek(range, columnFamilies, inclusive);
seenSeek = true;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/Aggregator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/Aggregator.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/Aggregator.java
index 2264bd9..f9183dc 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/Aggregator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/Aggregator.java
@@ -24,8 +24,8 @@ import org.apache.accumulo.core.data.Value;
@Deprecated
public interface Aggregator {
void reset();
-
+
void collect(Value value);
-
+
Value aggregate();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java
index bee96ac..de86ec4 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/LongSummation.java
@@ -29,11 +29,11 @@ import org.apache.log4j.Logger;
public class LongSummation implements Aggregator {
private static final Logger log = Logger.getLogger(LongSummation.class);
long sum = 0;
-
+
public Value aggregate() {
return new Value(longToBytes(sum));
}
-
+
public void collect(Value value) {
try {
sum += bytesToLong(value.get());
@@ -41,22 +41,22 @@ public class LongSummation implements Aggregator {
log.error(LongSummation.class.getSimpleName() + " trying to convert bytes to long, but byte array isn't length 8");
}
}
-
+
public void reset() {
sum = 0;
}
-
+
public static long bytesToLong(byte[] b) throws IOException {
return bytesToLong(b, 0);
}
-
+
public static long bytesToLong(byte[] b, int offset) throws IOException {
if (b.length < offset + 8)
throw new IOException("trying to convert to long, but byte array isn't long enough, wanted " + (offset + 8) + " found " + b.length);
return (((long) b[offset + 0] << 56) + ((long) (b[offset + 1] & 255) << 48) + ((long) (b[offset + 2] & 255) << 40) + ((long) (b[offset + 3] & 255) << 32)
+ ((long) (b[offset + 4] & 255) << 24) + ((b[offset + 5] & 255) << 16) + ((b[offset + 6] & 255) << 8) + ((b[offset + 7] & 255) << 0));
}
-
+
public static byte[] longToBytes(long l) {
byte[] b = new byte[8];
b[0] = (byte) (l >>> 56);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java
index 1d1e4cb..ca00337 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumArraySummation.java
@@ -32,7 +32,7 @@ import org.apache.hadoop.io.WritableUtils;
@Deprecated
public class NumArraySummation implements Aggregator {
long[] sum = new long[0];
-
+
public Value aggregate() {
try {
return new Value(NumArraySummation.longArrayToBytes(sum));
@@ -40,7 +40,7 @@ public class NumArraySummation implements Aggregator {
throw new RuntimeException(e);
}
}
-
+
public void collect(Value value) {
long[] la;
try {
@@ -48,7 +48,7 @@ public class NumArraySummation implements Aggregator {
} catch (IOException e) {
throw new RuntimeException(e);
}
-
+
if (la.length > sum.length) {
for (int i = 0; i < sum.length; i++) {
la[i] = NumSummation.safeAdd(la[i], sum[i]);
@@ -60,34 +60,34 @@ public class NumArraySummation implements Aggregator {
}
}
}
-
+
public static byte[] longArrayToBytes(long[] la) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
-
+
WritableUtils.writeVInt(dos, la.length);
for (int i = 0; i < la.length; i++) {
WritableUtils.writeVLong(dos, la[i]);
}
-
+
return baos.toByteArray();
}
-
+
public static long[] bytesToLongArray(byte[] b) throws IOException {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(b));
int len = WritableUtils.readVInt(dis);
-
+
long[] la = new long[len];
-
+
for (int i = 0; i < len; i++) {
la[i] = WritableUtils.readVLong(dis);
}
-
+
return la;
}
-
+
public void reset() {
sum = new long[0];
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java
index 7994195..9c28776 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/NumSummation.java
@@ -32,7 +32,7 @@ import org.apache.hadoop.io.WritableUtils;
@Deprecated
public class NumSummation implements Aggregator {
long sum = 0l;
-
+
public Value aggregate() {
try {
return new Value(NumSummation.longToBytes(sum));
@@ -40,7 +40,7 @@ public class NumSummation implements Aggregator {
throw new RuntimeException(e);
}
}
-
+
public void collect(Value value) {
long l;
try {
@@ -48,24 +48,24 @@ public class NumSummation implements Aggregator {
} catch (IOException e) {
throw new RuntimeException(e);
}
-
+
sum = NumSummation.safeAdd(sum, l);
}
-
+
public static byte[] longToBytes(long l) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
-
+
WritableUtils.writeVLong(dos, l);
-
+
return baos.toByteArray();
}
-
+
public static long bytesToLong(byte[] b) throws IOException {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(b));
return WritableUtils.readVLong(dis);
}
-
+
public static long safeAdd(long a, long b) {
long aSign = Long.signum(a);
long bSign = Long.signum(b);
@@ -80,9 +80,9 @@ public class NumSummation implements Aggregator {
}
return a + b;
}
-
+
public void reset() {
sum = 0l;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMax.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMax.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMax.java
index 36c777a..e086b22 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMax.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMax.java
@@ -24,22 +24,22 @@ import org.apache.accumulo.core.data.Value;
*/
@Deprecated
public class StringMax implements Aggregator {
-
+
long max = Long.MIN_VALUE;
-
+
public Value aggregate() {
return new Value(Long.toString(max).getBytes());
}
-
+
public void collect(Value value) {
long l = Long.parseLong(new String(value.get()));
if (l > max) {
max = l;
}
}
-
+
public void reset() {
max = Long.MIN_VALUE;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMin.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMin.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMin.java
index 1e6b7c7..48855b3 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMin.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringMin.java
@@ -24,22 +24,22 @@ import org.apache.accumulo.core.data.Value;
*/
@Deprecated
public class StringMin implements Aggregator {
-
+
long min = Long.MAX_VALUE;
-
+
public Value aggregate() {
return new Value(Long.toString(min).getBytes());
}
-
+
public void collect(Value value) {
long l = Long.parseLong(new String(value.get()));
if (l < min) {
min = l;
}
}
-
+
public void reset() {
min = Long.MAX_VALUE;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringSummation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringSummation.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringSummation.java
index 00bfd10..63a8297 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringSummation.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/StringSummation.java
@@ -24,19 +24,19 @@ import org.apache.accumulo.core.data.Value;
*/
@Deprecated
public class StringSummation implements Aggregator {
-
+
long sum = 0;
-
+
public Value aggregate() {
return new Value(Long.toString(sum).getBytes());
}
-
+
public void collect(Value value) {
sum += Long.parseLong(new String(value.get()));
}
-
+
public void reset() {
sum = 0;
-
+
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorConfiguration.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorConfiguration.java
index a74dd6d..41c0374 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorConfiguration.java
@@ -24,11 +24,11 @@ import org.apache.hadoop.io.Text;
*/
@Deprecated
public class AggregatorConfiguration extends PerColumnIteratorConfig {
-
+
public AggregatorConfiguration(Text columnFamily, String aggClassName) {
super(columnFamily, aggClassName);
}
-
+
public AggregatorConfiguration(Text columnFamily, Text columnQualifier, String aggClassName) {
super(columnFamily, columnQualifier, aggClassName);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorSet.java b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorSet.java
index ad33fa2..c874cc8 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorSet.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/aggregation/conf/AggregatorSet.java
@@ -31,11 +31,11 @@ public class AggregatorSet extends ColumnToClassMapping<Aggregator> {
public AggregatorSet(Map<String,String> opts) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
super(opts, Aggregator.class);
}
-
+
public AggregatorSet() {
super();
}
-
+
public Aggregator getAggregator(Key k) {
return getObject(k);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java b/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java
index 01ed523..c1edf5d 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java
@@ -31,21 +31,21 @@ import org.apache.hadoop.io.Text;
public class ColumnSet {
private Set<ColFamHashKey> objectsCF;
private Set<ColHashKey> objectsCol;
-
+
private ColHashKey lookupCol = new ColHashKey();
private ColFamHashKey lookupCF = new ColFamHashKey();
-
+
public ColumnSet() {
objectsCF = new HashSet<ColFamHashKey>();
objectsCol = new HashSet<ColHashKey>();
}
-
+
public ColumnSet(Collection<String> objectStrings) {
this();
-
+
for (String column : objectStrings) {
Pair<Text,Text> pcic = ColumnSet.decodeColumns(column);
-
+
if (pcic.getSecond() == null) {
add(pcic.getFirst());
} else {
@@ -53,15 +53,15 @@ public class ColumnSet {
}
}
}
-
+
protected void add(Text colf) {
objectsCF.add(new ColFamHashKey(new Text(colf)));
}
-
+
protected void add(Text colf, Text colq) {
objectsCol.add(new ColHashKey(colf, colq));
}
-
+
public boolean contains(Key key) {
// lookup column family and column qualifier
if (objectsCol.size() > 0) {
@@ -69,36 +69,36 @@ public class ColumnSet {
if (objectsCol.contains(lookupCol))
return true;
}
-
+
// lookup just column family
if (objectsCF.size() > 0) {
lookupCF.set(key);
return objectsCF.contains(lookupCF);
}
-
+
return false;
}
-
+
public boolean isEmpty() {
return objectsCol.size() == 0 && objectsCF.size() == 0;
}
public static String encodeColumns(Text columnFamily, Text columnQualifier) {
StringBuilder sb = new StringBuilder();
-
+
encode(sb, columnFamily);
if (columnQualifier != null) {
sb.append(':');
encode(sb, columnQualifier);
}
-
+
return sb.toString();
}
-
+
static void encode(StringBuilder sb, Text t) {
for (int i = 0; i < t.getLength(); i++) {
int b = (0xff & t.getBytes()[i]);
-
+
// very inefficient code
if ((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '0' && b <= '9') || b == '_' || b == '-') {
sb.append((char) b);
@@ -115,16 +115,16 @@ public class ColumnSet {
if (!validChar)
return false;
}
-
+
return true;
}
public static Pair<Text,Text> decodeColumns(String columns) {
if (!isValidEncoding(columns))
throw new IllegalArgumentException("Invalid encoding " + columns);
-
+
String[] cols = columns.split(":");
-
+
if (cols.length == 1) {
return new Pair<Text,Text>(decode(cols[0]), null);
} else if (cols.length == 2) {
@@ -136,9 +136,9 @@ public class ColumnSet {
static Text decode(String s) {
Text t = new Text();
-
+
byte[] sb = s.getBytes(UTF_8);
-
+
// very inefficient code
for (int i = 0; i < sb.length; i++) {
if (sb[i] != '%') {
@@ -150,7 +150,7 @@ public class ColumnSet {
t.append(new byte[] {(byte) b}, 0, 1);
}
}
-
+
return t;
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnToClassMapping.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnToClassMapping.java b/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnToClassMapping.java
index 59063d9..84a6996 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnToClassMapping.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnToClassMapping.java
@@ -29,39 +29,39 @@ import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
import org.apache.hadoop.io.Text;
public class ColumnToClassMapping<K> {
-
+
private HashMap<ColFamHashKey,K> objectsCF;
private HashMap<ColHashKey,K> objectsCol;
-
+
private ColHashKey lookupCol = new ColHashKey();
private ColFamHashKey lookupCF = new ColFamHashKey();
-
+
public ColumnToClassMapping() {
objectsCF = new HashMap<ColFamHashKey,K>();
objectsCol = new HashMap<ColHashKey,K>();
}
-
+
public ColumnToClassMapping(Map<String,String> objectStrings, Class<? extends K> c) throws InstantiationException, IllegalAccessException,
ClassNotFoundException, IOException {
- this(objectStrings, c, null);
+ this(objectStrings, c, null);
}
public ColumnToClassMapping(Map<String,String> objectStrings, Class<? extends K> c, String context) throws InstantiationException, IllegalAccessException,
- ClassNotFoundException, IOException {
- this();
-
+ ClassNotFoundException, IOException {
+ this();
+
for (Entry<String,String> entry : objectStrings.entrySet()) {
String column = entry.getKey();
String className = entry.getValue();
-
+
Pair<Text,Text> pcic = ColumnSet.decodeColumns(column);
-
+
Class<?> clazz;
if (context != null && !context.equals(""))
clazz = AccumuloVFSClassLoader.getContextManager().getClassLoader(context).loadClass(className);
else
clazz = AccumuloVFSClassLoader.loadClass(className, c);
-
+
@SuppressWarnings("unchecked")
K inst = (K) clazz.newInstance();
if (pcic.getSecond() == null) {
@@ -71,18 +71,18 @@ public class ColumnToClassMapping<K> {
}
}
}
-
+
protected void addObject(Text colf, K obj) {
objectsCF.put(new ColFamHashKey(new Text(colf)), obj);
}
-
+
protected void addObject(Text colf, Text colq, K obj) {
objectsCol.put(new ColHashKey(colf, colq), obj);
}
-
+
public K getObject(Key key) {
K obj = null;
-
+
// lookup column family and column qualifier
if (objectsCol.size() > 0) {
lookupCol.set(key);
@@ -91,16 +91,16 @@ public class ColumnToClassMapping<K> {
return obj;
}
}
-
+
// lookup just column family
if (objectsCF.size() > 0) {
lookupCF.set(key);
obj = objectsCF.get(lookupCF);
}
-
+
return obj;
}
-
+
public boolean isEmpty() {
return objectsCol.size() == 0 && objectsCF.size() == 0;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnUtil.java b/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnUtil.java
index 984f069..a6a3e65 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnUtil.java
@@ -24,89 +24,89 @@ public class ColumnUtil {
private static int hash(byte[] bytes, int offset, int len) {
int hash = 1;
int end = offset + len;
-
+
for (int i = offset; i < end; i++)
hash = (31 * hash) + bytes[i];
-
+
return hash;
}
-
+
private static int hash(ByteSequence bs) {
return hash(bs.getBackingArray(), bs.offset(), bs.length());
}
-
+
public static class ColFamHashKey {
Text columnFamily;
-
+
Key key;
-
+
private int hashCode;
-
+
ColFamHashKey() {
columnFamily = null;
}
-
+
ColFamHashKey(Text cf) {
columnFamily = cf;
hashCode = hash(columnFamily.getBytes(), 0, columnFamily.getLength());
}
-
+
void set(Key key) {
this.key = key;
hashCode = hash(key.getColumnFamilyData());
}
-
+
public int hashCode() {
return hashCode;
}
-
+
public boolean equals(Object o) {
if (o instanceof ColFamHashKey)
return equals((ColFamHashKey) o);
return false;
}
-
+
public boolean equals(ColFamHashKey ohk) {
if (columnFamily == null)
return key.compareColumnFamily(ohk.columnFamily) == 0;
return ohk.key.compareColumnFamily(columnFamily) == 0;
}
}
-
+
public static class ColHashKey {
Text columnFamily;
Text columnQualifier;
-
+
Key key;
-
+
private int hashValue;
-
+
ColHashKey() {
columnFamily = null;
columnQualifier = null;
}
-
+
ColHashKey(Text cf, Text cq) {
columnFamily = cf;
columnQualifier = cq;
hashValue = hash(columnFamily.getBytes(), 0, columnFamily.getLength()) + hash(columnQualifier.getBytes(), 0, columnQualifier.getLength());
}
-
+
void set(Key key) {
this.key = key;
hashValue = hash(key.getColumnFamilyData()) + hash(key.getColumnQualifierData());
}
-
+
public int hashCode() {
return hashValue;
}
-
+
public boolean equals(Object o) {
if (o instanceof ColHashKey)
return equals((ColHashKey) o);
return false;
}
-
+
public boolean equals(ColHashKey ohk) {
if (columnFamily == null)
return key.compareColumnFamily(ohk.columnFamily) == 0 && key.compareColumnQualifier(ohk.columnQualifier) == 0;