drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ve...@apache.org
Subject [1/2] drill git commit: DRILL-3398: Fix memory leak in WebServer
Date Fri, 26 Jun 2015 19:35:35 GMT
Repository: drill
Updated Branches:
  refs/heads/master da17f2867 -> 60bc9459b


DRILL-3398: Fix memory leak in WebServer


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

Branch: refs/heads/master
Commit: 60bc9459bd8ef29e9d90ffe885771090ab658a40
Parents: 153baeb
Author: vkorukanti <venki.korukanti@gmail.com>
Authored: Fri Jun 26 11:41:35 2015 -0700
Committer: vkorukanti <venki.korukanti@gmail.com>
Committed: Fri Jun 26 11:46:47 2015 -0700

----------------------------------------------------------------------
 .../drill/exec/server/rest/QueryWrapper.java    | 39 ++++++++++++--------
 1 file changed, 23 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/60bc9459/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryWrapper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryWrapper.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryWrapper.java
index 4629dd0..ee31929 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryWrapper.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryWrapper.java
@@ -146,23 +146,30 @@ public class QueryWrapper {
       try {
         final int rows = result.getHeader().getRowCount();
         if (result.hasData()) {
-          final RecordBatchLoader loader = new RecordBatchLoader(allocator);
-          loader.load(result.getHeader().getDef(), result.getData());
-          // TODO:  Clean:  DRILL-2933:  That load(...) no longer throws
-          // SchemaChangeException, so check/clean catch clause below.
-          for (int i = 0; i < loader.getSchema().getFieldCount(); ++i) {
-            columns.add(loader.getSchema().getColumn(i).getPath().getAsUnescapedPath());
-          }
-          for (int i = 0; i < rows; ++i) {
-            final Map<String, String> record = Maps.newHashMap();
-            for (VectorWrapper<?> vw : loader) {
-              final String field = vw.getValueVector().getMetadata().getNamePart().getName();
-              final ValueVector.Accessor accessor = vw.getValueVector().getAccessor();
-              final Object value = i < accessor.getValueCount() ? accessor.getObject(i)
: null;
-              final String display = value == null ? null : value.toString();
-              record.put(field, display);
+          RecordBatchLoader loader = null;
+          try {
+            loader = new RecordBatchLoader(allocator);
+            loader.load(result.getHeader().getDef(), result.getData());
+            // TODO:  Clean:  DRILL-2933:  That load(...) no longer throws
+            // SchemaChangeException, so check/clean catch clause below.
+            for (int i = 0; i < loader.getSchema().getFieldCount(); ++i) {
+              columns.add(loader.getSchema().getColumn(i).getPath().getAsUnescapedPath());
+            }
+            for (int i = 0; i < rows; ++i) {
+              final Map<String, String> record = Maps.newHashMap();
+              for (VectorWrapper<?> vw : loader) {
+                final String field = vw.getValueVector().getMetadata().getNamePart().getName();
+                final ValueVector.Accessor accessor = vw.getValueVector().getAccessor();
+                final Object value = i < accessor.getValueCount() ? accessor.getObject(i)
: null;
+                final String display = value == null ? null : value.toString();
+                record.put(field, display);
+              }
+              results.add(record);
+            }
+          } finally {
+            if (loader != null) {
+              loader.clear();
             }
-            results.add(record);
           }
         }
       } catch (SchemaChangeException e) {


Mime
View raw message