Examples of PairOfIntLong


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

    }

    assertEquals(6, list.size());

    Iterator<PairOfIntLong> iter = list.iterator();
    PairOfIntLong e = iter.next();
    assertEquals(1, e.getLeftElement());
    assertEquals(1, e.getRightElement());
    e = iter.next();
    assertEquals(2, e.getLeftElement());
    assertEquals(4, e.getRightElement());
    e = iter.next();
    assertEquals(3, e.getLeftElement());
    assertEquals(2, e.getRightElement());
    e = iter.next();
    assertEquals(4, e.getLeftElement());
    assertEquals(3, e.getRightElement());
    e = iter.next();
    assertEquals(5, e.getLeftElement());
    assertEquals(7, e.getRightElement());
    e = iter.next();
    assertEquals(6, e.getLeftElement());
    assertEquals(9, e.getRightElement());
  }
View Full Code Here

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

   */
  public Iterator<PairOfIntLong> iterator() {
    return new Iterator<PairOfIntLong>() {
      private Iterator<MapIL.Entry> iter =
        Int2LongFrequencyDistributionEntry.this.counts.entrySet().iterator();
      private final PairOfIntLong pair = new PairOfIntLong();

      @Override
      public boolean hasNext() {
        return iter.hasNext();
      }

      @Override
      public PairOfIntLong next() {
        if (!hasNext()) {
          return null;
        }

        MapIL.Entry entry = iter.next();
        pair.set(entry.getKey(), entry.getValue());
        return pair;
      }

      @Override
      public void remove() {
View Full Code Here

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

  private List<PairOfIntLong> getEntriesSorted(Comparator<PairOfIntLong> comparator) {
    List<PairOfIntLong> list = Lists.newArrayList();

    for (MapIL.Entry e : counts.entrySet()) {
      list.add(new PairOfIntLong(e.getKey(), e.getValue()));
    }

    Collections.sort(list, comparator);
    return list;
  }
View Full Code Here

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

   */
  public Iterator<PairOfIntLong> iterator() {
    return new Iterator<PairOfIntLong>() {
      private Iterator<Int2LongMap.Entry> iter =
        Int2LongFrequencyDistributionFastutil.this.counts.int2LongEntrySet().iterator();
      private final PairOfIntLong pair = new PairOfIntLong();

      @Override
      public boolean hasNext() {
        return iter.hasNext();
      }

      @Override
      public PairOfIntLong next() {
        if (!hasNext()) {
          return null;
        }

        Int2LongMap.Entry entry = iter.next();
        pair.set(entry.getIntKey(), entry.getLongValue());
        return pair;
      }

      @Override
      public void remove() {
View Full Code Here

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

  private List<PairOfIntLong> getEntriesSorted(Comparator<PairOfIntLong> comparator) {
    List<PairOfIntLong> list = Lists.newArrayList();

    for (Int2LongMap.Entry e : counts.int2LongEntrySet()) {
      list.add(new PairOfIntLong(e.getIntKey(), e.getLongValue()));
    }

    Collections.sort(list, comparator);
    return list;
  }
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

    @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
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.