Repository: phoenix
Updated Branches:
  refs/heads/4.0 a329d3f42 -> 954133c32
  refs/heads/master c72c4a65d -> ed4163b7e


PHOENIX-1280 ColumnProjectionFilter creates too many ImmutableBytesPtrs


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ed4163b7
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ed4163b7
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ed4163b7

Branch: refs/heads/master
Commit: ed4163b7e52dd7ca270b7ee42bdf83bdd769966a
Parents: c72c4a6
Author: Lars Hofhansl <la...@apache.org>
Authored: Tue Sep 23 17:49:36 2014 -0700
Committer: Lars Hofhansl <la...@apache.org>
Committed: Tue Sep 23 17:49:36 2014 -0700

----------------------------------------------------------------------
 .../phoenix/filter/ColumnProjectionFilter.java  | 21 ++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ed4163b7/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 032fb7e..a238e8e 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
@@ -129,27 +129,28 @@ public class ColumnProjectionFilter extends FilterBase 
implements Writable {
         }
     }
     
+    // "ptr" to be used for one time comparisons in filterRowCells
+    private ImmutableBytesPtr ptr = new ImmutableBytesPtr();
     @Override
     public void filterRowCells(List<Cell> kvs) throws IOException {
         if (kvs.isEmpty()) return;
-        KeyValue firstKV = KeyValueUtil.ensureKeyValue(kvs.get(0));
+        Cell firstKV = kvs.get(0);
         Iterator<Cell> itr = kvs.iterator();
         while (itr.hasNext()) {
-            KeyValue kv = KeyValueUtil.ensureKeyValue(itr.next());
-            ImmutableBytesPtr f = new ImmutableBytesPtr(kv.getFamilyArray(),
-              kv.getFamilyOffset(), kv.getFamilyLength());
-            if (this.columnsTracker.containsKey(f)) {
-                Set<ImmutableBytesPtr> cols = this.columnsTracker.get(f);
-                ImmutableBytesPtr q = new 
ImmutableBytesPtr(kv.getQualifierArray(),
-                  kv.getQualifierOffset(),
-                        kv.getQualifierLength());
-                if (cols != null && !(cols.contains(q))) {
+            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();
                 }
             } else {
                 itr.remove();
             }
         }
+        // make sure we're not holding to any of the byte[]'s
+        ptr.set(HConstants.EMPTY_BYTE_ARRAY);
         if (kvs.isEmpty()) {
             kvs.add(new KeyValue(firstKV.getRowArray(), 
firstKV.getRowOffset(),firstKV.getRowLength(), this.emptyCFName,
                     0, this.emptyCFName.length, 
QueryConstants.EMPTY_COLUMN_BYTES, 0,

Reply via email to