Package org.apache.avro
Class SchemaNormalization
java.lang.Object
org.apache.avro.SchemaNormalization
Collection of static methods for generating the canonical form of schemas
(see
toParsingForm(org.apache.avro.Schema)
) -- and fingerprints of canonical forms
(fingerprint(java.lang.String, byte[])
).-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
fingerprint
(String fpName, byte[] data) Returns a fingerprint of a string of bytes.static long
fingerprint64
(byte[] data) Returns the 64-bit Rabin Fingerprint (as recommended in the Avro spec) of a byte string.static byte[]
parsingFingerprint
(String fpName, Schema s) Returnsfingerprint(java.lang.String, byte[])
applied to the parsing canonical form of the supplied schema.static long
Returnsfingerprint64(byte[])
applied to the parsing canonical form of the supplied schema.static String
Returns "Parsing Canonical Form" of a schema as defined by Avro spec.
-
Method Details
-
toParsingForm
Returns "Parsing Canonical Form" of a schema as defined by Avro spec. -
fingerprint
Returns a fingerprint of a string of bytes. This string is presumed to contain a canonical form of a schema. The algorithm used to compute the fingerprint is selected by the argument fpName. If fpName equals the string"CRC-64-AVRO"
, then the result offingerprint64(byte[])
is returned in little-endian format. Otherwise, fpName is used as an algorithm name forMessageDigest.getInstance(String)
, which will throwNoSuchAlgorithmException
if it doesn't recognize the name.Recommended Avro practice dictates that
"CRC-64-AVRO"
is used for 64-bit fingerprints,"MD5"
is used for 128-bit fingerprints, and"SHA-256"
is used for 256-bit fingerprints.- Throws:
NoSuchAlgorithmException
-
fingerprint64
public static long fingerprint64(byte[] data) Returns the 64-bit Rabin Fingerprint (as recommended in the Avro spec) of a byte string. -
parsingFingerprint
Returnsfingerprint(java.lang.String, byte[])
applied to the parsing canonical form of the supplied schema.- Throws:
NoSuchAlgorithmException
-
parsingFingerprint64
Returnsfingerprint64(byte[])
applied to the parsing canonical form of the supplied schema.
-