Package org.rabinfingerprint.polynomial

Examples of org.rabinfingerprint.polynomial.Polynomial$ReverseComparator


  }

  protected List<Match> matches = new ArrayList<Match>();

  public void getMatches(String pathA, String pathB) throws FileNotFoundException {
    final Polynomial p = Polynomial.createIrreducible(53);

    Collection<Handprint> handsA = getHandsFromPath(p, pathA);
    Collection<Handprint> handsB = getHandsFromPath(p, pathB);

    findExactMatches(handsA, handsB);
View Full Code Here


public class Samples {
  public static void fingerprint() throws FileNotFoundException, IOException {
    // Create new random irreducible polynomial
    // These can also be created from Longs or hex Strings
    Polynomial polynomial = Polynomial.createIrreducible(53);
   
    // Create a fingerprint object
    RabinFingerprintLong rabin = new RabinFingerprintLong(polynomial);
   
    // Push bytes from a file stream
View Full Code Here

  }
 
  public static void slidingWindowFingerprint() throws FileNotFoundException, IOException {
    // Create new random irreducible polynomial
    // These can also be created from Longs or hex Strings
    Polynomial polynomial = Polynomial.createIrreducible(53);

    // Create a windowed fingerprint object with a window size of 48 bytes.
    RabinFingerprintLongWindowed window = new RabinFingerprintLongWindowed(polynomial, 48);
    for (byte b : ByteStreams.toByteArray(new FileInputStream("file.test"))) {
      // Push in one byte. Old bytes are automatically popped.
View Full Code Here

      }
    }
  }

  public void generatePolynomial(int deg) {
    Polynomial p = Polynomial.createIrreducible(deg);
    System.out.println(p.toHexString());
  }
View Full Code Here

  public void printUsage() throws IOException {
    ByteStreams.copy(getClass().getResourceAsStream("/usage.txt"), System.out);
  }

  public Polynomial checkPolynomial(Long l) throws ArgParseException {
    Polynomial p = Polynomial.createFromLong(l);
    if (p.isReducible()) {
      throw new ArgParseException(
          "The specified polynomial is not irreducible and therefore invalid for the rabin fingerprint method. Please use -polygen to generate an irreducible polynomial.");
    }
    return p;
  }
View Full Code Here

    this.popTable = that.popTable;
  }

  private void precomputePopTable() {
    for (int i = 0; i < 256; i++) {
      Polynomial f = Polynomial.createFromLong(i);
      f = f.shiftLeft(BigInteger.valueOf(bytesPerWindow * 8));
      f = f.mod(poly);
      popTable[i] = f.toBigInteger().longValue();
    }
  }
View Full Code Here

    super(poly);
    this.byteShift = BigInteger.valueOf(8);
    this.windowShift = BigInteger.valueOf(bytesPerWindow * 8);
    this.bytesPerWindow = bytesPerWindow;
    this.byteWindow = new CircularByteQueue((int) bytesPerWindow + 1);
    this.fingerprint = new Polynomial();
  }
View Full Code Here

   *
   * If we have passed overflowed our window, we pop a byte
   */
  @Override
  public synchronized void pushByte(byte b) {
    Polynomial f = fingerprint;
    f = f.shiftLeft(byteShift);
    f = f.or(Polynomial.createFromLong(b & 0xFFL));
    f = f.mod(poly);

    fingerprint = f;

    if (bytesPerWindow > 0) {
      byteWindow.add(b);
View Full Code Here

   * Note that despite this massive shift, the fingerprint will still result
   * in a k-bit number at the end of the calculation.
   */
  public synchronized void popByte() {
    byte b = byteWindow.poll();
    Polynomial f = Polynomial.createFromLong(b & 0xFFL);
    f = f.shiftLeft(windowShift);
    f = f.mod(poly);

    fingerprint = fingerprint.xor(f);
  }
View Full Code Here

    fingerprint = fingerprint.xor(f);
  }

  @Override
  public synchronized void reset() {
    this.fingerprint = new Polynomial();
    this.byteWindow.clear();
  }
View Full Code Here

TOP

Related Classes of org.rabinfingerprint.polynomial.Polynomial$ReverseComparator

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.