Examples of PairOfIntLong


Examples of edu.umd.cloud9.io.pair.PairOfIntLong

    @Override
    public void reduce(Text key, Iterable<PairOfIntLong> values, Context context)
        throws IOException, InterruptedException {
      String term = key.toString();
      Iterator<PairOfIntLong> iter = values.iterator();
      PairOfIntLong p = iter.next();
      int df = p.getLeftElement();
      long cf = p.getRightElement();
      WritableUtils.writeVInt(dfByTermOut, df);
      WritableUtils.writeVLong(cfByTermOut, cf);
      if (iter.hasNext()) {
        throw new RuntimeException("More than one record for term: " + term);
      }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

      // map from the id back to text
      // sLogger.info("termid: " + key);
      String term = mTermIdMap.getTerm(key.get());
      // sLogger.info("term: " + term);
      PairOfIntLong pair = gs.getStats(term);

      if (pair == null) {
        p.setCf(-1);
        p.setDf(-1);
      } else {
        p.setCf(pair.getRightElement());
        p.setDf(pair.getLeftElement());
      }

      output.collect(key, p);
    }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

      int df = 0;
      long cf = 0;

      while (values.hasNext()) {
        PairOfIntLong p = values.next();
        df += p.getLeftElement();
        cf += p.getRightElement();
      }

      sLogger.info(key + " " + df + " " + cf);

      if (curKeyIndex % window == 0) {
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

    @Override
    public void reduce(Text key, Iterable<PairOfIntLong> values, Context context)
        throws IOException, InterruptedException {
      String term = key.toString();
      Iterator<PairOfIntLong> iter = values.iterator();
      PairOfIntLong p = iter.next();
      int df = p.getLeftElement();
      long cf = p.getRightElement();
      WritableUtils.writeVInt(dfByTermOut, df);
      WritableUtils.writeVLong(cfByTermOut, cf);

      if (iter.hasNext()) {
        throw new RuntimeException("More than one record for term: " + term);
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

  public PairOfIntLong getStats(String term) {
    int index = prefixSet.getId(term);
    LOG.info("index of " + term + ": " + index);
    if (index < 0)
      return null;
    PairOfIntLong p = new PairOfIntLong();
    p.set(df[index], cf[index]);
    return p;
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

  }
 
  public PairOfIntLong getStats(int index) {
    if (index < 0)
      return null;
    PairOfIntLong p = new PairOfIntLong();
    p.set(df[index], cf[index]);
    return p;
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

public class PairOfIntLongTest {

  @Test
  public void testBasic() throws IOException {
    PairOfIntLong pair = new PairOfIntLong(1, 2L);

    assertEquals(1L, pair.getLeftElement());
    assertEquals(2L, pair.getRightElement());
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

    assertEquals(2L, pair.getRightElement());
  }

  @Test
  public void testSerialize() throws IOException {
    PairOfIntLong origPair = new PairOfIntLong(1, 2L);

    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    DataOutputStream dataOut = new DataOutputStream(bytesOut);

    origPair.write(dataOut);

    PairOfIntLong pair = new PairOfIntLong();

    pair.readFields(new DataInputStream(new ByteArrayInputStream(bytesOut.toByteArray())));

    assertEquals(1L, pair.getLeftElement());
    assertEquals(2L, pair.getRightElement());
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

    assertEquals(2L, pair.getRightElement());
  }

  @Test
  public void testComparison1() throws IOException {
    PairOfIntLong pair1 = new PairOfIntLong(1, 2L);
    PairOfIntLong pair2 = new PairOfIntLong(1, 2L);
    PairOfIntLong pair3 = new PairOfIntLong(1, 1L);
    PairOfIntLong pair4 = new PairOfIntLong(0, 9L);
    PairOfIntLong pair5 = new PairOfIntLong(9, 0L);

    assertTrue(pair1.equals(pair2));
    assertFalse(pair1.equals(pair3));

    assertTrue(pair1.compareTo(pair2) == 0);
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntLong

  @Test
  public void testComparison2() throws IOException {
    WritableComparator comparator = new PairOfIntLong.Comparator();

    PairOfIntLong pair1 = new PairOfIntLong(1, 2L);
    PairOfIntLong pair2 = new PairOfIntLong(1, 2L);
    PairOfIntLong pair3 = new PairOfIntLong(1, 1L);
    PairOfIntLong pair4 = new PairOfIntLong(0, 9L);
    PairOfIntLong pair5 = new PairOfIntLong(9, 0L);

    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair2) == 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair3) > 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair4) > 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair5) < 0);
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.