直接运行Hadoop-0.20.2的PiEstimator.java的话,会报"java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result." 的错误,原因是算出的Pi值没有设定小数位数(Pi是无理数)。
解决方法:
1、去https://issues.apache.org/jira/browse/MAPREDUCE-1880下载m1880_20100619_0.20.patch。
2、为hadoop-0.20.2打上这个补丁
[root@master:/opt/hadoop-0.20.2]# patch -p0 < ../hadoopPatch/m1880_20100619_0.20.patch
3、修改$HADOOP_HOME/build.xml
将line904和line908的两句注释掉,修改成如下所示:
<target name="forrest.check" unless="forrest.home" depends="java5.check">
<!--fail message="'forrest.home' is not defined. Please pass -Dforrest.home=<base of Apache Forrest installation> to Ant on the command-line." /-->
</target>
<target name="java5.check" unless="java5.home">
<!--fail message="'java5.home' is not defined. Forrest requires Java 5. Please pass -Djava5.home=<base of Java 5 distribution> to Ant on the command-line." /-->
</target>
4、重新build
本文详细介绍了如何解决在直接运行Hadoop-0.20.2的PiEstimator.java时遇到的java.lang.ArithmeticException:Non-terminating decimal expansion; no exact representable decimal result.错误。通过下载并应用补丁、修改build.xml文件、重新构建和替换jar文件等步骤,最终成功解决了Pi值计算的问题。
2275

被折叠的 条评论
为什么被折叠?



