drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From laurentgo <...@git.apache.org>
Subject [GitHub] drill pull request #1024: DRILL-3640: Support JDBC Statement.setQueryTimeout...
Date Wed, 08 Nov 2017 00:15:30 GMT
Github user laurentgo commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1024#discussion_r149542468
  
    --- Diff: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillCursor.java ---
    @@ -139,8 +147,22 @@ private boolean stopThrottlingIfSo() {
           return stopped;
         }
     
    -    public void awaitFirstMessage() throws InterruptedException {
    -      firstMessageReceived.await();
    +    public void awaitFirstMessage() throws InterruptedException, SQLTimeoutException
{
    +      //Check if a non-zero timeout has been set
    +      if ( parent.timeoutInMilliseconds > 0 ) {
    +        //Identifying remaining in milliseconds to maintain a granularity close to integer
value of timeout
    +        long timeToTimeout = (parent.timeoutInMilliseconds) - parent.elapsedTimer.elapsed(TimeUnit.MILLISECONDS);
    +        if ( timeToTimeout > 0 ) {
    --- End diff --
    
    maybe a style issue, but to avoid code duplication both conditions could be checked together?
    ```
    if ( timeToTimeout <= 0 || !firstMessageReceived.await(timeToTimeout, TimeUnit.MILLISECONDS)
) {
      throw new SqlTimeoutException(TimeUnit.MILLISECONDS.toSeconds(parent.timeoutInMilliseconds));
    }
    ```


---

Mime
View raw message