Package ivory.lsh.data

Examples of ivory.lsh.data.NBitSignature


          randomUnitVectors = SequenceFileUtils.readValues(new Path(PwsimEnvironment.getFileNameWithPars(job.get("Ivory.IndexPath"), "RandomVectors")+"/part-00000"), FileSystem.getLocal(job));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      signature = new NBitSignature(D);
     
      if(localFiles.length > 1){
        dotProductThresholds = new float[D];
        int i = 0;
        try {
View Full Code Here


        }
        if (randomUnitVectors == nullthrow new RuntimeException("File not found in local cache: " + inCacheFile);
      } catch (Exception e) {
        throw new RuntimeException("Error reading random vectors!\n" + e.getMessage());
      }
      signature = new NBitSignature(D);
    }
View Full Code Here

              + "/part-00000"), FileSystem.getLocal(job));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      signature = new NBitSignature(D);

      if (localFiles.length > 1) {
        dotProductThresholds = new float[D];
        int i = 0;
        try {
View Full Code Here

    //write
    SequenceFile.Writer w = SequenceFile.createWriter(FileSystem.getLocal(new Configuration()), new Configuration(),
        new Path(TMP_FILENAME1), IntWritable.class, PairOfIntNBitSignature.class);
   
    PairOfIntNBitSignature p1 = new PairOfIntNBitSignature(1, null);
    PairOfIntNBitSignature p2 = new PairOfIntNBitSignature(2, new NBitSignature(100));
    PairOfIntNBitSignature p3 = new PairOfIntNBitSignature(3, null);

    w.append(new IntWritable(1), p1);
    w.append(new IntWritable(2), p2);
    w.append(new IntWritable(3), p3);
View Full Code Here

  }

  @Test
  public void testSort() {
    // 00000000
    NBitSignature s1 = new NBitSignature(64);
    for (int i = 0; i < 64; i++) {
      s1.set(i, false);
    }

    // 10000000
    NBitSignature s2 = new NBitSignature(64);
    s2.set(0, true);

    // 01000000
    NBitSignature s3 = new NBitSignature(64);
    s3.set(1, true);

    // 000100000
    NBitSignature s4 = new NBitSignature(64);
    s4.set(3, true);

    PriorityQueue<NBitSignature> sorted = new PriorityQueue<NBitSignature>();
    sorted.add(s1);
    sorted.add(s2);
    sorted.add(s3);
View Full Code Here

    PermutationByBit p = new PermutationByBit(D);
    ArrayListOfIntsWritable a = p.nextPermutation();

    for (int i = 0; i < 100000; i++) {

      NBitSignature s = getRandomSignature();

      // System.out.println(s);

      NBitSignature slide = s.getSubSignature(0, D / 2);
      NBitSignature slide2 = s.getSubSignature(D / 2 + 1, D - 1);
      // System.out.println(slide+""+slide2);

      assertTrue(s.toString().equals(slide.toString() + slide2.toString()));
    }
    System.out.println("done");

    // System.out.println(slide);
    // System.out.println(slide2);
View Full Code Here

      s.set(i, true);
    }
    // System.out.println(s);

    // for(int i=0;i<1;i++){
    NBitSignature slide = s.getSubSignature(0, 4);
    NBitSignature slide2 = s.getSubSignature(5, 9);
    // }
    System.out.println(s);

    System.out.println("From 0 to 4: " + slide);
    System.out.println("From 5 to 9: " + slide2);
View Full Code Here

    // write
    SequenceFile.Writer w = SequenceFile.createWriter(fs, conf,
        new Path(TMP_FILENAME1), IntWritable.class, PairOfIntNBitSignature.class);

    PairOfIntNBitSignature p1 = new PairOfIntNBitSignature(1, null);
    PairOfIntNBitSignature p2 = new PairOfIntNBitSignature(2, new NBitSignature(100));
    PairOfIntNBitSignature p3 = new PairOfIntNBitSignature(3, null);

    w.append(new IntWritable(1), p1);
    w.append(new IntWritable(2), p2);
    w.append(new IntWritable(3), p3);
View Full Code Here

public class SignatureTest {
  private static final String TMP_FILENAME1 = "tmp1.out";
  private static int D = 20;

  private NBitSignature getRandomSignature() {
    NBitSignature s = new NBitSignature(D);
    for (int i = 0; i < s.size(); i++) {
      s.set(i, (Math.random() > 0.5 ? true : false));
    }
    return s;
  }
View Full Code Here

  @Test
  public void testPermuteBit() throws IOException {
    PermutationByBit p = new PermutationByBit(D);

    NBitSignature s = getRandomSignature();

    int cntBits = s.countSetBits();

    int loopcnt = 0;
    NBitSignature permutedS = new NBitSignature(D);
    while (loopcnt++ < 100) {
      ArrayListOfIntsWritable a = p.nextPermutation();
      s.perm(a, permutedS);
      System.out.println(permutedS.countSetBits());
      assertTrue(cntBits == permutedS.countSetBits());
      // System.out.println(permutedS);
    }
  }
View Full Code Here

TOP

Related Classes of ivory.lsh.data.NBitSignature

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.