Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 85ae9db4b -> 276c74d71
PHOENIX-3393 Use Iterables.removeIf instead of Iterator.remove in HBase filters(Robert Yokota) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/276c74d7 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/276c74d7 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/276c74d7 Branch: refs/heads/4.x-HBase-0.98 Commit: 276c74d719193a1af59fdd4bcdb52942343c3a63 Parents: 85ae9db Author: Ankit Singhal <ankitsingha...@gmail.com> Authored: Fri Oct 21 16:32:45 2016 +0530 Committer: Ankit Singhal <ankitsingha...@gmail.com> Committed: Fri Oct 21 16:32:45 2016 +0530 ---------------------------------------------------------------------- .../phoenix/filter/ColumnProjectionFilter.java | 29 +++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/276c74d7/phoenix-core/src/main/java/org/apache/phoenix/filter/ColumnProjectionFilter.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/filter/ColumnProjectionFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/ColumnProjectionFilter.java index b8b0350..92e5c20 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/filter/ColumnProjectionFilter.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/ColumnProjectionFilter.java @@ -20,7 +20,6 @@ package org.apache.phoenix.filter; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -29,6 +28,8 @@ import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; @@ -136,20 +137,22 @@ public class ColumnProjectionFilter extends FilterBase implements Writable { public void filterRowCells(List<Cell> kvs) throws IOException { if (kvs.isEmpty()) return; Cell firstKV = kvs.get(0); - Iterator<Cell> itr = kvs.iterator(); - while (itr.hasNext()) { - Cell kv = itr.next(); - ptr.set(kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength()); - if (this.columnsTracker.containsKey(ptr)) { - Set<ImmutableBytesPtr> cols = this.columnsTracker.get(ptr); - ptr.set(kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength()); - if (cols != null && !(cols.contains(ptr))) { - itr.remove(); + Iterables.removeIf(kvs, new Predicate<Cell>() { + @Override + public boolean apply(Cell kv) { + ptr.set(kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength()); + if (columnsTracker.containsKey(ptr)) { + Set<ImmutableBytesPtr> cols = columnsTracker.get(ptr); + ptr.set(kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength()); + if (cols != null && !(cols.contains(ptr))) { + return true; + } + } else { + return true; } - } else { - itr.remove(); + return false; } - } + }); // make sure we're not holding to any of the byte[]'s ptr.set(HConstants.EMPTY_BYTE_ARRAY); if (kvs.isEmpty()) {