Hi All,
I am trying to find the solution to avoid conversion of double value in scientific notation.
e.g. 7536546814678.12 to 7.53654681467812E12
Note: If double value is less thant 10^-3 or greateer than 10^7 then only it gets converted to scientific notation.
//Code
Fields inputFields = new Fields("double_val").applyTypes(Double.class);
Scheme inputScheme = new TextDelimited(inputFields,true,",");
Tap inTap = new Hfs(inputScheme,inputPath,SinkMode.REPLACE);
Pipe mainPipe = new Pipe("main");
Scheme outputScheme = new TextDelimited(inputFields,true,",");
Tap outTap = new Hfs(outputScheme,outputPath,SinkMode.REPLACE);
FlowDef flowDef = FlowDef.flowDef();
flowDef.setName("Project2");
flowDef.addSource(mainPipe, inTap);
flowDef.addTailSink(mainPipe, outTap);
Flow wcFlow = flowConnector.connect(flowDef);
wcFlow.complete();
//
Input File:
double_val
7536546814678.12
76748.76
Actual Output:
double_val
7.53654681467812E12
76748.76
Expected Output:
7536546814678.12
76748.76
Observations:
public Double coerce( Object value ) method from cascading.tuple.coerce.DoubleObjectCoerce class executes:
Double.parseDouble( value.toString() ) which results in conversion of double values.
Could you please let me know if there is any workaround for this?
Regards,
Shrikant Dange