phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject git commit: PHOENIX-1280 ColumnProjectionFilter creates too many ImmutableBytesPtrs
Date Wed, 24 Sep 2014 00:56:37 GMT
Repository: phoenix
Updated Branches:
  refs/heads/3.0 f4eb0cdf8 -> ca776fe89


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/ca776fe8
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ca776fe8
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ca776fe8

Branch: refs/heads/3.0
Commit: ca776fe8912b2316701f13342c1d736c44a0c6b4
Parents: f4eb0cd
Author: Lars Hofhansl <larsh@apache.org>
Authored: Tue Sep 23 17:56:06 2014 -0700
Committer: Lars Hofhansl <larsh@apache.org>
Committed: Tue Sep 23 17:56:06 2014 -0700

----------------------------------------------------------------------
 .../phoenix/filter/ColumnProjectionFilter.java       | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ca776fe8/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 8c5225f..0af3258 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
@@ -103,6 +103,8 @@ public class ColumnProjectionFilter extends FilterBase {
         }
     }
 
+    // "ptr" to be used for one time comparisons in filterRowCells
+    private ImmutableBytesPtr ptr = new ImmutableBytesPtr();
     @Override
     public void filterRow(List<KeyValue> kvs) {
         if (kvs.isEmpty()) return;
@@ -110,18 +112,19 @@ public class ColumnProjectionFilter extends FilterBase {
         Iterator<KeyValue> itr = kvs.iterator();
         while (itr.hasNext()) {
             KeyValue kv = itr.next();
-            ImmutableBytesPtr f = new ImmutableBytesPtr(kv.getBuffer(), kv.getFamilyOffset(),
kv.getFamilyLength());
-            if (this.columnsTracker.containsKey(f)) {
-                Set<ImmutableBytesPtr> cols = this.columnsTracker.get(f);
-                ImmutableBytesPtr q = new ImmutableBytesPtr(kv.getBuffer(), kv.getQualifierOffset(),
-                        kv.getQualifierLength());
-                if (cols != null && !(cols.contains(q))) {
+            ptr.set(kv.getBuffer(), kv.getFamilyOffset(), kv.getFamilyLength());
+            if (this.columnsTracker.containsKey(ptr)) {
+                Set<ImmutableBytesPtr> cols = this.columnsTracker.get(ptr);
+                ptr.set(kv.getBuffer(), 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.getBuffer(), firstKV.getRowOffset(), firstKV.getRowLength(),
this.emptyCFName,
                     0, this.emptyCFName.length, QueryConstants.EMPTY_COLUMN_BYTES, 0,


Mime
View raw message