Package edu.umd.cloud9.io.array

Examples of edu.umd.cloud9.io.array.ArrayListOfIntsWritable


  public static void writeToFile(Permutation p, int numPerms, FileSystem fs, JobConf job, String fileName) throws IOException{
    SequenceFile.Writer writer = SequenceFile.createWriter(fs, job, new Path(fileName), IntWritable.class, ArrayListOfIntsWritable.class);

    for(int j=0;j<numPerms;j++){
      ArrayListOfIntsWritable perm = p.nextPermutation();
      writer.append(new IntWritable(j), perm);
      //            sLogger.debug(j +":"+perm);
    }
    writer.close();
  }
View Full Code Here


  public ArrayListOfIntsWritable nextPermutation() {
    if(combEnd==NUM_BLOCKS){
      throw new RuntimeException("Too many calls! All permutations done!");
    }
    System.err.println(combStart+","+combEnd);
    ArrayListOfIntsWritable perm = new ArrayListOfIntsWritable();
    addAll(perm, blocks[combStart].getArray());
    addAll(perm, blocks[combEnd].getArray());
    //    if(combStart==(BLOCK_SIZE-1) ||combEnd==(BLOCK_SIZE-1)){
    //      keyLen = 25;
    //    }else{
    //      keyLen = 26;
    //    }
    ArrayList<Integer> rest = new ArrayList<Integer>();
    for(int i=0;i<NUM_BLOCKS;i++){
      if(i!=combStart && i!=combEnd){
        rest.add(i);
      }
    }
    Collections.shuffle(rest);

    for(int nextBlock : rest){
      addAll(perm, blocks[nextBlock].getArray());
    }
    if(perm.size()!=length){
      throw new RuntimeException("Number of elements not correct!");
    }
    if(combEnd==(NUM_BLOCKS-1)){
      combStart++;
      combEnd = combStart+1;
View Full Code Here

              if ((eDocno == 6127 && fDocno == 1000000074) || (eDocno == 6127 && fDocno == 1000000071)) {
                sLogger.info(key);
              }
              if(langID == CLIRUtils.E){
                if(!pwsimMapping.containsKey(eDocno)){
                  pwsimMapping.put(eDocno, new ArrayListOfIntsWritable());
                }
                pwsimMapping.get(eDocno).add(fDocno);   // we add 1000000000 to foreign docnos to distinguish them during pwsim algo
              }else{
                if(!pwsimMapping.containsKey(fDocno)){
                  pwsimMapping.put(fDocno, new ArrayListOfIntsWritable());
                }
                pwsimMapping.get(fDocno).add(eDocno);   // we add 1000000000 to foreign docnos to distinguish them during pwsim algo
              }
              cnt++;
              key = (PairOfInts) reader.getKeyClass().newInstance();
View Full Code Here

              int fDocno = key.getRightElement();
//          fDocno -= 1000000000;
              int eDocno = key.getLeftElement();
              if(langID == CLIRUtils.E){
                if(!pwsimMapping.containsKey(eDocno)){
                  pwsimMapping.put(eDocno, new ArrayListOfIntsWritable());
                }
                pwsimMapping.get(eDocno).add(fDocno);   // we add 1000000000 to foreign docnos to distinguish them during pwsim algo
              }else{
                if(!pwsimMapping.containsKey(fDocno)){
                  pwsimMapping.put(fDocno, new ArrayListOfIntsWritable());
                }
                pwsimMapping.get(fDocno).add(eDocno);   // we add 1000000000 to foreign docnos to distinguish them during pwsim algo
              }
              cnt++;
              key = (PairOfInts) reader.getKeyClass().newInstance();
View Full Code Here

    SequenceFile.Writer writer = SequenceFile.createWriter(fs, job, new Path(randomPermFile),
        IntWritable.class, ArrayListOfIntsWritable.class);
    Permutation p = new PermutationByBit(numBits);
    for (int i = 0; i < numOfPermutations; i++) {
      ArrayListOfIntsWritable perm = p.nextPermutation();
      writer.append(new IntWritable(i), perm);
      sLogger.debug(i + ":" + perm);
    }
    writer.close();
    sLogger.info("Random permutations written.");
View Full Code Here

  /**
   * Create a BitsSignature object with the specified number of bits, all initially set to 0.
   */
  public MinhashSignature(){
    super();
    terms = new ArrayListOfIntsWritable();
  }
View Full Code Here

    super();
    terms = new ArrayListOfIntsWritable();
  }

  public MinhashSignature(ArrayListOfIntsWritable b){
    terms = new ArrayListOfIntsWritable(b);
  }
View Full Code Here

    this(other.terms);
  }

  public MinhashSignature(int numTerms){      //need this constructor for general purposes.
    super();
    terms = new ArrayListOfIntsWritable(numTerms);
  }
View Full Code Here


  @Override
  public int hammingDistance(Signature signature, int threshold){
    MinhashSignature s2 = (MinhashSignature) signature;
    ArrayListOfIntsWritable l1 = this.terms;
    ArrayListOfIntsWritable l2 = s2.terms;

    int count=0;
    for(int i=0;i<l1.size();i++){

      int i1 = l1.get(i), i2=l2.get(i);
      if(i1!=i2){
        count++;
        if(count>threshold){
          return count;
        }
View Full Code Here

   *   last index to be included in sub-list
   * @return
   *   return a new ArrayListOfIntsWritable object, containing the ints of this object from <code>start</code> to <code>end</code>
   */
  public ArrayListOfIntsWritable sub(ArrayListOfIntsWritable lst, int start, int end) {
    ArrayListOfIntsWritable sublst = new ArrayListOfIntsWritable(end-start+1);
    for(int i=start;i<=end;i++){
      sublst.add(lst.get(i));
    }
    return sublst;
  }
View Full Code Here

TOP

Related Classes of edu.umd.cloud9.io.array.ArrayListOfIntsWritable

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.