drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [01/13] drill git commit: DRILL-4134: Clean up close behaviors.
Date Tue, 22 Dec 2015 15:06:24 GMT
Repository: drill
Updated Branches:
  refs/heads/master abdfc6a96 -> 809f4620d


DRILL-4134: Clean up close behaviors.


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

Branch: refs/heads/master
Commit: a466e4bd4d31520d69a490bbfd2eff1936e217f4
Parents: abdfc6a
Author: Chris Westin <cwestin@yahoo.com>
Authored: Wed Nov 11 14:57:16 2015 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Mon Dec 21 23:52:22 2015 -0800

----------------------------------------------------------------------
 .../physical/impl/union/UnionAllRecordBatch.java   | 14 ++++++++++++--
 .../exec/record/RawFragmentBatchProvider.java      |  3 +++
 .../apache/drill/exec/record/WritableBatch.java    | 17 +++++++++--------
 .../exec/work/batch/AbstractDataCollector.java     | 16 +++++-----------
 4 files changed, 29 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/a466e4bd/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java
index 51d74cc..0d47a57 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java
@@ -84,6 +84,14 @@ public class UnionAllRecordBatch extends AbstractRecordBatch<UnionAll>
{
   }
 
   @Override
+  public void kill(boolean sendUpstream) {
+    if(current != null) {
+      current.kill(sendUpstream);
+      current = null;
+    }
+  }
+
+  @Override
   protected void killIncoming(boolean sendUpstream) {
     unionAllInput.getLeftRecordBatch().kill(sendUpstream);
     unionAllInput.getRightRecordBatch().kill(sendUpstream);
@@ -270,8 +278,10 @@ public class UnionAllRecordBatch extends AbstractRecordBatch<UnionAll>
{
 
   // This method is used by inner class to clear the current record batch
   private void clearCurrentRecordBatch() {
-    for(VectorWrapper<?> v: current) {
-      v.clear();
+    if (current != null) {
+      for(final VectorWrapper<?> v: current) {
+        v.clear();
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/a466e4bd/exec/java-exec/src/main/java/org/apache/drill/exec/record/RawFragmentBatchProvider.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/record/RawFragmentBatchProvider.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/record/RawFragmentBatchProvider.java
index 14db502..7a0be5e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/record/RawFragmentBatchProvider.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/record/RawFragmentBatchProvider.java
@@ -25,4 +25,7 @@ public interface RawFragmentBatchProvider extends AutoCloseable{
 
   public RawFragmentBatch getNext() throws IOException, InterruptedException;
   public void kill(FragmentContext context);
+
+  @Override
+  public void close(); // Suppress the "throws Exception".
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a466e4bd/exec/java-exec/src/main/java/org/apache/drill/exec/record/WritableBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/record/WritableBatch.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/record/WritableBatch.java
index 324829a..488ba69 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/record/WritableBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/record/WritableBatch.java
@@ -32,8 +32,8 @@ import com.google.common.collect.Lists;
 /**
  * A specialized version of record batch that can moves out buffers and preps them for writing.
  */
-public class WritableBatch {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(WritableBatch.class);
+public class WritableBatch implements AutoCloseable {
+  //private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(WritableBatch.class);
 
   private final RecordBatchDef def;
   private final DrillBuf[] buffers;
@@ -170,15 +170,16 @@ public class WritableBatch {
     return getBatchNoHVWrap(batch.getRecordCount(), batch, sv2);
   }
 
-  public void retainBuffers() {
-    for (DrillBuf buf : buffers) {
-      buf.retain();
+  public void retainBuffers(final int increment) {
+    for (final DrillBuf buf : buffers) {
+      buf.retain(increment);
     }
   }
 
-  public void retainBuffers(int increment) {
-    for (DrillBuf buf : buffers) {
-      buf.retain(increment);
+  @Override
+  public void close() {
+    for(final DrillBuf drillBuf : buffers) {
+      drillBuf.release(1);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/a466e4bd/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
index 3f2e3f2..1579c2b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
@@ -71,18 +71,12 @@ public abstract class AbstractDataCollector implements DataCollector{
 
     final boolean spooling = collector.getIsSpooling();
 
-    try {
-
-      for (int i = 0; i < numBuffers; i++) {
-        if (spooling) {
-          buffers[i] = new SpoolingRawBatchBuffer(context, bufferCapacity, collector.getOppositeMajorFragmentId(),
i);
-        } else {
-          buffers[i] = new UnlimitedRawBatchBuffer(context, bufferCapacity, collector.getOppositeMajorFragmentId());
-        }
+    for (int i = 0; i < numBuffers; i++) {
+      if (spooling) {
+        buffers[i] = new SpoolingRawBatchBuffer(context, bufferCapacity, collector.getOppositeMajorFragmentId(),
i);
+      } else {
+        buffers[i] = new UnlimitedRawBatchBuffer(context, bufferCapacity, collector.getOppositeMajorFragmentId());
       }
-    } catch (IOException | OutOfMemoryException e) {
-      logger.error("Exception", e);
-      context.fail(e);
     }
   }
 


Mime
View raw message