Examples of VarIntWritable


Examples of org.apache.mahout.math.VarIntWritable

                     Text value,
                     Context context) throws IOException, InterruptedException {
    String line = value.toString();
    Matcher m = NUMBERS.matcher(line);
    m.find();
    VarIntWritable index = new VarIntWritable();
    VarLongWritable itemID = new VarLongWritable();
    while (m.find()) {
      long item = Long.parseLong(m.group());
      itemID.set(item);
      index.set(idToIndex(item));
      context.write(index, itemID);
    }
  }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

    try {
      Path unqualifiedItemIDIndexPath = new Path(itemIDIndexPathStr);
      FileSystem fs = FileSystem.get(unqualifiedItemIDIndexPath.toUri(), conf);
      Path itemIDIndexPath = new Path(itemIDIndexPathStr).makeQualified(fs);

      VarIntWritable index = new VarIntWritable();
      VarLongWritable id = new VarLongWritable();
      for (FileStatus status : fs.listStatus(itemIDIndexPath, PARTS_FILTER)) {
        String path = status.getPath().toString();
        SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(path).makeQualified(fs), conf);
        while (reader.next(index, id)) {
          indexItemIDMap.put(index.get(), id.get());
        }
        reader.close();
      }
    } catch (IOException ioe) {
      throw new IllegalStateException(ioe);
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

    if (usersToRecommendFor != null && !usersToRecommendFor.contains(userID)) {
      return;
    }
    Vector userVector = maybePruneUserVector(value.get());
    Iterator<Vector.Element> it = userVector.iterateNonZero();
    VarIntWritable itemIndexWritable = new VarIntWritable();
    VectorOrPrefWritable vectorOrPref = new VectorOrPrefWritable();
    while (it.hasNext()) {
      Vector.Element e = it.next();
      itemIndexWritable.set(e.index());
      vectorOrPref.set(userID, (float) e.get());
      context.write(itemIndexWritable, vectorOrPref);
    }
  }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

      if (currentUserID > lastSeenUserID) {
        lastSeenUserID = currentUserID;
        numberOfUsers++;
      }
    }
    context.write(new VarIntWritable(numberOfUsers), NullWritable.get());
  }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

   */
  @Test
  public void testCountUsersReducer() throws Exception {
    Reducer<CountUsersKeyWritable,VarLongWritable,VarIntWritable,NullWritable>.Context context =
        EasyMock.createMock(Reducer.Context.class);
    context.write(new VarIntWritable(3), NullWritable.get());
    EasyMock.replay(context);

    List<VarLongWritable> userIDs = Arrays.asList(new VarLongWritable(1L), new VarLongWritable(1L),
                                                  new VarLongWritable(3L), new VarLongWritable(5L),
                                                  new VarLongWritable(5L), new VarLongWritable(5L));
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

    for (VarLongWritable userID : values) {
      userIDs.add(userID.get());
      prefValues.add(1.0f);
    }

    ctx.write(new VarIntWritable(itemIDIndex), new VectorAndPrefsWritable(vector, userIDs, prefValues));
  }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

                     Text value,
                     Context context) throws IOException, InterruptedException {
    String[] tokens = TasteHadoopUtils.splitPrefTokens(value.toString());
    long itemID = Long.parseLong(tokens[transpose ? 0 : 1]);
    int index = TasteHadoopUtils.idToIndex(itemID);
    context.write(new VarIntWritable(index), new VarLongWritable(itemID));
 
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

                     VectorWritable value,
                     Context context) throws IOException, InterruptedException {
    Vector similarityMatrixRow = value.get();
    /* remove self similarity */
    similarityMatrixRow.set(key.get(), Double.NaN);
    context.write(new VarIntWritable(key.get()), new VectorOrPrefWritable(similarityMatrixRow));
  }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

      idx = keyStr.lastIndexOf('/', idx);
      String msgId = keyStr.substring(idx + 1);
      if (EmailUtility.WHITESPACE.matcher(msgId).matches()) {
        context.getCounter(EmailUtility.Counters.NO_MESSAGE_ID).increment(1);
      } else {
        context.write(new Text(msgId), new VarIntWritable(1));
      }
    }
  }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

      Iterator<Vector.Element> elementsIterator = v.iterateNonZero();
      while (elementsIterator.hasNext()) {
        Vector.Element element = elementsIterator.next();
        int column = element.index();
        double value = element.get();
        ctx.write(new VarIntWritable(column), new WeightedOccurrence(row.get(), value, weight));
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.