phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject [28/50] [abbrv] phoenix git commit: PHOENIX-1650 Possible resource leak in upsert select query (Rajeshbabu)
Date Wed, 04 Mar 2015 22:41:03 GMT
PHOENIX-1650 Possible resource leak in upsert select query (Rajeshbabu)


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

Branch: refs/heads/calcite
Commit: e0a81a09ec7aeab44a2bce597d19850e7c6a7846
Parents: 7dc3d84
Author: James Taylor <jtaylor@salesforce.com>
Authored: Tue Feb 10 16:51:10 2015 -0800
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Tue Feb 10 16:53:26 2015 -0800

----------------------------------------------------------------------
 .../apache/phoenix/compile/UpsertCompiler.java  | 26 +++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e0a81a09/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
index 2ac075e..b21cc2f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
@@ -670,18 +670,22 @@ public class UpsertCompiler {
                     if (parallelIteratorFactory == null) {
                         return upsertSelect(statement, tableRef, projector, iterator, columnIndexes,
pkSlotIndexes);
                     }
-                    parallelIteratorFactory.setRowProjector(projector);
-                    parallelIteratorFactory.setColumnIndexes(columnIndexes);
-                    parallelIteratorFactory.setPkSlotIndexes(pkSlotIndexes);
-                    Tuple tuple;
-                    long totalRowCount = 0;
-                    while ((tuple=iterator.next()) != null) {// Runs query
-                        Cell kv = tuple.getValue(0);
-                        totalRowCount += PLong.INSTANCE.getCodec().decodeLong(kv.getValueArray(),
kv.getValueOffset(), SortOrder.getDefault());
+                    try {
+                        parallelIteratorFactory.setRowProjector(projector);
+                        parallelIteratorFactory.setColumnIndexes(columnIndexes);
+                        parallelIteratorFactory.setPkSlotIndexes(pkSlotIndexes);
+                        Tuple tuple;
+                        long totalRowCount = 0;
+                        while ((tuple=iterator.next()) != null) {// Runs query
+                            Cell kv = tuple.getValue(0);
+                            totalRowCount += PLong.INSTANCE.getCodec().decodeLong(kv.getValueArray(),
kv.getValueOffset(), SortOrder.getDefault());
+                        }
+                        // Return total number of rows that have been updated. In the case
of auto commit being off
+                        // the mutations will all be in the mutation state of the current
connection.
+                        return new MutationState(maxSize, statement.getConnection(), totalRowCount);
+                    } finally {
+                        iterator.close();
                     }
-                    // Return total number of rows that have been updated. In the case of
auto commit being off
-                    // the mutations will all be in the mutation state of the current connection.
-                    return new MutationState(maxSize, statement.getConnection(), totalRowCount);
                 }
 
                 @Override


Mime
View raw message