Github user daveoshinsky commented on a diff in the pull request:
https://github.com/apache/drill/pull/517#discussion_r70493981
--- Diff:
exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java ---
@@ -64,7 +64,15 @@ public void setup() {
public void eval() {
out.scale = (int) scale.value;
- out.precision = (int) precision.value;
--- End diff --
I tried doing it in the setup method, and it did not work. It seems the
integer value to be casted was not available at that time. Â Since the number
of divisions by 10 (these are cheap integer divisions) is proportional to
log10(the integer number), I don't see how this is expensive, especially
compared to the expense of reading the rows from whatever device.
On Tuesday, July 12, 2016 1:56 PM, Aman Sinha
<[email protected]> wrote:
In exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java:>
@@ -64,7 +64,15 @@ public void setup() {
>
> public void eval() {
> out.scale = (int) scale.value;
> - out.precision = (int) precision.value;
The eval() method is called for every row, so there will be a performance
overhead. I agree about the storage cost if we assume worst case precision;
however the per-row evaluation should be as lightweight as possible and likely
outweighs the storage consideration. One option is to treat the IntDecimal and
BigIntDecimal separately. For IntDecimal the max int value is 2^31 - 1 which
has a max precision of 10. Similarly, there is an upper bound on the
BigIntDecimal. You could initialize the precision in the setup() method which
is called once per new schema (in the normal case the schema of that column
does not change, this would avoid unnecessarily computing the precision). â
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
---
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.
---