赞
踩
在使用pyspark运行Spark ALS算法时,发生以下问题:
java.lang.IllegalArgumentException: ALS only supports values in Integer range and without fractional part for columns userId and softId. Value 13466056057 was either out of Integer range or contained a fractional part that could not be converted.
输出信息提示,13466056057
超出Integer类型范围,或者是一个小数。很明显,13466056057
不是一个小数,那就是说超出了Integer类型范围。
Java Integer取值范围是:[-2147483648, 2147483647]
获取方式:Integer.MAX_VALUE
和 Integer.MIN_VALUE
这个是数据ETL逻辑缺陷导致的,ETL逻辑是用Python写的,增加符合Java Integer类型的合法性检查即可。而对于现有的ETL之后的数据进行一次清理,将不合法的记录删除,重新运行任务。
经过测试,在Python中,int类型的数据貌似是没有范围限制的,这个以前倒是没有注意过。
另外sys.maxsize
是系统的整数最大值,64位系统中,输出如下:
>>> import sys
>>> print(sys.maxsize)
9223372036854775807
实测Python int转换:
>>> print(int('92233720368547758070'))
92233720368547758070
>>> print(int('922337203685477580700'))
922337203685477580700
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。