Example usage for org.apache.mahout.cf.taste.hadoop TasteHadoopUtils readIDIndexMap

List of usage examples for org.apache.mahout.cf.taste.hadoop TasteHadoopUtils readIDIndexMap

Introduction

In this page you can find the example usage for org.apache.mahout.cf.taste.hadoop TasteHadoopUtils readIDIndexMap.

Prototype

public static OpenIntLongHashMap readIDIndexMap(String idIndexPathStr, Configuration conf) 

Source Link

Document

Reads a binary mapping file

Usage

From source file:hadoop.api.AggregateAndRecommendReducer.java

License:Apache License

@Override
protected void setup(Context context) throws IOException {
    Configuration conf = context.getConfiguration();
    recommendationsPerUser = conf.getInt(NUM_RECOMMENDATIONS, DEFAULT_NUM_RECOMMENDATIONS);
    booleanData = conf.getBoolean(RecommenderJob.BOOLEAN_DATA, false);
    indexItemIDMap = TasteHadoopUtils.readIDIndexMap(conf.get(ITEMID_INDEX_PATH), conf);

    String itemFilePathString = conf.get(ITEMS_FILE);
    if (itemFilePathString != null) {
        itemsToRecommendFor = new FastIDSet();
        for (String line : new FileLineIterable(HadoopUtil.openStream(new Path(itemFilePathString), conf))) {
            try {
                itemsToRecommendFor.add(Long.parseLong(line));
            } catch (NumberFormatException nfe) {
                log.warn("itemsFile line ignored: {}", line);
            }/*w  ww .j  av  a2  s  . c  o  m*/
        }
    }
}