Github user sudheeshkatkam commented on a diff in the pull request:
https://github.com/apache/drill/pull/610#discussion_r85990420
--- 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 --
This \#get call is invoked per record.
How about storing a mapping (static `Map<String, Integer>`) in BooleanType,
rather than iterate through a list?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---