Mahout: java.lang.NumberFormatException: for input line:

I am trying to get mahout to work and I get the following error:

3/05/16 22:48:53 INFO mapred.MapTask: record buffer = 262144/327680 13/05/16 22:48:53 WARN mapred.LocalJobRunner: job_local_0001 java.lang.NumberFormatException: For input string: "1119" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Long.parseLong(Long.java:430) at java.lang.Long.parseLong(Long.java:483) at org.apache.mahout.cf.taste.hadoop.item.ItemIDIndexMapper.map(ItemIDIndexMapper.java:47) at org.apache.mahout.cf.taste.hadoop.item.ItemIDIndexMapper.map(ItemIDIndexMapper.java:31) at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370) at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:212) 13/05/16 22:48:54 INFO mapred.JobClient: map 0% reduce 0% 13/05/16 22:48:54 INFO mapred.JobClient: Job complete: job_local_0001 13/05/16 22:48:54 INFO mapred.JobClient: Counters: 0 Exception in thread "main" java.io.FileNotFoundException: File does not exist: /user/eric.waite/temp/preparePreferenceMatrix/numUsers.bin at org.apache.hadoop.hdfs.DFSClient$DFSInputStream.openInfo(DFSClient.java:1843) at org.apache.hadoop.hdfs.DFSClient$DFSInputStream.<init>(DFSClient.java:1834) at org.apache.hadoop.hdfs.DFSClient.open(DFSClient.java:578) 

My input file is very simple: (sample) userid, storyId, rating (1-5)

 2840281,1119,2 2840321,1170,3 2840323,1124,5 2840371,1170,5 2840347,1157,3 2840371,1172,5 2840347,1157,5 2840358,1333,5 2840371,1172,5 2840347,1157,5 

I am trying to run a basic example using the following command:

 hadoop jar /sourcecode/mahout/mahout-distribution-0.7/mahout-core-0.7-job.jar org.apache.mahout.cf.taste.hadoop.item.RecommenderJob -s SIMILARITY_COOCCURRENCE --input ratings.dat --output output 

Java Information:

java version "1.7.0_13" Java (TM) SE Runtime Environment (build 1.7.0_13-b20) Java HotSpot (TM) 64-bit server VM (build 23.7-b01, mixed mode) I am on mac 10.8 0.2

Does anyone have any suggestions on why an integer reads as a string and throws a NumberFormatException ?

Thanks.

+4
source share
2 answers

You probably have some kind of non-printing character. The line that it shows is, of course, perfectly parsed as long. (Quotation marks are only part of the error message.)

To understand what I mean, try

  System.out.println(Long.parseLong("\u00001119")); 

He fails with the same error that is puzzled.

Not sure how to debug this easily without a hex editor.

+1
source

You can debug the Recommendation and check where the exception occurs, and check the actual string value, possibly some kind of empty or useless character in the input file. I also have this exception, and my exception happens here:

 String[] tokens = TasteHadoopUtils.splitPrefTokens(value.toString()); long itemID = Long.parseLong(tokens[transpose ? 0 : 1]); 
0
source

Source: https://habr.com/ru/post/1481452/


All Articles