drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arina-ielchiieva <...@git.apache.org>
Subject [GitHub] drill pull request #610: DRILL-4674: Allow casting to boolean the same liter...
Date Wed, 02 Nov 2016 10:41:55 GMT
Github user arina-ielchiieva commented on a diff in the pull request:

    https://github.com/apache/drill/pull/610#discussion_r86103902
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleCastFunctions.java
---
    @@ -48,14 +46,8 @@ public void setup() {
         public void eval() {
           byte[] buf = new byte[in.end - in.start];
           in.buffer.getBytes(in.start, buf, 0, in.end - in.start);
    -      String input = new String(buf, com.google.common.base.Charsets.UTF_8).toLowerCase();
    -      if ("true".equals(input)) {
    -        out.value = 1;
    -      } else if ("false".equals(input)) {
    -        out.value = 0;
    -      } else {
    -        throw new IllegalArgumentException("Invalid value for boolean: " + input);
    -      }
    +      String input = new String(buf, com.google.common.base.Charsets.UTF_8);
    +      out.value = org.apache.drill.exec.expr.BooleanType.get(input).getNumericValue();
    --- End diff --
    
    @sudheeshkatkam 
    I can't make static `Map<String, Integer>`, since sometimes we need numeric representation
and sometimes bytes. But you are right iteration through the list per each record is too expensive.
So I have added static `Map<String, BooleanType>`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message