You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2018/07/13 03:45:12 UTC

[GitHub] sohami closed pull request #1360: DRILL-6578: Handle query cancellation in Parquet reader

sohami closed pull request #1360: DRILL-6578: Handle query cancellation in Parquet reader
URL: https://github.com/apache/drill/pull/1360
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java b/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java
index 98b1a9d0302..b6ced84d0aa 100644
--- a/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java
+++ b/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java
@@ -48,4 +48,22 @@ public static void format(String format, Object...args) {
   public static void format(Throwable cause, String format, Object...args) {
     throw new DrillRuntimeException(String.format(format, args), cause);
   }
+
+  /**
+   * This method can be called within loops to check whether the current thread has been
+   * interrupted; it ensures that operator implementation can respond to query cancellation
+   * in a timely manner.
+   *
+   * <p>Calling this method will result in the following behavior:
+   * <ul>
+   * <li>Throws a runtime exception if current thread interrupt flag has been set
+   * <li>Clears current thread interrupt flag
+   * </ul>
+   */
+  public static void checkInterrupted() {
+    if (Thread.interrupted()) {
+      // This exception will ensure the control layer will immediately get back control
+      throw new DrillRuntimeException("Interrupt received; aborting current operation");
+    }
+  }
 }
diff --git a/exec/vector/src/main/codegen/templates/VariableLengthVectors.java b/exec/vector/src/main/codegen/templates/VariableLengthVectors.java
index c35728ec2c6..8dd8eb19aae 100644
--- a/exec/vector/src/main/codegen/templates/VariableLengthVectors.java
+++ b/exec/vector/src/main/codegen/templates/VariableLengthVectors.java
@@ -19,7 +19,7 @@
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.util.Set;
-
+import org.apache.drill.common.exceptions.DrillRuntimeException;
 import org.apache.drill.exec.exception.OutOfMemoryException;
 import org.apache.drill.exec.memory.AllocationManager.BufferLedger;
 import org.apache.drill.exec.vector.BaseDataValueVector;
@@ -641,6 +641,8 @@ public void setSafe(int index, byte[] bytes) {
         if (callback != null) {
           callback.onNewBulkEntry(entry);
         }
+
+        DrillRuntimeException.checkInterrupted(); // Ensures fast handling of query cancellation
       }
 
       // Flush any data not yet copied to this VL container


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services