phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject [14/35] phoenix git commit: PHOENIX-3393 Use Iterables.removeIf instead of Iterator.remove in HBase filters(Robert Yokota)
Date Fri, 28 Oct 2016 21:34:07 GMT
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/5c9fb7b6
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/5c9fb7b6
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/5c9fb7b6

Branch: refs/heads/calcite
Commit: 5c9fb7b68ebeed20e3876579534df4adf21943a4
Parents: 1e78d3b
Author: Ankit Singhal <ankitsinghal59@gmail.com>
Authored: Fri Oct 21 16:30:44 2016 +0530
Committer: Ankit Singhal <ankitsinghal59@gmail.com>
Committed: Fri Oct 21 16:30:44 2016 +0530

----------------------------------------------------------------------
 .../phoenix/filter/ColumnProjectionFilter.java  | 29 +++++++++++---------
 1 file changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/5c9fb7b6/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()) {


Mime
View raw message