Package edu.umd.cloud9.io.pair

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


    @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

  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

  }
 
  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

    @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

      // 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

  }

  public PairOfIntLong getStats(String term) {
    int df = -1;
    long cf = -1;
    PairOfIntLong p = new PairOfIntLong();
    if(frequentTermsDfs != null){
      try{
        df = frequentTermsDfs.get(term);
        LOGGER.info("[cached] df of "+term+": "+df);
        if(frequentTermsCfs != null){
          try{
            cf = frequentTermsCfs.get(term);
            LOGGER.info("[cached] cf of "+term+": "+cf);
            p.set(df, cf);
            return p;
          }catch (NoSuchElementException e){
          }
        }
      }catch (NoSuchElementException e){
      }
    }
    int index = prefixSet.getId(term);
    LOGGER.info("index of " + term + ": " + index);
    if (index < 0)
      return null;
    p.set(dfs[index], cfs[index]);
    return p;
  }
View Full Code Here

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

      int df = 0;
      long cf = 0;

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

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

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

    @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

TOP

Related Classes of edu.umd.cloud9.io.pair.PairOfIntLong

Copyright © 2018 www.massapicom. 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.