[1/2] git commit: PHOENIX-1280 ColumnProjectionFilter creates too many ImmutableBytesPtrs

2014-09-23 Thread larsh
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(ListCell kvs) throws IOException {
 if (kvs.isEmpty()) return;
-KeyValue firstKV = KeyValueUtil.ensureKeyValue(kvs.get(0));
+Cell firstKV = kvs.get(0);
 IteratorCell 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)) {
-SetImmutableBytesPtr 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)) {
+SetImmutableBytesPtr 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,



git commit: PHOENIX-1280 ColumnProjectionFilter creates too many ImmutableBytesPtrs

2014-09-23 Thread larsh
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 la...@apache.org
Authored: Tue Sep 23 17:56:06 2014 -0700
Committer: Lars Hofhansl la...@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(ListKeyValue kvs) {
 if (kvs.isEmpty()) return;
@@ -110,18 +112,19 @@ public class ColumnProjectionFilter extends FilterBase {
 IteratorKeyValue 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)) {
-SetImmutableBytesPtr 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)) {
+SetImmutableBytesPtr 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,