[ https://issues.apache.org/jira/browse/MAHOUT-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851789#action_12851789 ]
Hui Wen Han commented on MAHOUT-353: ------------------------------------ org.apache.mahout.cf.taste.impl.common.Cache private V getAndCacheValue(K key) throws TasteException { V value = retriever.get(key); //we may get null here,if so ,we can not put the value to cache (FastMap). synchronized (cache) { cache.put(key, value); } return value; } because in UserVectorToCooccurrenceReducer: line49: while (cooccurrences.hasNext()) { Vector.Element element = cooccurrences.next(); if (element.get() <= 1.0) { // purge small values element.set(0.0); //here we set element to zero } } in RecommenderMapper: line 103: Iterator<Vector.Element> userVectorIterator = userVector.iterateNonZero(); //here not get Zero item Vector recommendationVector = new RandomAccessSparseVector(Integer.MAX_VALUE, 1000); while (userVectorIterator.hasNext()) { Vector.Element element = userVectorIterator.next(); int index = element.index(); double value = element.get(); Vector columnVector; try { columnVector = cooccurrenceColumnCache.get(new IntWritable(index)); //here may get null so we need : in org.apache.mahout.cf.taste.impl.common.Cache private V getAndCacheValue(K key) throws TasteException { V value = retriever.get(key); //we may get null here,if so ,we can not put the value to cache (FastMap). if (value == null) { return null; } synchronized (cache) { cache.put(key, value); } return value; } in RecommenderMapper: while (userVectorIterator.hasNext()) { Vector.Element element = userVectorIterator.next(); int index = element.index(); double value = element.get(); Vector columnVector; try { columnVector = cooccurrenceColumnCache.get(new IntWritable(index)); } catch (TasteException te) { if (te.getCause() instanceof IOException) { throw (IOException) te.getCause(); } else { throw new IOException(te.getCause()); } } if (columnVector !=null) { columnVector.times(value).addTo(recommendationVector); } } > java.lang.NullPointerException in RecommenderMapper > --------------------------------------------------- > > Key: MAHOUT-353 > URL: https://issues.apache.org/jira/browse/MAHOUT-353 > Project: Mahout > Issue Type: Bug > Components: Collaborative Filtering > Affects Versions: 0.4 > Reporter: Hui Wen Han > Fix For: 0.4 > > > java.lang.NullPointerException > at > org.apache.mahout.cf.taste.hadoop.item.RecommenderMapper$CooccurrenceCache.get(RecommenderMapper.java:169) > at > org.apache.mahout.cf.taste.hadoop.item.RecommenderMapper$CooccurrenceCache.get(RecommenderMapper.java:154) > at > org.apache.mahout.cf.taste.impl.common.Cache.getAndCacheValue(Cache.java:125) > at org.apache.mahout.cf.taste.impl.common.Cache.get(Cache.java:94) > at > org.apache.mahout.cf.taste.hadoop.item.RecommenderMapper.map(RecommenderMapper.java:111) > at > org.apache.mahout.cf.taste.hadoop.item.RecommenderMapper.map(RecommenderMapper.java:52) > at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:50) > at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:358) > at org.apache.hadoop.mapred.MapTask.run(MapTask.java:307) > at org.apache.hadoop.mapred.Child.main(Child.java:170) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.