drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-5230) Translation of millisecond duration into hours is incorrect
Date Fri, 03 Feb 2017 18:27:51 GMT

    [ https://issues.apache.org/jira/browse/DRILL-5230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15851874#comment-15851874
] 

ASF GitHub Bot commented on DRILL-5230:
---------------------------------------

Github user kkhatua commented on a diff in the pull request:

    https://github.com/apache/drill/pull/739#discussion_r99393776
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/TableBuilder.java
---
    @@ -56,6 +47,30 @@ public TableBuilder(final String[] columns) {
         sb.append("</tr>\n");
       }
     
    +  /**
    +   * Representation of a millisecond duration in a short readable text
    +   * @param millis  Duration in milliseconds
    +   * @return        Human-Readable Duration Time
    +   */
    +  public String shortDurationFormat(long millis) {
    +    long days = TimeUnit.MILLISECONDS.toDays(millis);
    +    long hours = TimeUnit.MILLISECONDS.toHours(millis) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(millis));
    +    long minutes = TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis));
    +    long seconds = TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis));
    +    long milliSeconds = millis - TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(millis));
    +    String formattedDuration = "";
    +    if (days >= 1) {
    +      formattedDuration = days + "d" + hours + "h" + minutes + "m";
    +    } else if (hours >= 1) {
    +      formattedDuration = hours + "h" + minutes + "m";
    +    } else if (minutes >= 1) {
    +      formattedDuration = minutes + "m" + seconds + "s";
    +    } else {
    +      formattedDuration = seconds + "." + milliSeconds + "s";
    --- End diff --
    
    Good catch. I'll update the test case as well and apply the String.format()


> Translation of millisecond duration into hours is incorrect
> -----------------------------------------------------------
>
>                 Key: DRILL-5230
>                 URL: https://issues.apache.org/jira/browse/DRILL-5230
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Web Server
>    Affects Versions: 1.9.0
>            Reporter: Kunal Khatua
>              Labels: easyfix
>             Fix For: 1.10.0
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> The method 
> {code:JAVA}org.apache.drill.exec.server.rest.profile.TableBuilder.appendMillis(long,
String){code}
> has a bug where the human readable translation of a 1+ hr duration in milliseconds is
reported incorrectly. 
> This has to do with the {code:JAVA}SimpleDateFormat.format() {code} method incorectly
translating it. 
> For e.g.
> {code:JAVA}
> long x = 4545342L; //1 hour 15 min 45.342 sec
> public void appendMillis(x, null);
> {code}
> This formats the value as {noformat}17h15m{noformat} instead of {noformat}1h15m{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message