Package org.h2.dev.util
Class AnsCompression
- java.lang.Object
-
- org.h2.dev.util.AnsCompression
-
public class AnsCompression extends java.lang.ObjectAn ANS (Asymmetric Numeral Systems) compression tool. It uses the range variant.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcountFrequencies(int[] freq, byte[] data)Count the frequencies of codes in the data, and increment the target frequency table.static byte[]decode(int[] freq, byte[] data, int length)Decode the data.static byte[]encode(int[] freq, byte[] data)Encode the data.static voidscaleFrequencies(int[] freq, int total)Scale the frequencies to a new total.
-
-
-
Method Detail
-
countFrequencies
public static void countFrequencies(int[] freq, byte[] data)Count the frequencies of codes in the data, and increment the target frequency table.- Parameters:
freq- the target frequency tabledata- the data
-
scaleFrequencies
public static void scaleFrequencies(int[] freq, int total)Scale the frequencies to a new total. Frequencies of 0 are kept as 0; larger frequencies result in at least 1.- Parameters:
freq- the (source and target) frequency tabletotal- the target total (sum of all frequencies)
-
encode
public static byte[] encode(int[] freq, byte[] data)Encode the data.- Parameters:
freq- the frequency table (will be scaled)data- the source data (uncompressed)- Returns:
- the compressed data
-
decode
public static byte[] decode(int[] freq, byte[] data, int length)Decode the data.- Parameters:
freq- the frequency table (will be scaled)data- the compressed datalength- the target length- Returns:
- the uncompressed result
-
-