Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.1 49f082ad9 -> 88907c224
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/88907c22 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/88907c22 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/88907c22 Branch: refs/heads/4.x-HBase-1.1 Commit: 88907c2242241034c4d93fbd79e7df1e31d3aea8 Parents: 49f082a Author: Ankit Singhal <ankitsingha...@gmail.com> Authored: Fri Oct 21 16:31:11 2016 +0530 Committer: Ankit Singhal <ankitsingha...@gmail.com> Committed: Fri Oct 21 16:31:11 2016 +0530 ---------------------------------------------------------------------- .../phoenix/filter/ColumnProjectionFilter.java | 29 +++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/88907c22/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()) {