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:39 UTC
[35/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/conf/PerColumnIteratorConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/conf/PerColumnIteratorConfig.java b/core/src/main/java/org/apache/accumulo/core/iterators/conf/PerColumnIteratorConfig.java
index 1d8a1b3..310776aa 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/conf/PerColumnIteratorConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/conf/PerColumnIteratorConfig.java
@@ -20,56 +20,56 @@ import org.apache.hadoop.io.Text;
/**
* @deprecated since 1.4
- *
+ *
* @see org.apache.accumulo.core.client.IteratorSetting.Column
* @see org.apache.accumulo.core.iterators.Combiner#setColumns(org.apache.accumulo.core.client.IteratorSetting, java.util.List)
*/
@Deprecated
public class PerColumnIteratorConfig {
-
+
private String parameter;
private Text colq;
private Text colf;
-
+
public PerColumnIteratorConfig(Text columnFamily, String parameter) {
this.colf = columnFamily;
this.colq = null;
this.parameter = parameter;
}
-
+
public PerColumnIteratorConfig(Text columnFamily, Text columnQualifier, String parameter) {
this.colf = columnFamily;
this.colq = columnQualifier;
this.parameter = parameter;
}
-
+
public Text getColumnFamily() {
return colf;
}
-
+
public Text getColumnQualifier() {
return colq;
}
-
+
public String encodeColumns() {
return encodeColumns(this);
}
-
+
public String getClassName() {
return parameter;
}
-
+
private static String encodeColumns(PerColumnIteratorConfig pcic) {
return ColumnSet.encodeColumns(pcic.colf, pcic.colq);
}
-
+
public static String encodeColumns(Text columnFamily, Text columnQualifier) {
return ColumnSet.encodeColumns(columnFamily, columnQualifier);
}
public static PerColumnIteratorConfig decodeColumns(String columns, String className) {
String[] cols = columns.split(":");
-
+
if (cols.length == 1) {
return new PerColumnIteratorConfig(ColumnSet.decode(cols[0]), className);
} else if (cols.length == 2) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnFamilySkippingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnFamilySkippingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnFamilySkippingIterator.java
index 7df57c5..350c4cd 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnFamilySkippingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnFamilySkippingIterator.java
@@ -33,27 +33,27 @@ import org.apache.accumulo.core.iterators.SkippingIterator;
import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
public class ColumnFamilySkippingIterator extends SkippingIterator implements InterruptibleIterator {
-
+
protected Set<ByteSequence> colFamSet = null;
protected TreeSet<ByteSequence> sortedColFams = null;
-
+
protected boolean inclusive = false;
protected Range range;
-
+
public ColumnFamilySkippingIterator(SortedKeyValueIterator<Key,Value> source) {
this.setSource(source);
}
-
+
protected ColumnFamilySkippingIterator(SortedKeyValueIterator<Key,Value> source, Set<ByteSequence> colFamSet, boolean inclusive) {
this(source);
this.colFamSet = colFamSet;
this.inclusive = inclusive;
}
-
+
@Override
protected void consume() throws IOException {
int count = 0;
-
+
if (inclusive)
while (getSource().hasTop() && !colFamSet.contains(getSource().getTopKey().getColumnFamilyData())) {
if (count < 10) {
@@ -70,7 +70,7 @@ public class ColumnFamilySkippingIterator extends SkippingIterator implements In
// seek to the next column family in the sorted list of column families
reseek(new Key(getSource().getTopKey().getRowData().toArray(), higherCF.toArray(), new byte[0], new byte[0], Long.MAX_VALUE));
}
-
+
count = 0;
}
}
@@ -86,7 +86,7 @@ public class ColumnFamilySkippingIterator extends SkippingIterator implements In
}
}
}
-
+
private void reseek(Key key) throws IOException {
if (range.afterEndKey(key)) {
range = new Range(range.getEndKey(), true, range.getEndKey(), range.isEndKeyInclusive());
@@ -96,36 +96,36 @@ public class ColumnFamilySkippingIterator extends SkippingIterator implements In
getSource().seek(range, colFamSet, inclusive);
}
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new ColumnFamilySkippingIterator(getSource().deepCopy(env), colFamSet, inclusive);
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
-
+
if (columnFamilies instanceof Set<?>) {
colFamSet = (Set<ByteSequence>) columnFamilies;
} else {
colFamSet = new HashSet<ByteSequence>();
colFamSet.addAll(columnFamilies);
}
-
+
if (inclusive) {
sortedColFams = new TreeSet<ByteSequence>(colFamSet);
} else {
sortedColFams = null;
}
-
+
this.range = range;
this.inclusive = inclusive;
super.seek(range, colFamSet, inclusive);
}
-
+
@Override
public void setInterruptFlag(AtomicBoolean flag) {
((InterruptibleIterator) getSource()).setInterruptFlag(flag);
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnQualifierFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnQualifierFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnQualifierFilter.java
index d5ca3b4..6e0f6e1 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnQualifierFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/ColumnQualifierFilter.java
@@ -34,14 +34,14 @@ public class ColumnQualifierFilter extends Filter {
private boolean scanColumns;
private HashSet<ByteSequence> columnFamilies;
private HashMap<ByteSequence,HashSet<ByteSequence>> columnsQualifiers;
-
+
public ColumnQualifierFilter() {}
-
+
public ColumnQualifierFilter(SortedKeyValueIterator<Key,Value> iterator, Set<Column> columns) {
setSource(iterator);
init(columns);
}
-
+
public ColumnQualifierFilter(SortedKeyValueIterator<Key,Value> iterator, HashSet<ByteSequence> columnFamilies,
HashMap<ByteSequence,HashSet<ByteSequence>> columnsQualifiers, boolean scanColumns) {
setSource(iterator);
@@ -49,25 +49,25 @@ public class ColumnQualifierFilter extends Filter {
this.columnsQualifiers = columnsQualifiers;
this.scanColumns = scanColumns;
}
-
+
public boolean accept(Key key, Value v) {
if (!scanColumns)
return true;
-
+
if (columnFamilies.contains(key.getColumnFamilyData()))
return true;
-
+
HashSet<ByteSequence> cfset = columnsQualifiers.get(key.getColumnQualifierData());
// ensure the columm qualifier goes with a paired column family,
// it is possible that a column qualifier could occur with a
// column family it was not paired with
return cfset != null && cfset.contains(key.getColumnFamilyData());
}
-
+
public void init(Set<Column> columns) {
this.columnFamilies = new HashSet<ByteSequence>();
this.columnsQualifiers = new HashMap<ByteSequence,HashSet<ByteSequence>>();
-
+
for (Iterator<Column> iter = columns.iterator(); iter.hasNext();) {
Column col = iter.next();
if (col.columnQualifier != null) {
@@ -77,18 +77,18 @@ public class ColumnQualifierFilter extends Filter {
cfset = new HashSet<ByteSequence>();
this.columnsQualifiers.put(cq, cfset);
}
-
+
cfset.add(new ArrayByteSequence(col.columnFamily));
} else {
// this whole column family should pass
columnFamilies.add(new ArrayByteSequence(col.columnFamily));
}
}
-
+
// only take action when column qualifies are present
scanColumns = this.columnsQualifiers.size() > 0;
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new ColumnQualifierFilter(getSource().deepCopy(env), columnFamilies, columnsQualifiers, scanColumns);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/CountingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/CountingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/CountingIterator.java
index 010136a..b75ce67 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/CountingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/CountingIterator.java
@@ -26,34 +26,34 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
import org.apache.accumulo.core.iterators.WrappingIterator;
public class CountingIterator extends WrappingIterator {
-
+
private long count;
-
+
public CountingIterator deepCopy(IteratorEnvironment env) {
return new CountingIterator(this, env);
}
-
+
private CountingIterator(CountingIterator other, IteratorEnvironment env) {
setSource(other.getSource().deepCopy(env));
count = 0;
}
-
+
public CountingIterator(SortedKeyValueIterator<Key,Value> source) {
this.setSource(source);
count = 0;
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) {
throw new UnsupportedOperationException();
}
-
+
@Override
public void next() throws IOException {
super.next();
count++;
}
-
+
public long getCount() {
return count;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/DeletingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/DeletingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/DeletingIterator.java
index e770351..1e7bd0d 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/DeletingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/DeletingIterator.java
@@ -33,23 +33,23 @@ import org.apache.accumulo.core.iterators.WrappingIterator;
public class DeletingIterator extends WrappingIterator {
private boolean propogateDeletes;
private Key workKey = new Key();
-
+
public DeletingIterator deepCopy(IteratorEnvironment env) {
return new DeletingIterator(this, env);
}
-
+
public DeletingIterator(DeletingIterator other, IteratorEnvironment env) {
setSource(other.getSource().deepCopy(env));
propogateDeletes = other.propogateDeletes;
}
-
+
public DeletingIterator() {}
-
+
public DeletingIterator(SortedKeyValueIterator<Key,Value> iterator, boolean propogateDeletes) throws IOException {
this.setSource(iterator);
this.propogateDeletes = propogateDeletes;
}
-
+
@Override
public void next() throws IOException {
if (super.getTopKey().isDeleted())
@@ -58,26 +58,26 @@ public class DeletingIterator extends WrappingIterator {
getSource().next();
findTop();
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
// do not want to seek to the middle of a row
Range seekRange = IteratorUtil.maximizeStartKeyTimeStamp(range);
-
+
super.seek(seekRange, columnFamilies, inclusive);
findTop();
-
+
if (range.getStartKey() != null) {
while (getSource().hasTop() && getSource().getTopKey().compareTo(range.getStartKey(), PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME) < 0) {
next();
}
-
+
while (hasTop() && range.beforeStartKey(getTopKey())) {
next();
}
}
}
-
+
private void findTop() throws IOException {
if (!propogateDeletes) {
while (getSource().hasTop() && getSource().getTopKey().isDeleted()) {
@@ -85,18 +85,18 @@ public class DeletingIterator extends WrappingIterator {
}
}
}
-
+
private void skipRowColumn() throws IOException {
workKey.set(getSource().getTopKey());
-
+
Key keyToSkip = workKey;
getSource().next();
-
+
while (getSource().hasTop() && getSource().getTopKey().equals(keyToSkip, PartialKey.ROW_COLFAM_COLQUAL_COLVIS)) {
getSource().next();
}
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) {
throw new UnsupportedOperationException();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/LocalityGroupIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/LocalityGroupIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/LocalityGroupIterator.java
index 71d2d8b..b2fae6d 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/LocalityGroupIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/LocalityGroupIterator.java
@@ -34,7 +34,7 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
import org.apache.commons.lang.mutable.MutableLong;
/**
- *
+ *
*/
public class LocalityGroupIterator extends HeapIterator implements InterruptibleIterator {
@@ -45,12 +45,12 @@ public class LocalityGroupIterator extends HeapIterator implements Interruptible
this(localityGroup.columnFamilies, localityGroup.isDefaultLocalityGroup);
this.iterator = (InterruptibleIterator) localityGroup.iterator.deepCopy(env);
}
-
+
public LocalityGroup(InterruptibleIterator iterator, Map<ByteSequence,MutableLong> columnFamilies, boolean isDefaultLocalityGroup) {
this(columnFamilies, isDefaultLocalityGroup);
this.iterator = iterator;
}
-
+
public LocalityGroup(Map<ByteSequence,MutableLong> columnFamilies, boolean isDefaultLocalityGroup) {
this.isDefaultLocalityGroup = isDefaultLocalityGroup;
this.columnFamilies = columnFamilies;
@@ -64,7 +64,7 @@ public class LocalityGroupIterator extends HeapIterator implements Interruptible
protected Map<ByteSequence,MutableLong> columnFamilies;
private InterruptibleIterator iterator;
}
-
+
private LocalityGroup groups[];
private Set<ByteSequence> nonDefaultColumnFamilies;
private AtomicBoolean interruptFlag;
@@ -79,13 +79,13 @@ public class LocalityGroupIterator extends HeapIterator implements Interruptible
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
throw new UnsupportedOperationException();
}
-
+
public static final int seek(HeapIterator hiter, LocalityGroup[] groups, Set<ByteSequence> nonDefaultColumnFamilies, Range range,
Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
hiter.clear();
-
+
int numLGSeeked = 0;
-
+
Set<ByteSequence> cfSet;
if (columnFamilies.size() > 0)
if (columnFamilies instanceof Set<?>) {
@@ -101,13 +101,13 @@ public class LocalityGroupIterator extends HeapIterator implements Interruptible
// when include is set to true it means this locality groups contains
// wanted column families
boolean include = false;
-
+
if (cfSet.size() == 0) {
include = !inclusive;
} else if (lgr.isDefaultLocalityGroup && lgr.columnFamilies == null) {
// do not know what column families are in the default locality group,
// only know what column families are not in it
-
+
if (inclusive) {
if (!nonDefaultColumnFamilies.containsAll(cfSet)) {
// default LG may contain wanted and unwanted column families
@@ -123,7 +123,7 @@ public class LocalityGroupIterator extends HeapIterator implements Interruptible
* Need to consider the following cases for inclusive and exclusive (lgcf:locality group column family set, cf:column family set) lgcf and cf are
* disjoint lgcf and cf are the same cf contains lgcf lgcf contains cf lgccf and cf intersect but neither is a subset of the other
*/
-
+
for (Entry<ByteSequence,MutableLong> entry : lgr.columnFamilies.entrySet())
if (entry.getValue().longValue() > 0)
if (cfSet.contains(entry.getKey())) {
@@ -140,7 +140,7 @@ public class LocalityGroupIterator extends HeapIterator implements Interruptible
numLGSeeked++;
}// every column family is excluded, zero count, or not present
}
-
+
return numLGSeeked;
}
@@ -152,16 +152,16 @@ public class LocalityGroupIterator extends HeapIterator implements Interruptible
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
LocalityGroup[] groupsCopy = new LocalityGroup[groups.length];
-
+
for (int i = 0; i < groups.length; i++) {
groupsCopy[i] = new LocalityGroup(groups[i], env);
if (interruptFlag != null)
groupsCopy[i].getIterator().setInterruptFlag(interruptFlag);
}
-
+
return new LocalityGroupIterator(groupsCopy, nonDefaultColumnFamilies);
}
-
+
@Override
public void setInterruptFlag(AtomicBoolean flag) {
this.interruptFlag = flag;
@@ -169,5 +169,5 @@ public class LocalityGroupIterator extends HeapIterator implements Interruptible
lgr.getIterator().setInterruptFlag(flag);
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/MapFileIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/MapFileIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/MapFileIterator.java
index 37a234c..b9a4e31 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/MapFileIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/MapFileIterator.java
@@ -49,7 +49,7 @@ public class MapFileIterator implements FileSKVIterator {
private int interruptCheckCount = 0;
private FileSystem fs;
private String dirName;
-
+
public MapFileIterator(AccumuloConfiguration acuconf, FileSystem fs, String dir, Configuration conf) throws IOException {
this.reader = MapFileUtil.openMapFile(acuconf, fs, dir, conf);
this.fs = fs;
@@ -60,59 +60,59 @@ public class MapFileIterator implements FileSKVIterator {
public void setInterruptFlag(AtomicBoolean flag) {
this.interruptFlag = flag;
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
throw new UnsupportedOperationException();
}
-
+
@Override
public boolean hasTop() {
return topKey != null;
}
-
+
@Override
public void next() throws IOException {
if (interruptFlag != null && interruptCheckCount++ % 100 == 0 && interruptFlag.get())
throw new IterationInterruptedException();
-
+
reader.next(topKey, topValue);
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
if (columnFamilies.size() != 0 || inclusive) {
throw new IllegalArgumentException("I do not know how to filter column families");
}
-
+
if (range == null)
throw new IllegalArgumentException("Cannot seek to null range");
-
+
if (interruptFlag != null && interruptFlag.get())
throw new IterationInterruptedException();
-
+
Key key = range.getStartKey();
if (key == null) {
key = new Key();
}
-
+
reader.seek(key);
-
+
while (hasTop() && range.beforeStartKey(getTopKey())) {
next();
}
}
-
+
@Override
public Key getTopKey() {
return topKey;
}
-
+
@Override
public Value getTopValue() {
return topValue;
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
try {
@@ -125,17 +125,17 @@ public class MapFileIterator implements FileSKVIterator {
throw new RuntimeException(e);
}
}
-
+
@Override
public Key getFirstKey() throws IOException {
throw new UnsupportedOperationException();
}
-
+
@Override
public Key getLastKey() throws IOException {
throw new UnsupportedOperationException();
}
-
+
@Override
public DataInputStream getMetaStore(String name) throws IOException {
Path path = new Path(this.dirName, name);
@@ -143,12 +143,12 @@ public class MapFileIterator implements FileSKVIterator {
throw new NoSuchMetaStoreException("name = " + name);
return fs.open(path);
}
-
+
@Override
public void closeDeepCopies() throws IOException {
// nothing to do, deep copies are externally managed/closed
}
-
+
@Override
public void close() throws IOException {
reader.close();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/MultiIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/MultiIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/MultiIterator.java
index f406fee..26ad8e9 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/MultiIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/MultiIterator.java
@@ -32,21 +32,21 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
/**
* An iterator capable of iterating over other iterators in sorted order.
- *
- *
- *
+ *
+ *
+ *
*/
public class MultiIterator extends HeapIterator {
-
+
private List<SortedKeyValueIterator<Key,Value>> iters;
private Range fence;
-
+
// deep copy with no seek/scan state
public MultiIterator deepCopy(IteratorEnvironment env) {
return new MultiIterator(this, env);
}
-
+
private MultiIterator(MultiIterator other, IteratorEnvironment env) {
super(other.iters.size());
this.iters = new ArrayList<SortedKeyValueIterator<Key,Value>>();
@@ -55,58 +55,58 @@ public class MultiIterator extends HeapIterator {
iters.add(iter.deepCopy(env));
}
}
-
+
private void init() {
for (SortedKeyValueIterator<Key,Value> skvi : iters)
addSource(skvi);
}
-
+
private MultiIterator(List<SortedKeyValueIterator<Key,Value>> iters, Range seekFence, boolean init) {
super(iters.size());
-
+
if (seekFence != null && init) {
// throw this exception because multi-iterator does not seek on init, therefore the
// fence would not be enforced in anyway, so do not want to give the impression it
// will enforce this
throw new IllegalArgumentException("Initializing not supported when seek fence set");
}
-
+
this.fence = seekFence;
this.iters = iters;
-
+
if (init) {
init();
}
}
-
+
public MultiIterator(List<SortedKeyValueIterator<Key,Value>> iters, Range seekFence) {
this(iters, seekFence, false);
}
-
+
public MultiIterator(List<SortedKeyValueIterator<Key,Value>> iters2, KeyExtent extent) {
this(iters2, new Range(extent.getPrevEndRow(), false, extent.getEndRow(), true), false);
}
-
+
public MultiIterator(List<SortedKeyValueIterator<Key,Value>> readers, boolean init) {
this(readers, (Range) null, init);
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
clear();
-
+
if (fence != null) {
range = fence.clip(range, true);
if (range == null)
return;
}
-
+
for (SortedKeyValueIterator<Key,Value> skvi : iters) {
skvi.seek(range, columnFamilies, inclusive);
addSource(skvi);
}
}
-
+
@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/system/SequenceFileIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/SequenceFileIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/SequenceFileIterator.java
index f593ee2..266b638 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/SequenceFileIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/SequenceFileIterator.java
@@ -33,89 +33,89 @@ import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.SequenceFile.Reader;
public class SequenceFileIterator implements FileSKVIterator {
-
+
private Reader reader;
private Value top_value;
private Key top_key;
private boolean readValue;
-
+
public SequenceFileIterator deepCopy(IteratorEnvironment env) {
throw new UnsupportedOperationException("SequenceFileIterator does not yet support cloning");
}
-
+
@Override
public void closeDeepCopies() throws IOException {
throw new UnsupportedOperationException();
}
-
+
public SequenceFileIterator(SequenceFile.Reader reader, boolean readValue) throws IOException {
this.reader = reader;
this.readValue = readValue;
-
+
top_key = new Key();
-
+
if (readValue)
top_value = new Value();
-
+
next();
}
-
+
public Key getTopKey() {
return top_key;
}
-
+
public Value getTopValue() {
return top_value;
}
-
+
public boolean hasTop() {
return top_key != null;
}
-
+
public void next() throws IOException {
boolean valid;
if (readValue)
valid = reader.next(top_key, top_value);
else
valid = reader.next(top_key);
-
+
if (!valid) {
top_key = null;
top_value = null;
}
-
+
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
throw new UnsupportedOperationException("seek() not supported");
}
-
+
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
throw new UnsupportedOperationException();
-
+
}
-
+
@Override
public void close() throws IOException {
reader.close();
}
-
+
@Override
public Key getFirstKey() throws IOException {
throw new UnsupportedOperationException("getFirstKey() not supported");
}
-
+
@Override
public Key getLastKey() throws IOException {
throw new UnsupportedOperationException("getLastKey() not supported");
}
-
+
@Override
public DataInputStream getMetaStore(String name) throws IOException {
throw new UnsupportedOperationException();
}
-
+
@Override
public void setInterruptFlag(AtomicBoolean flag) {
throw new UnsupportedOperationException();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/StatsIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/StatsIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/StatsIterator.java
index 1f23577..f92d1ec 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/StatsIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/StatsIterator.java
@@ -29,36 +29,36 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
import org.apache.accumulo.core.iterators.WrappingIterator;
/**
- *
+ *
*/
public class StatsIterator extends WrappingIterator {
-
+
private int numRead = 0;
private AtomicLong seekCounter;
private AtomicLong readCounter;
-
+
public StatsIterator(SortedKeyValueIterator<Key,Value> source, AtomicLong seekCounter, AtomicLong readCounter) {
super.setSource(source);
this.seekCounter = seekCounter;
this.readCounter = readCounter;
}
-
+
@Override
public void next() throws IOException {
super.next();
numRead++;
-
+
if (numRead % 23 == 0) {
readCounter.addAndGet(numRead);
numRead = 0;
}
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new StatsIterator(getSource().deepCopy(env), seekCounter, readCounter);
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
super.seek(range, columnFamilies, inclusive);
@@ -66,7 +66,7 @@ public class StatsIterator extends WrappingIterator {
readCounter.addAndGet(numRead);
numRead = 0;
}
-
+
public void report() {
readCounter.addAndGet(numRead);
numRead = 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/TimeSettingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/TimeSettingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/TimeSettingIterator.java
index 4eef14d..3e1b7a9 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/TimeSettingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/TimeSettingIterator.java
@@ -30,48 +30,48 @@ import org.apache.accumulo.core.iterators.IteratorUtil;
import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
public class TimeSettingIterator implements InterruptibleIterator {
-
+
private SortedKeyValueIterator<Key,Value> source;
private long time;
private Range range;
-
+
public TimeSettingIterator(SortedKeyValueIterator<Key,Value> source, long time) {
this.source = source;
this.time = time;
}
-
+
@Override
public Key getTopKey() {
Key key = new Key(source.getTopKey());
key.setTimestamp(time);
return key;
}
-
+
@Override
public void setInterruptFlag(AtomicBoolean flag) {
((InterruptibleIterator) source).setInterruptFlag(flag);
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new TimeSettingIterator(source.deepCopy(env), time);
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
-
+
}
-
+
@Override
public boolean hasTop() {
return source.hasTop() && !range.afterEndKey(getTopKey());
}
-
+
@Override
public void next() throws IOException {
source.next();
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
Range seekRange = IteratorUtil.maximizeStartKeyTimeStamp(range);
@@ -81,12 +81,12 @@ public class TimeSettingIterator implements InterruptibleIterator {
while (hasTop() && range.beforeStartKey(getTopKey())) {
next();
}
-
+
}
-
+
@Override
public Value getTopValue() {
return source.getTopValue();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java
index 15c33fa..4bbd819 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java
@@ -37,11 +37,11 @@ public class VisibilityFilter extends Filter {
protected LRUMap cache;
protected Text tmpVis;
protected Authorizations authorizations;
-
+
private static final Logger log = Logger.getLogger(VisibilityFilter.class);
-
+
public VisibilityFilter() {}
-
+
public VisibilityFilter(SortedKeyValueIterator<Key,Value> iterator, Authorizations authorizations, byte[] defaultVisibility) {
setSource(iterator);
this.ve = new VisibilityEvaluator(authorizations);
@@ -50,25 +50,25 @@ public class VisibilityFilter extends Filter {
this.cache = new LRUMap(1000);
this.tmpVis = new Text();
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new VisibilityFilter(getSource().deepCopy(env), authorizations, TextUtil.getBytes(defaultVisibility));
}
-
+
@Override
public boolean accept(Key k, Value v) {
Text testVis = k.getColumnVisibility(tmpVis);
-
+
if (testVis.getLength() == 0 && defaultVisibility.getLength() == 0)
return true;
else if (testVis.getLength() == 0)
testVis = defaultVisibility;
-
+
Boolean b = (Boolean) cache.get(testVis);
if (b != null)
return b;
-
+
try {
Boolean bb = ve.evaluate(new ColumnVisibility(testVis));
cache.put(new Text(testVis), bb);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java
index 6e9a571..705f990 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java
@@ -28,7 +28,7 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
/**
* A filter that ages off key/value pairs based on the Key's timestamp. It removes an entry if its timestamp is less than currentTime - threshold.
- *
+ *
* This filter requires a "ttl" option, in milliseconds, to determine the age off threshold.
*/
public class AgeOffFilter extends Filter {
@@ -36,10 +36,10 @@ public class AgeOffFilter extends Filter {
private static final String CURRENT_TIME = "currentTime";
private long threshold;
private long currentTime;
-
+
/**
* Accepts entries whose timestamps are less than currentTime - threshold.
- *
+ *
* @see org.apache.accumulo.core.iterators.Filter#accept(org.apache.accumulo.core.data.Key, org.apache.accumulo.core.data.Value)
*/
@Override
@@ -48,29 +48,29 @@ public class AgeOffFilter extends Filter {
return false;
return true;
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
if (options == null)
throw new IllegalArgumentException(TTL + " must be set for AgeOffFilter");
-
+
String ttl = options.get(TTL);
if (ttl == null)
throw new IllegalArgumentException(TTL + " must be set for AgeOffFilter");
-
+
super.init(source, options, env);
threshold = -1;
threshold = Long.parseLong(ttl);
-
+
String time = options.get(CURRENT_TIME);
if (time != null)
currentTime = Long.parseLong(time);
else
currentTime = System.currentTimeMillis();
-
+
// add sanity checks for threshold and currentTime?
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
AgeOffFilter copy = (AgeOffFilter) super.deepCopy(env);
@@ -78,7 +78,7 @@ public class AgeOffFilter extends Filter {
copy.threshold = threshold;
return copy;
}
-
+
@Override
public IteratorOptions describeOptions() {
IteratorOptions io = super.describeOptions();
@@ -88,7 +88,7 @@ public class AgeOffFilter extends Filter {
io.setDescription("AgeOffFilter removes entries with timestamps more than <ttl> milliseconds old");
return io;
}
-
+
@Override
public boolean validateOptions(Map<String,String> options) {
if (super.validateOptions(options) == false)
@@ -100,10 +100,10 @@ public class AgeOffFilter extends Filter {
}
return true;
}
-
+
/**
* A convenience method for setting the age off threshold.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param ttl
@@ -112,10 +112,10 @@ public class AgeOffFilter extends Filter {
public static void setTTL(IteratorSetting is, Long ttl) {
is.addOption(TTL, Long.toString(ttl));
}
-
+
/**
* A convenience method for setting the current time (from which to measure the age off threshold).
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param currentTime
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java
index a9cd774..86c9e73 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java
@@ -31,18 +31,17 @@ import org.apache.accumulo.core.iterators.TypedValueCombiner;
import org.apache.accumulo.core.iterators.ValueFormatException;
/**
- * A family of combiners that treat values as BigDecimals, encoding and
- * decoding using the built-in BigDecimal String input/output functions.
+ * A family of combiners that treat values as BigDecimals, encoding and decoding using the built-in BigDecimal String input/output functions.
*/
public abstract class BigDecimalCombiner extends TypedValueCombiner<BigDecimal> {
private final static BigDecimalEncoder BDE = new BigDecimalEncoder();
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
setEncoder(BDE);
}
-
+
@Override
public IteratorOptions describeOptions() {
IteratorOptions io = super.describeOptions();
@@ -50,14 +49,14 @@ public abstract class BigDecimalCombiner extends TypedValueCombiner<BigDecimal>
io.setDescription("bigdecimalcombiner interprets Values as BigDecimals before combining");
return io;
}
-
+
@Override
public boolean validateOptions(Map<String,String> options) {
if (super.validateOptions(options) == false)
return false;
return true;
}
-
+
public static class BigDecimalSummingCombiner extends BigDecimalCombiner {
@Override
public BigDecimal typedReduce(Key key, Iterator<BigDecimal> iter) {
@@ -70,7 +69,7 @@ public abstract class BigDecimalCombiner extends TypedValueCombiner<BigDecimal>
return sum;
}
}
-
+
public static class BigDecimalMaxCombiner extends BigDecimalCombiner {
@Override
public BigDecimal typedReduce(Key key, Iterator<BigDecimal> iter) {
@@ -83,7 +82,7 @@ public abstract class BigDecimalCombiner extends TypedValueCombiner<BigDecimal>
return max;
}
}
-
+
public static class BigDecimalMinCombiner extends BigDecimalCombiner {
@Override
public BigDecimal typedReduce(Key key, Iterator<BigDecimal> iter) {
@@ -96,17 +95,17 @@ public abstract class BigDecimalCombiner extends TypedValueCombiner<BigDecimal>
return min;
}
}
-
+
/**
* Provides the ability to encode scientific notation.
- *
+ *
*/
public static class BigDecimalEncoder implements org.apache.accumulo.core.iterators.TypedValueCombiner.Encoder<BigDecimal> {
@Override
public byte[] encode(BigDecimal v) {
return v.toString().getBytes(UTF_8);
}
-
+
@Override
public BigDecimal decode(byte[] b) throws ValueFormatException {
try {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
index 51e9ed3..c3da5c1 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
@@ -39,14 +39,14 @@ public class ColumnAgeOffFilter extends Filter {
public static class TTLSet extends ColumnToClassMapping<Long> {
public TTLSet(Map<String,String> objectStrings) {
super();
-
+
for (Entry<String,String> entry : objectStrings.entrySet()) {
String column = entry.getKey();
String ttl = entry.getValue();
Long l = Long.parseLong(ttl);
-
+
Pair<Text,Text> colPair = ColumnSet.decodeColumns(column);
-
+
if (colPair.getSecond() == null) {
addObject(colPair.getFirst(), l);
} else {
@@ -55,10 +55,10 @@ public class ColumnAgeOffFilter extends Filter {
}
}
}
-
+
TTLSet ttls;
long currentTime = 0;
-
+
@Override
public boolean accept(Key k, Value v) {
Long threshold = ttls.getObject(k);
@@ -68,14 +68,14 @@ public class ColumnAgeOffFilter extends Filter {
return false;
return true;
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
this.ttls = new TTLSet(options);
currentTime = System.currentTimeMillis();
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
ColumnAgeOffFilter copy = (ColumnAgeOffFilter) super.deepCopy(env);
@@ -83,11 +83,11 @@ public class ColumnAgeOffFilter extends Filter {
copy.ttls = ttls;
return copy;
}
-
+
public void overrideCurrentTime(long ts) {
this.currentTime = ts;
}
-
+
@Override
public IteratorOptions describeOptions() {
IteratorOptions io = super.describeOptions();
@@ -96,7 +96,7 @@ public class ColumnAgeOffFilter extends Filter {
io.addUnnamedOption("<col fam>[:<col qual>] <Long> (escape non-alphanum chars using %<hex>)");
return io;
}
-
+
@Override
public boolean validateOptions(Map<String,String> options) {
if (super.validateOptions(options) == false)
@@ -108,10 +108,10 @@ public class ColumnAgeOffFilter extends Filter {
}
return true;
}
-
+
/**
* A convenience method for adding or changing an age off threshold for a column.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param column
@@ -122,10 +122,10 @@ public class ColumnAgeOffFilter extends Filter {
public static void addTTL(IteratorSetting is, IteratorSetting.Column column, Long ttl) {
is.addOption(ColumnSet.encodeColumns(column.getFirst(), column.getSecond()), Long.toString(ttl));
}
-
+
/**
* A convenience method for removing an age off threshold for a column.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param column
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnSliceFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnSliceFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnSliceFilter.java
index 5dfcd17..5de72d5 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnSliceFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnSliceFilter.java
@@ -16,6 +16,9 @@
*/
package org.apache.accumulo.core.iterators.user;
+import java.io.IOException;
+import java.util.Map;
+
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
@@ -23,93 +26,90 @@ import org.apache.accumulo.core.iterators.Filter;
import org.apache.accumulo.core.iterators.IteratorEnvironment;
import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
-import java.io.IOException;
-import java.util.Map;
-
public class ColumnSliceFilter extends Filter {
- public static final String START_BOUND = "startBound";
- public static final String START_INCLUSIVE = "startInclusive";
- public static final String END_BOUND = "endBound";
- public static final String END_INCLUSIVE = "endInclusive";
+ public static final String START_BOUND = "startBound";
+ public static final String START_INCLUSIVE = "startInclusive";
+ public static final String END_BOUND = "endBound";
+ public static final String END_INCLUSIVE = "endInclusive";
- private String startBound;
- private String endBound;
- private boolean startInclusive;
- private boolean endInclusive;
+ private String startBound;
+ private String endBound;
+ private boolean startInclusive;
+ private boolean endInclusive;
- @Override
- public boolean accept(Key key, Value value) {
- String colQ = key.getColumnQualifier().toString();
- return (startBound == null || (startInclusive ? (colQ.compareTo(startBound) >= 0) : (colQ.compareTo(startBound) > 0)))
- && (endBound == null || (endInclusive ? (colQ.compareTo(endBound) <= 0) : (colQ.compareTo(endBound) < 0)));
- }
+ @Override
+ public boolean accept(Key key, Value value) {
+ String colQ = key.getColumnQualifier().toString();
+ return (startBound == null || (startInclusive ? (colQ.compareTo(startBound) >= 0) : (colQ.compareTo(startBound) > 0)))
+ && (endBound == null || (endInclusive ? (colQ.compareTo(endBound) <= 0) : (colQ.compareTo(endBound) < 0)));
+ }
- @Override
- public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException {
- super.init(source, options, env);
- if (options.containsKey(START_BOUND)) {
- startBound = options.get(START_BOUND);
- } else {
- startBound = null;
- }
-
- if (options.containsKey(START_INCLUSIVE)) {
- startInclusive = Boolean.parseBoolean(options.get(START_INCLUSIVE));
- } else {
- startInclusive = true;
- }
-
- if (options.containsKey(END_BOUND)) {
- endBound = options.get(END_BOUND);
- } else {
- endBound = null;
- }
+ @Override
+ public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
+ super.init(source, options, env);
+ if (options.containsKey(START_BOUND)) {
+ startBound = options.get(START_BOUND);
+ } else {
+ startBound = null;
+ }
- if (options.containsKey(END_INCLUSIVE)) {
- endInclusive = Boolean.parseBoolean(options.get(END_INCLUSIVE));
- } else {
- endInclusive = false;
- }
+ if (options.containsKey(START_INCLUSIVE)) {
+ startInclusive = Boolean.parseBoolean(options.get(START_INCLUSIVE));
+ } else {
+ startInclusive = true;
}
- @Override
- public IteratorOptions describeOptions() {
- IteratorOptions io = super.describeOptions();
- io.setName("columnSlice");
- io.setDescription("The ColumnSliceFilter/Iterator allows you to filter for key/value pairs based on a lexicographic range of column qualifier names");
- io.addNamedOption(START_BOUND, "start string in slice");
- io.addNamedOption(END_BOUND, "end string in slice");
- io.addNamedOption(START_INCLUSIVE, "include the start bound in the result set");
- io.addNamedOption(END_INCLUSIVE, "include the end bound in the result set");
- return io;
+ if (options.containsKey(END_BOUND)) {
+ endBound = options.get(END_BOUND);
+ } else {
+ endBound = null;
}
- public static void setSlice(IteratorSetting si, String start, String end) {
- setSlice(si, start, true, end, false);
+ if (options.containsKey(END_INCLUSIVE)) {
+ endInclusive = Boolean.parseBoolean(options.get(END_INCLUSIVE));
+ } else {
+ endInclusive = false;
}
+ }
- public static void setSlice(IteratorSetting si, String start, boolean startInclusive, String end, boolean endInclusive) {
- if (start != null && end != null && (start.compareTo(end) > 0 || (start.compareTo(end) == 0 && (!startInclusive || !endInclusive)))) {
- throw new IllegalArgumentException("Start key must be less than end key or equal with both sides inclusive in range (" + start + ", " + end + ")");
- }
+ @Override
+ public IteratorOptions describeOptions() {
+ IteratorOptions io = super.describeOptions();
+ io.setName("columnSlice");
+ io.setDescription("The ColumnSliceFilter/Iterator allows you to filter for key/value pairs based on a lexicographic range of column qualifier names");
+ io.addNamedOption(START_BOUND, "start string in slice");
+ io.addNamedOption(END_BOUND, "end string in slice");
+ io.addNamedOption(START_INCLUSIVE, "include the start bound in the result set");
+ io.addNamedOption(END_INCLUSIVE, "include the end bound in the result set");
+ return io;
+ }
- if (start != null) {
- si.addOption(START_BOUND, start);
- }
- if (end != null) {
- si.addOption(END_BOUND, end);
- }
- si.addOption(START_INCLUSIVE, String.valueOf(startInclusive));
- si.addOption(END_INCLUSIVE, String.valueOf(endInclusive));
+ public static void setSlice(IteratorSetting si, String start, String end) {
+ setSlice(si, start, true, end, false);
+ }
+
+ public static void setSlice(IteratorSetting si, String start, boolean startInclusive, String end, boolean endInclusive) {
+ if (start != null && end != null && (start.compareTo(end) > 0 || (start.compareTo(end) == 0 && (!startInclusive || !endInclusive)))) {
+ throw new IllegalArgumentException("Start key must be less than end key or equal with both sides inclusive in range (" + start + ", " + end + ")");
}
- @Override
- public SortedKeyValueIterator<Key, Value> deepCopy(IteratorEnvironment env) {
- ColumnSliceFilter result = (ColumnSliceFilter) super.deepCopy(env);
- result.startBound = startBound;
- result.startInclusive = startInclusive;
- result.endBound = endBound;
- result.endInclusive = endInclusive;
- return result;
+ if (start != null) {
+ si.addOption(START_BOUND, start);
+ }
+ if (end != null) {
+ si.addOption(END_BOUND, end);
}
+ si.addOption(START_INCLUSIVE, String.valueOf(startInclusive));
+ si.addOption(END_INCLUSIVE, String.valueOf(endInclusive));
+ }
+
+ @Override
+ public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
+ ColumnSliceFilter result = (ColumnSliceFilter) super.deepCopy(env);
+ result.startBound = startBound;
+ result.startInclusive = startInclusive;
+ result.endBound = endBound;
+ result.endInclusive = endInclusive;
+ return result;
+ }
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
index e859363..043a729 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
@@ -34,43 +34,43 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
* This iterator provides exact string matching. It searches both the Key and Value for the string. The string to match is specified by the "term" option.
*/
public class GrepIterator extends Filter {
-
+
private byte term[];
-
+
@Override
public boolean accept(Key k, Value v) {
return match(v.get()) || match(k.getRowData()) || match(k.getColumnFamilyData()) || match(k.getColumnQualifierData());
}
-
+
private boolean match(ByteSequence bs) {
return indexOf(bs.getBackingArray(), bs.offset(), bs.length(), term) >= 0;
}
-
+
private boolean match(byte[] ba) {
return indexOf(ba, 0, ba.length, term) >= 0;
}
-
+
// copied code below from java string and modified
-
+
private static int indexOf(byte[] source, int sourceOffset, int sourceCount, byte[] target) {
byte first = target[0];
int targetCount = target.length;
int max = sourceOffset + (sourceCount - targetCount);
-
+
for (int i = sourceOffset; i <= max; i++) {
/* Look for first character. */
if (source[i] != first) {
while (++i <= max && source[i] != first)
continue;
}
-
+
/* Found first character, now look at the rest of v2 */
if (i <= max) {
int j = i + 1;
int end = j + targetCount - 1;
for (int k = 1; j < end && source[j] == target[k]; j++, k++)
continue;
-
+
if (j == end) {
/* Found whole string. */
return i - sourceOffset;
@@ -79,20 +79,20 @@ public class GrepIterator extends Filter {
}
return -1;
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
GrepIterator copy = (GrepIterator) super.deepCopy(env);
copy.term = Arrays.copyOf(term, term.length);
return copy;
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
term = options.get("term").getBytes(UTF_8);
}
-
+
/**
* Encode the grep term as an option for a ScanIterator
*/
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/IndexedDocIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/IndexedDocIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/IndexedDocIterator.java
index 2e9f049..9ef2bf6 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/IndexedDocIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/IndexedDocIterator.java
@@ -40,37 +40,37 @@ import org.slf4j.LoggerFactory;
* docID. As with the IntersectingIterator, documents are grouped together and indexed into a single row of an Accumulo table. This allows a tablet server to
* perform boolean AND operations on terms in the index. This iterator also stores the document contents in a separate column family in the same row so that the
* full document can be returned with each query.
- *
+ *
* The table structure should have the following form:
- *
+ *
* row: shardID, colfam: docColf\0doctype, colqual: docID, value: doc
- *
+ *
* row: shardID, colfam: indexColf, colqual: term\0doctype\0docID\0info, value: (empty)
- *
+ *
* When you configure this iterator with a set of terms, it will return only the docIDs and docs that appear with all of the specified terms. The result will
* have the following form:
- *
+ *
* row: shardID, colfam: indexColf, colqual: doctype\0docID\0info, value: doc
- *
+ *
* This iterator is commonly used with BatchScanner or AccumuloInputFormat, to parallelize the search over all shardIDs.
*/
public class IndexedDocIterator extends IntersectingIterator {
private static final Logger log = LoggerFactory.getLogger(IndexedDocIterator.class);
public static final Text DEFAULT_INDEX_COLF = new Text("i");
public static final Text DEFAULT_DOC_COLF = new Text("e");
-
+
private static final String indexFamilyOptionName = "indexFamily";
private static final String docFamilyOptionName = "docFamily";
-
+
private Text indexColf = DEFAULT_INDEX_COLF;
private Text docColf = DEFAULT_DOC_COLF;
private Set<ByteSequence> indexColfSet;
private Set<ByteSequence> docColfSet;
-
+
private static final byte[] nullByte = {0};
-
+
public SortedKeyValueIterator<Key,Value> docSource;
-
+
@Override
protected Key buildKey(Text partition, Text term, Text docID) {
Text colq = new Text(term);
@@ -79,18 +79,18 @@ public class IndexedDocIterator extends IntersectingIterator {
colq.append(nullByte, 0, 1);
return new Key(partition, indexColf, colq);
}
-
+
@Override
protected Key buildKey(Text partition, Text term) {
Text colq = new Text(term);
return new Key(partition, indexColf, colq);
}
-
+
@Override
protected Text getDocID(Key key) {
return parseDocID(key);
}
-
+
public static Text parseDocID(Key key) {
Text colq = key.getColumnQualifier();
int firstZeroIndex = colq.find("\0");
@@ -113,7 +113,7 @@ public class IndexedDocIterator extends IntersectingIterator {
}
return docID;
}
-
+
@Override
protected Text getTerm(Key key) {
if (indexColf.compareTo(key.getColumnFamily().getBytes(), 0, indexColf.getLength()) < 0) {
@@ -127,7 +127,7 @@ public class IndexedDocIterator extends IntersectingIterator {
term.set(colq.getBytes(), 0, zeroIndex);
return term;
}
-
+
@Override
synchronized public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
@@ -137,23 +137,23 @@ public class IndexedDocIterator extends IntersectingIterator {
docColf = new Text(options.get(docFamilyOptionName));
docSource = source.deepCopy(env);
indexColfSet = Collections.singleton((ByteSequence) new ArrayByteSequence(indexColf.getBytes(), 0, indexColf.getLength()));
-
+
for (TermSource ts : this.sources) {
ts.seekColfams = indexColfSet;
}
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
throw new UnsupportedOperationException();
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> seekColumnFamilies, boolean inclusive) throws IOException {
super.seek(range, null, true);
-
+
}
-
+
@Override
protected void advanceToIntersection() throws IOException {
super.advanceToIntersection();
@@ -169,7 +169,7 @@ public class IndexedDocIterator extends IntersectingIterator {
}
log.debug("got doc value: " + value.toString());
}
-
+
protected Key buildDocKey() {
if (log.isTraceEnabled())
log.trace("building doc key for " + currentPartition + " " + currentDocID);
@@ -189,10 +189,10 @@ public class IndexedDocIterator extends IntersectingIterator {
log.trace("built doc key for seek: " + k.toString());
return k;
}
-
+
/**
* A convenience method for setting the index column family.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param indexColf
@@ -201,10 +201,10 @@ public class IndexedDocIterator extends IntersectingIterator {
public static void setIndexColf(IteratorSetting is, String indexColf) {
is.addOption(indexFamilyOptionName, indexColf);
}
-
+
/**
* A convenience method for setting the document column family prefix.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param docColfPrefix
@@ -213,10 +213,10 @@ public class IndexedDocIterator extends IntersectingIterator {
public static void setDocColfPrefix(IteratorSetting is, String docColfPrefix) {
is.addOption(docFamilyOptionName, docColfPrefix);
}
-
+
/**
* A convenience method for setting the index column family and document column family prefix.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param indexColf
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
index 732a76c..63d6a34 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
@@ -39,68 +39,68 @@ import org.apache.hadoop.io.Text;
/**
* This iterator facilitates document-partitioned indexing. It involves grouping a set of documents together and indexing those documents into a single row of
* an Accumulo table. This allows a tablet server to perform boolean AND operations on terms in the index.
- *
+ *
* The table structure should have the following form:
- *
+ *
* row: shardID, colfam: term, colqual: docID
- *
+ *
* When you configure this iterator with a set of terms (column families), it will return only the docIDs that appear with all of the specified terms. The
* result will have an empty column family, as follows:
- *
+ *
* row: shardID, colfam: (empty), colqual: docID
- *
+ *
* This iterator is commonly used with BatchScanner or AccumuloInputFormat, to parallelize the search over all shardIDs.
- *
+ *
* This iterator will *ignore* any columnFamilies passed to {@link #seek(Range, Collection, boolean)} as it performs intersections over terms. Extending classes
* should override the {@link TermSource#seekColfams} in their implementation's {@link #init(SortedKeyValueIterator, Map, IteratorEnvironment)} method.
- *
+ *
* README.shard in docs/examples shows an example of using the IntersectingIterator.
*/
public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
-
+
protected Text nullText = new Text();
-
+
protected Text getPartition(Key key) {
return key.getRow();
}
-
+
protected Text getTerm(Key key) {
return key.getColumnFamily();
}
-
+
protected Text getDocID(Key key) {
return key.getColumnQualifier();
}
-
+
protected Key buildKey(Text partition, Text term) {
return new Key(partition, (term == null) ? nullText : term);
}
-
+
protected Key buildKey(Text partition, Text term, Text docID) {
return new Key(partition, (term == null) ? nullText : term, docID);
}
-
+
protected Key buildFollowingPartitionKey(Key key) {
return key.followingKey(PartialKey.ROW);
}
-
+
public static class TermSource {
public SortedKeyValueIterator<Key,Value> iter;
public Text term;
public Collection<ByteSequence> seekColfams;
public boolean notFlag;
-
+
public TermSource(TermSource other) {
this.iter = other.iter;
this.term = other.term;
this.notFlag = other.notFlag;
this.seekColfams = other.seekColfams;
}
-
+
public TermSource(SortedKeyValueIterator<Key,Value> iter, Text term) {
this(iter, term, false);
}
-
+
public TermSource(SortedKeyValueIterator<Key,Value> iter, Text term, boolean notFlag) {
this.iter = iter;
this.term = term;
@@ -108,32 +108,32 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
// The desired column families for this source is the term itself
this.seekColfams = Collections.<ByteSequence> singletonList(new ArrayByteSequence(term.getBytes(), 0, term.getLength()));
}
-
+
public String getTermString() {
return (this.term == null) ? "Iterator" : this.term.toString();
}
}
-
+
protected TermSource[] sources;
int sourcesCount = 0;
-
+
Range overallRange;
-
+
// query-time settings
protected Text currentPartition = null;
protected Text currentDocID = new Text(emptyByteArray);
static final byte[] emptyByteArray = new byte[0];
-
+
protected Key topKey = null;
protected Value value = new Value(emptyByteArray);
-
+
public IntersectingIterator() {}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new IntersectingIterator(this, env);
}
-
+
private IntersectingIterator(IntersectingIterator other, IteratorEnvironment env) {
if (other.sources != null) {
sourcesCount = other.sourcesCount;
@@ -143,29 +143,29 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
}
}
-
+
@Override
public Key getTopKey() {
return topKey;
}
-
+
@Override
public Value getTopValue() {
// we don't really care about values
return value;
}
-
+
@Override
public boolean hasTop() {
return currentPartition != null;
}
-
+
// precondition: currentRow is not null
private boolean seekOneSource(int sourceID) throws IOException {
// find the next key in the appropriate column family that is at or beyond the cursor (currentRow, currentCQ)
// advance the cursor if this source goes beyond it
// return whether we advanced the cursor
-
+
// within this loop progress must be made in one of the following forms:
// - currentRow or currentCQ must be increased
// - the given source must advance its iterator
@@ -174,7 +174,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
// - the given source is out of data and currentRow is set to null
// - the given source has advanced beyond the endRow and currentRow is set to null
boolean advancedCursor = false;
-
+
if (sources[sourceID].notFlag) {
while (true) {
if (sources[sourceID].iter.hasTop() == false) {
@@ -194,7 +194,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
int partitionCompare = currentPartition.compareTo(getPartition(sources[sourceID].iter.getTopKey()));
// check if this source is already at or beyond currentRow
// if not, then seek to at least the current row
-
+
if (partitionCompare > 0) {
// seek to at least the currentRow
Key seekKey = buildKey(currentPartition, sources[sourceID].term);
@@ -224,7 +224,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
break;
}
}
-
+
// we have verified that we are in currentRow and the correct column family
// make sure we are at or beyond columnQualifier
Text docID = getDocID(sources[sourceID].iter.getTopKey());
@@ -260,7 +260,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
// check if we're past the end key
int endCompare = -1;
// we should compare the row to the end of the range
-
+
if (overallRange.getEndKey() != null) {
endCompare = overallRange.getEndKey().getRow().compareTo(sources[sourceID].iter.getTopKey().getRow());
if ((!overallRange.isEndKeyInclusive() && endCompare <= 0) || endCompare < 0) {
@@ -289,7 +289,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
// we have verified that the current source is positioned in currentRow
// now we must make sure we're in the right columnFamily in the current row
// Note: Iterators are auto-magically set to the correct columnFamily
-
+
if (sources[sourceID].term != null) {
int termCompare = sources[sourceID].term.compareTo(getTerm(sources[sourceID].iter.getTopKey()));
// check if this source is already on the right columnFamily
@@ -343,7 +343,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
return advancedCursor;
}
-
+
@Override
public void next() throws IOException {
if (currentPartition == null) {
@@ -354,7 +354,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
sources[0].iter.next();
advanceToIntersection();
}
-
+
protected void advanceToIntersection() throws IOException {
boolean cursorChanged = true;
while (cursorChanged) {
@@ -373,16 +373,16 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
topKey = buildKey(currentPartition, nullText, currentDocID);
}
-
+
public static String stringTopKey(SortedKeyValueIterator<Key,Value> iter) {
if (iter.hasTop())
return iter.getTopKey().toString();
return "";
}
-
+
private static final String columnFamiliesOptionName = "columnFamilies";
private static final String notFlagOptionName = "notFlag";
-
+
/**
* @return encoded columns
*/
@@ -394,7 +394,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
return sb.toString();
}
-
+
/**
* @return encoded flags
*/
@@ -408,7 +408,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
return Base64.encodeBase64String(bytes);
}
-
+
protected static Text[] decodeColumns(String columns) {
String[] columnStrings = columns.split("\n");
Text[] columnTexts = new Text[columnStrings.length];
@@ -417,7 +417,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
return columnTexts;
}
-
+
/**
* @return decoded flags
*/
@@ -425,7 +425,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
// return null of there were no flags
if (flags == null)
return null;
-
+
byte[] bytes = Base64.decodeBase64(flags.getBytes(UTF_8));
boolean[] bFlags = new boolean[bytes.length];
for (int i = 0; i < bytes.length; i++) {
@@ -436,16 +436,16 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
return bFlags;
}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
Text[] terms = decodeColumns(options.get(columnFamiliesOptionName));
boolean[] notFlag = decodeBooleans(options.get(notFlagOptionName));
-
+
if (terms.length < 1) {
throw new IllegalArgumentException("IntersectionIterator requires one or more columns families");
}
-
+
// Scan the not flags.
// There must be at least one term that isn't negated
// And we are going to re-order such that the first term is not a ! term
@@ -469,7 +469,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
throw new IllegalArgumentException("IntersectionIterator requires at lest one column family without not");
}
}
-
+
sources = new TermSource[terms.length];
sources[0] = new TermSource(source, terms[0]);
for (int i = 1; i < terms.length; i++) {
@@ -477,13 +477,13 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
sourcesCount = terms.length;
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> seekColumnFamilies, boolean inclusive) throws IOException {
overallRange = new Range(range);
currentPartition = new Text();
currentDocID.set(emptyByteArray);
-
+
// seek each of the sources to the right column family within the row given by key
for (int i = 0; i < sourcesCount; i++) {
Key sourceKey;
@@ -502,7 +502,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
advanceToIntersection();
}
-
+
/**
* @deprecated since 1.6.0
*/
@@ -526,7 +526,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
sources[sourcesCount] = new TermSource(source.deepCopy(env), term, notFlag);
sourcesCount++;
}
-
+
/**
* Encode the columns to be used when iterating.
*/
@@ -535,7 +535,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
throw new IllegalArgumentException("Must supply at least one term to intersect");
cfg.addOption(IntersectingIterator.columnFamiliesOptionName, IntersectingIterator.encodeColumns(columns));
}
-
+
/**
* Encode columns and NOT flags indicating which columns should be negated (docIDs will be excluded if matching negated columns, instead of included).
*/
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
index 4db379b..59a5dec 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
@@ -41,40 +41,40 @@ import org.apache.hadoop.io.Text;
/**
* This iterator suppresses rows that exceed a specified number of columns. Once a row exceeds the threshold, a marker is emitted and the row is always
* suppressed by this iterator after that point in time.
- *
+ *
* This iterator works in a similar way to the RowDeletingIterator. See its javadoc about locality groups.
*/
public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, OptionDescriber {
-
+
public static final Value SUPPRESS_ROW_VALUE = new Value("SUPPRESS_ROW".getBytes(UTF_8));
-
+
private static final ByteSequence EMPTY = new ArrayByteSequence(new byte[] {});
-
+
/* key into hash map, value refers to the row supression limit (maxColumns) */
private static final String MAX_COLUMNS = "max_columns";
-
+
private SortedKeyValueIterator<Key,Value> source;
-
+
// a cache of keys
private ArrayList<Key> keys = new ArrayList<Key>();
private ArrayList<Value> values = new ArrayList<Value>();
-
+
private int currentPosition;
-
+
private int maxColumns;
-
+
private boolean propogateSuppression = false;
-
+
private Range range;
private Collection<ByteSequence> columnFamilies;
private boolean inclusive;
private boolean dropEmptyColFams;
-
+
private boolean isSuppressionMarker(Key key, Value val) {
return key.getColumnFamilyData().length() == 0 && key.getColumnQualifierData().length() == 0 && key.getColumnVisibilityData().length() == 0
&& val.equals(SUPPRESS_ROW_VALUE);
}
-
+
private void reseek(Key key) throws IOException {
if (range.afterEndKey(key)) {
range = new Range(range.getEndKey(), true, range.getEndKey(), range.isEndKeyInclusive());
@@ -84,11 +84,11 @@ public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, Option
source.seek(range, columnFamilies, inclusive);
}
}
-
+
private void consumeRow(ByteSequence row) throws IOException {
// try reading a few and if still not to next row, then seek
int count = 0;
-
+
while (source.hasTop() && source.getTopKey().getRowData().equals(row)) {
source.next();
count++;
@@ -99,7 +99,7 @@ public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, Option
}
}
}
-
+
private void addKeyValue(Key k, Value v) {
if (dropEmptyColFams && k.getColumnFamilyData().equals(EMPTY)) {
return;
@@ -107,34 +107,34 @@ public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, Option
keys.add(new Key(k));
values.add(new Value(v));
}
-
+
private void bufferNextRow() throws IOException {
-
+
keys.clear();
values.clear();
currentPosition = 0;
-
+
while (source.hasTop() && keys.size() == 0) {
-
+
addKeyValue(source.getTopKey(), source.getTopValue());
-
+
if (isSuppressionMarker(source.getTopKey(), source.getTopValue())) {
-
+
consumeRow(source.getTopKey().getRowData());
-
+
} else {
-
+
ByteSequence currentRow = keys.get(0).getRowData();
source.next();
-
+
while (source.hasTop() && source.getTopKey().getRowData().equals(currentRow)) {
-
+
addKeyValue(source.getTopKey(), source.getTopValue());
-
+
if (keys.size() > maxColumns) {
keys.clear();
values.clear();
-
+
// when the row is to big, just emit a suppression
// marker
addKeyValue(new Key(new Text(currentRow.toArray())), SUPPRESS_ROW_VALUE);
@@ -144,56 +144,56 @@ public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, Option
}
}
}
-
+
}
}
-
+
private void readNextRow() throws IOException {
-
+
bufferNextRow();
-
+
while (!propogateSuppression && currentPosition < keys.size() && isSuppressionMarker(keys.get(0), values.get(0))) {
bufferNextRow();
}
}
-
+
private LargeRowFilter(SortedKeyValueIterator<Key,Value> source, boolean propogateSuppression, int maxColumns) {
this.source = source;
this.propogateSuppression = propogateSuppression;
this.maxColumns = maxColumns;
}
-
+
public LargeRowFilter() {}
-
+
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
this.source = source;
this.maxColumns = Integer.parseInt(options.get(MAX_COLUMNS));
this.propogateSuppression = env.getIteratorScope() != IteratorScope.scan;
}
-
+
@Override
public boolean hasTop() {
return currentPosition < keys.size();
}
-
+
@Override
public void next() throws IOException {
-
+
if (currentPosition >= keys.size()) {
throw new IllegalStateException("Called next() when hasTop() is false");
}
-
+
currentPosition++;
-
+
if (currentPosition == keys.size()) {
readNextRow();
}
}
-
+
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
-
+
if (inclusive && !columnFamilies.contains(EMPTY)) {
columnFamilies = new HashSet<ByteSequence>(columnFamilies);
columnFamilies.add(EMPTY);
@@ -205,48 +205,48 @@ public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, Option
} else {
dropEmptyColFams = false;
}
-
+
this.range = range;
this.columnFamilies = columnFamilies;
this.inclusive = inclusive;
-
+
if (range.getStartKey() != null) {
// seek to beginning of row to see if there is a suppression marker
Range newRange = new Range(new Key(range.getStartKey().getRow()), true, range.getEndKey(), range.isEndKeyInclusive());
source.seek(newRange, columnFamilies, inclusive);
-
+
readNextRow();
-
+
// it is possible that all or some of the data read for the current
// row is before the start of the range
while (currentPosition < keys.size() && range.beforeStartKey(keys.get(currentPosition)))
currentPosition++;
-
+
if (currentPosition == keys.size())
readNextRow();
-
+
} else {
source.seek(range, columnFamilies, inclusive);
readNextRow();
}
-
+
}
-
+
@Override
public Key getTopKey() {
return keys.get(currentPosition);
}
-
+
@Override
public Value getTopValue() {
return values.get(currentPosition);
}
-
+
@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
return new LargeRowFilter(source.deepCopy(env), propogateSuppression, maxColumns);
}
-
+
@Override
public IteratorOptions describeOptions() {
String description = "This iterator suppresses rows that exceed a specified number of columns. Once\n"
@@ -255,13 +255,13 @@ public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, Option
return new IteratorOptions(this.getClass().getSimpleName(), description, Collections.singletonMap(MAX_COLUMNS, "Number Of Columns To Begin Suppression"),
null);
}
-
+
@Override
public boolean validateOptions(Map<String,String> options) {
if (options == null || options.size() < 1) {
throw new IllegalArgumentException("Bad # of options, must supply: " + MAX_COLUMNS + " as value");
}
-
+
if (!options.containsKey(MAX_COLUMNS))
throw new IllegalArgumentException("Bad # of options, must supply: " + MAX_COLUMNS + " as value");
try {
@@ -269,13 +269,13 @@ public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, Option
} catch (Exception e) {
throw new IllegalArgumentException("bad integer " + MAX_COLUMNS + ":" + options.get(MAX_COLUMNS));
}
-
+
return true;
}
-
+
/**
* A convenience method for setting the maximum number of columns to keep.
- *
+ *
* @param is
* IteratorSetting object to configure.
* @param maxColumns
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/MaxCombiner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/MaxCombiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/MaxCombiner.java
index 1b5a4e2..08ec483 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/MaxCombiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/MaxCombiner.java
@@ -35,7 +35,7 @@ public class MaxCombiner extends LongCombiner {
}
return max;
}
-
+
@Override
public IteratorOptions describeOptions() {
IteratorOptions io = super.describeOptions();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/iterators/user/MinCombiner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/MinCombiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/MinCombiner.java
index 891806e..31be086 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/MinCombiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/MinCombiner.java
@@ -35,7 +35,7 @@ public class MinCombiner extends LongCombiner {
}
return min;
}
-
+
@Override
public IteratorOptions describeOptions() {
IteratorOptions io = super.describeOptions();