Examples of VarLongWritable


Examples of org.apache.mahout.math.VarLongWritable

  protected void map(LongWritable key,
                     Text value,
                     Context context) throws IOException, InterruptedException {
    String[] tokens = DELIMITER.split(value.toString());
    long userID = Long.parseLong(tokens[0]);
    context.write(new VarLongWritable(userID), NullWritable.get());
  }
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

  @Test
  public void testItemIDIndexMapper() throws Exception {
    Mapper<LongWritable,Text, VarIntWritable, VarLongWritable>.Context context =
      EasyMock.createMock(Mapper.Context.class);

    context.write(new VarIntWritable(TasteHadoopUtils.idToIndex(789L)), new VarLongWritable(789L));
    EasyMock.replay(context);

    new ItemIDIndexMapper().map(new LongWritable(123L), new Text("456,789,5.0"), context);

    EasyMock.verify(context);
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

  @Test
  public void testItemIDIndexReducer() throws Exception {
    Reducer<VarIntWritable, VarLongWritable, VarIntWritable,VarLongWritable>.Context context =
      EasyMock.createMock(Reducer.Context.class);

    context.write(new VarIntWritable(123), new VarLongWritable(45L));
    EasyMock.replay(context);

    new ItemIDIndexReducer().reduce(new VarIntWritable(123), Arrays.asList(new VarLongWritable(67L),
        new VarLongWritable(89L), new VarLongWritable(45L)), context);

    EasyMock.verify(context);
  }
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

  @Test
  public void testToItemPrefsMapper() throws Exception {
    Mapper<LongWritable,Text, VarLongWritable,VarLongWritable>.Context context =
      EasyMock.createMock(Mapper.Context.class);

    context.write(new VarLongWritable(12L), new EntityPrefWritable(34L, 1.0f));
    context.write(new VarLongWritable(56L), new EntityPrefWritable(78L, 2.0f));
    EasyMock.replay(context);

    ToItemPrefsMapper mapper = new ToItemPrefsMapper();
    mapper.map(new LongWritable(123L), new Text("12,34,1"), context);
    mapper.map(new LongWritable(456L), new Text("56,78,2"), context);
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

  @Test
  public void testToItemPrefsMapperBooleanData() throws Exception {
    Mapper<LongWritable,Text, VarLongWritable,VarLongWritable>.Context context =
      EasyMock.createMock(Mapper.Context.class);

    context.write(new VarLongWritable(12L), new VarLongWritable(34L));
    context.write(new VarLongWritable(56L), new VarLongWritable(78L));
    EasyMock.replay(context);

    ToItemPrefsMapper mapper = new ToItemPrefsMapper();
    setField(mapper, "booleanData", true);
    mapper.map(new LongWritable(123L), new Text("12,34"), context);
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

      EasyMock.createMock(Reducer.Context.class);
    Counter userCounters = EasyMock.createMock(Counter.class);

    EasyMock.expect(context.getCounter(ToUserVectorsReducer.Counters.USERS)).andReturn(userCounters);
    userCounters.increment(1);
    context.write(EasyMock.eq(new VarLongWritable(12L)), MathHelper.vectorMatches(
        MathHelper.elem(TasteHadoopUtils.idToIndex(34L), 1.0), MathHelper.elem(TasteHadoopUtils.idToIndex(56L), 2.0)));

    EasyMock.replay(context, userCounters);

    Collection<VarLongWritable> varLongWritables = Lists.newLinkedList();
    varLongWritables.add(new EntityPrefWritable(34L, 1.0f));
    varLongWritables.add(new EntityPrefWritable(56L, 2.0f));

    new ToUserVectorsReducer().reduce(new VarLongWritable(12L), varLongWritables, context);

    EasyMock.verify(context, userCounters);
  }
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

      EasyMock.createMock(Reducer.Context.class);
    Counter userCounters = EasyMock.createMock(Counter.class);

    EasyMock.expect(context.getCounter(ToUserVectorsReducer.Counters.USERS)).andReturn(userCounters);
    userCounters.increment(1);
    context.write(EasyMock.eq(new VarLongWritable(12L)), MathHelper.vectorMatches(
        MathHelper.elem(TasteHadoopUtils.idToIndex(34L), 1.0), MathHelper.elem(TasteHadoopUtils.idToIndex(56L), 1.0)));

    EasyMock.replay(context, userCounters);

    new ToUserVectorsReducer().reduce(new VarLongWritable(12L), Arrays.asList(new VarLongWritable(34L),
        new VarLongWritable(56L)), context);

    EasyMock.verify(context, userCounters);
  }
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

    RandomAccessSparseVector vector = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
    vector.set(34, 0.5);
    vector.set(56, 0.7);

    mapper.map(new VarLongWritable(123L), new VectorWritable(vector), context);

    EasyMock.verify(context);
  }
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

    RandomAccessSparseVector vector = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
    vector.set(34, 0.5);
    vector.set(56, 0.7);

    mapper.map(new VarLongWritable(123L), new VectorWritable(vector), context);
    mapper.map(new VarLongWritable(456L), new VectorWritable(vector), context);

    EasyMock.verify(context);
  }
View Full Code Here

Examples of org.apache.mahout.math.VarLongWritable

    RandomAccessSparseVector vector = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
    vector.set(34, 0.5);
    vector.set(56, 0.7);

    mapper.map(new VarLongWritable(123L), new VectorWritable(vector), context);

    EasyMock.verify(context);
  }
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.