Module avro_fingerprint

Implement the Avro CRC 64 fingerprint algorithm.

Authors: Jake Morrison (jake@cogini.com).

References

Description

Implement the Avro CRC 64 fingerprint algorithm.

The algorithm is defined with this Java code:

    static long fingerprint64(byte[] buf) {
      if (FP_TABLE == null) initFPTable();
      long fp = EMPTY;
      for (int i = 0; i < buf.length; i++)
        fp = (fp >>> 8) ^ FP_TABLE[(int)(fp ^ buf[i]) & 0xff];
      return fp;
    }
  
    static long EMPTY = 0xc15d213aa4d7a795L;
    static long[] FP_TABLE = null;
  
    static void initFPTable() {
      FP_TABLE = new long[256];
      for (int i = 0; i < 256; i++) {
        long fp = i;
        for (int j = 0; j < 8; j++)
          fp = (fp >>> 1) ^ (EMPTY & -(fp & 1L));
        FP_TABLE[i] = fp;
        // Generate the lookup table used in this code
        System.out.format("fp_table(%d) -> 16#%s;%n", i, Long.toHexString(fp));
      }
    }
In the Avro Java SchemaNormalization code, they serialize the fingerprint in little-endian format.

Data Types

crc64()

crc64() = non_neg_integer()

Function Index

crc64/1

Function Details

crc64/1

crc64(Data::binary()) -> crc64()


Generated by EDoc