Class DescriptorEncoder


  • public class DescriptorEncoder
    extends java.lang.Object
    DescriptorEncoder encodes int[] based descriptors into byte arrays that may be used to instantiate Strings
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_COUNT_VALUE  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int[] decode​(byte[] bytes)
      Decodes a binary fingerprint from a String into an int[].
      int[] decode​(java.lang.String s)
      Decodes a binary fingerprint from a String into an int[].
      byte[] decodeCounts​(byte[] bytes)
      Decodes a list of fragment/has-value counts from an encoded byte sequence into a byte[].
      byte[] decodeCounts​(java.lang.String s)
      Decodes a list of fragment/has-value counts from an encoded String.
      int[] decodeIntArray​(byte[] bytes)
      Decodes an int[] without upper limit.
      int[] decodeIntArray​(java.lang.String s)
      Decodes an int[] without upper limit.
      long[] decodeLong​(byte[] bytes)
      Decodes a binary fingerprint from a String into a long[].
      long[] decodeLong​(java.lang.String s)
      Decodes a binary fingerprint from a String into a long[].
      int[][] decodePairs​(byte[] bytes)
      Decodes pairs of identifying integer with corresponding count values in the form of an int[n][2], where n is the number of pairs, index=0 refers to the ID value and index=1 refers to the count value.
      int[][] decodePairs​(java.lang.String s)
      Decodes pairs of identifying integer with corresponding count values in the form of an int[n][2], where n is the number of pairs, index=0 refers to the ID value and index=1 refers to the count value.
      byte[] encode​(int[] data)
      Encodes a binary fingerprint stored as int[].
      byte[] encodeCounts​(byte[] data)
      Encodes a fragment/hash-value count list.
      byte[] encodeIntArray​(int[] data)
      Encodes an int[] containing positive values without upper limit.
      byte[] encodeLong​(long[] data)
      Encodes a binary fingerprint stored as long[].
      byte[] encodePairs​(int[][] data)
      Encodes pairs of identifying integer with corresponding count values in the form of an int[n][2], where n is the number of pairs, index=0 refers to the ID value and index=1 refers to the count value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DescriptorEncoder

        public DescriptorEncoder()
    • Method Detail

      • encode

        public byte[] encode​(int[] data)
        Encodes a binary fingerprint stored as int[].
        Parameters:
        data - binary fingerprint
        Returns:
        byte[] of encoded character sequence
      • encodeLong

        public byte[] encodeLong​(long[] data)
        Encodes a binary fingerprint stored as long[].
        Parameters:
        data - binary fingerprint
        Returns:
        byte[] of encoded character sequence
      • decode

        public int[] decode​(java.lang.String s)
        Decodes a binary fingerprint from a String into an int[].
        Parameters:
        s - encoded binary fingerprint
        Returns:
        int[] binary fingerprint
      • decode

        public int[] decode​(byte[] bytes)
        Decodes a binary fingerprint from a String into an int[].
        Parameters:
        bytes - encoded binary fingerprint as byte sequence
        Returns:
        int[] binary fingerprint
      • decodeLong

        public long[] decodeLong​(java.lang.String s)
        Decodes a binary fingerprint from a String into a long[].
        Parameters:
        s - encoded binary fingerprint
        Returns:
        int[] binary fingerprint
      • decodeLong

        public long[] decodeLong​(byte[] bytes)
        Decodes a binary fingerprint from a String into a long[].
        Parameters:
        bytes - encoded binary fingerprint as byte sequence
        Returns:
        long[] binary fingerprint
      • encodeCounts

        public byte[] encodeCounts​(byte[] data)
        Encodes a fragment/hash-value count list. Count values must not exceed MAX_COUNT_VALUE in order to get encoded correctly.
        Parameters:
        data - list of fragment counts or hash-value counts
        Returns:
        byte[] of encoded character sequence
      • decodeCounts

        public byte[] decodeCounts​(java.lang.String s)
        Decodes a list of fragment/has-value counts from an encoded String.
        Parameters:
        s - count list encoded as String
        Returns:
        byte[] array with every byte representing a count value
      • decodeCounts

        public byte[] decodeCounts​(byte[] bytes)
        Decodes a list of fragment/has-value counts from an encoded byte sequence into a byte[].
        Parameters:
        bytes - count list encoded as byte sequence
        Returns:
        byte[] array with every byte representing a count value
      • encodeIntArray

        public byte[] encodeIntArray​(int[] data)
        Encodes an int[] containing positive values without upper limit.
        Parameters:
        data -
        Returns:
        byte[] of encoded character sequence
      • decodeIntArray

        public int[] decodeIntArray​(java.lang.String s)
        Decodes an int[] without upper limit.
        Parameters:
        s - String
        Returns:
        int[] decoded int array
      • decodeIntArray

        public int[] decodeIntArray​(byte[] bytes)
        Decodes an int[] without upper limit.
        Parameters:
        bytes - encoded character sequence
        Returns:
        int[] decoded int array
      • encodePairs

        public byte[] encodePairs​(int[][] data)
        Encodes pairs of identifying integer with corresponding count values in the form of an int[n][2], where n is the number of pairs, index=0 refers to the ID value and index=1 refers to the count value. Neither ID values nor count values must be larger than 32767.
        Parameters:
        data -
        Returns:
      • decodePairs

        public int[][] decodePairs​(byte[] bytes)
        Decodes pairs of identifying integer with corresponding count values in the form of an int[n][2], where n is the number of pairs, index=0 refers to the ID value and index=1 refers to the count value.
        Parameters:
        bytes -
        Returns:
      • decodePairs

        public int[][] decodePairs​(java.lang.String s)
        Decodes pairs of identifying integer with corresponding count values in the form of an int[n][2], where n is the number of pairs, index=0 refers to the ID value and index=1 refers to the count value.
        Parameters:
        s -
        Returns: