Skip to content
Permalink
Browse files
DRILL-6578: Handle query cancellation in Parquet reader
closes #1360
  • Loading branch information
sachouche authored and sohami committed Jul 12, 2018
1 parent c644367 commit cfe61eb9b6ed4d636a26c76dbd12df26f38ba672
Showing 2 changed files with 21 additions and 1 deletion.
@@ -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");
}
}
}
@@ -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 <T extends VarLenBulkEntry> void setSafe(VarLenBulkInput<T> input, VarLen
if (callback != null) {
callback.onNewBulkEntry(entry);
}

DrillRuntimeException.checkInterrupted(); // Ensures fast handling of query cancellation
}

// Flush any data not yet copied to this VL container

0 comments on commit cfe61eb

Please sign in to comment.