phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdsi...@apache.org
Subject phoenix git commit: PHOENIX-3980 Wrap iterator returned by BaseQueryPlan so that it always closes dependencies
Date Wed, 28 Jun 2017 18:45:08 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.11-HBase-1.2 77006e6eb -> 3e81387c5


PHOENIX-3980 Wrap iterator returned by BaseQueryPlan so that it always closes dependencies


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

Branch: refs/heads/4.11-HBase-1.2
Commit: 3e81387c58cf90dc4b36c34725119ce459cd0996
Parents: 77006e6
Author: Thomas <tdsilva@salesforce.com>
Authored: Tue Jun 27 20:02:22 2017 -0700
Committer: Thomas <tdsilva@salesforce.com>
Committed: Wed Jun 28 11:43:53 2017 -0700

----------------------------------------------------------------------
 .../ConnectionQueryServicesTestImpl.java        |  4 +--
 .../apache/phoenix/execute/BaseQueryPlan.java   | 33 +++++++++++---------
 2 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3e81387c/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
index 5b64c98..a1ad1ad 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
@@ -70,8 +70,8 @@ public class ConnectionQueryServicesTestImpl extends ConnectionQueryServicesImpl
                 this.connections = Sets.newHashSet();
             }
             SQLCloseables.closeAll(connections);
-            // long unfreedBytes = clearCache();
-            // assertEquals("Found unfreed bytes in server-side cache", 0, unfreedBytes);
+             long unfreedBytes = clearCache();
+             assertEquals("Found unfreed bytes in server-side cache", 0, unfreedBytes);
         } finally {
             super.close();
         }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3e81387c/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
index 9f30aac..881a033 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
@@ -208,6 +208,21 @@ public abstract class BaseQueryPlan implements QueryPlan {
     public final ResultIterator iterator(ParallelScanGrouper scanGrouper, Scan scan) throws
SQLException {
         return iterator(Collections.<SQLCloseable>emptyList(), scanGrouper, scan);
     }
+    
+	private ResultIterator getWrappedIterator(final List<? extends SQLCloseable> dependencies,
+			ResultIterator iterator) {
+		ResultIterator wrappedIterator = dependencies.isEmpty() ? iterator : new DelegateResultIterator(iterator)
{
+			@Override
+			public void close() throws SQLException {
+				try {
+					super.close();
+				} finally {
+					SQLCloseables.closeAll(dependencies);
+				}
+			}
+		};
+		return wrappedIterator;
+	}
 
     public final ResultIterator iterator(final List<? extends SQLCloseable> dependencies,
ParallelScanGrouper scanGrouper, Scan scan) throws SQLException {
          if (scan == null) {
@@ -220,11 +235,11 @@ public abstract class BaseQueryPlan implements QueryPlan {
 		 * row to be scanned.
 		 */
         if (context.getScanRanges() == ScanRanges.NOTHING && !getStatement().isAggregate())
{
-            return ResultIterator.EMPTY_ITERATOR;
+            return getWrappedIterator(dependencies, ResultIterator.EMPTY_ITERATOR);
         }
         
         if (tableRef == TableRef.EMPTY_TABLE_REF) {
-            return newIterator(scanGrouper, scan);
+            return getWrappedIterator(dependencies, newIterator(scanGrouper, scan));
         }
         
         // Set miscellaneous scan attributes. This is the last chance to set them before
we
@@ -333,19 +348,7 @@ public abstract class BaseQueryPlan implements QueryPlan {
         	LOG.debug(LogUtil.addCustomAnnotations("Scan ready for iteration: " + scan, connection));
         }
         
-        ResultIterator iterator = newIterator(scanGrouper, scan);
-        iterator = dependencies.isEmpty() ?
-                iterator : new DelegateResultIterator(iterator) {
-            @Override
-            public void close() throws SQLException {
-                try {
-                    super.close();
-                } finally {
-                    SQLCloseables.closeAll(dependencies);
-                }
-            }
-        };
-        
+        ResultIterator iterator = getWrappedIterator(dependencies, newIterator(scanGrouper,
scan));
         if (LOG.isDebugEnabled()) {
         	LOG.debug(LogUtil.addCustomAnnotations("Iterator ready: " + iterator, connection));
         }


Mime
View raw message