Package edu.umd.cloud9.io.array

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


   * @param size
   *     number of bits
   */
  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

   * @param i
   *     length of permutation
   */
  public PermutationByBit(int i){
    rand = new Random();
    randPerm = new ArrayListOfIntsWritable();
    for(int j = 0; j < i; j++){
      randPerm.add(j);
    }
    length = i;
  }
View Full Code Here

      int i = rand.nextInt(length);
      int j = randPerm.get(i);
      randPerm.set(i, randPerm.get(k));
      randPerm.set(k, j);
    }
    return new ArrayListOfIntsWritable(randPerm);
 
View Full Code Here

  public static void main(String[] args){
    int SIZE = 1000;
    PermutationByBit p = new PermutationByBit(SIZE);
    for(int k=0;k<100;k++){
      ArrayListOfIntsWritable a = p.nextPermutation();

      //make sure the permutation is not out of bounds
      for(int i=0;i<SIZE;i++){
        assertTrue(i+"-->"+a.get(i),a.get(i)<SIZE && a.get(i)>=0);
      }
     
      //make sure each position is included in the permutation exactly once
      int[] positions = new int[SIZE];
      for(int i=0;i<SIZE;i++){
        if(positions[a.get(i)]==1){
          fail("Same position included twice: "+a.get(i));
        }
        positions[a.get(i)]=1;
      }
      for(int i=0;i<SIZE;i++){
        if(positions[i]==0){
//          System.out.println(java.util.Arrays.binarySearch(positions, i));
          fail("Position not included: "+i);
View Full Code Here

      return randomPermFile;
    }
    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

   * @param size
   *     number of bits
   */
  public MinhashSignature(){
    super();
    terms = new ArrayListOfIntsWritable();
  }
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.