DRILL-3761: Modify CastIntDecimal implementation so that it will not modify its 
input holder.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/80e7e61a
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/80e7e61a
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/80e7e61a

Branch: refs/heads/master
Commit: 80e7e61aa1396c0e424b42507cbf49c6b3546876
Parents: 48bc0b9
Author: Jinfeng Ni <[email protected]>
Authored: Fri Aug 28 16:50:21 2015 -0700
Committer: Jinfeng Ni <[email protected]>
Committed: Tue Sep 15 16:24:37 2015 -0700

----------------------------------------------------------------------
 .../src/main/codegen/templates/Decimal/CastIntDecimal.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/80e7e61a/exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java 
b/exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java
index 2393db8..6d727b0 100644
--- a/exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java
+++ b/exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java
@@ -90,9 +90,10 @@ public class Cast${type.from}${type.to} implements 
DrillSimpleFunc {
         int scaleSize = 
org.apache.drill.exec.util.DecimalUtility.roundUp((int) scale.value);
         int integerIndex = (${type.arraySize} - scaleSize - 1);
 
-        while (in.value != 0 && integerIndex >= 0) {
-            out.setInteger(integerIndex--, (int) Math.abs((in.value % 
org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE)), out.start, out.buffer);
-            in.value = in.value / 
org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE;
+        long inValue = in.value;
+        while (inValue != 0 && integerIndex >= 0) {
+            out.setInteger(integerIndex--, (int) Math.abs((inValue % 
org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE)), out.start, out.buffer);
+            inValue = inValue / 
org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE;
         }
 
         </#if>

Reply via email to