/** * Used by buildEncodingForTag to create a ByteArrayLenEncoding with CanonicalHuffmanIntegerEncoding and * ExternalByteArrayEncoding sub-encodings * * @param tagValueSize the size of the tag value, to be Huffman encoded * @param tagID the ID of the tag * @return EncodingParams a complete description of the result Encoding */ private EncodingParams buildTagEncodingForSize(final int tagValueSize, final int tagID) { return new ByteArrayLenEncoding( new CanonicalHuffmanIntegerEncoding(new int[] { tagValueSize }, singleZero), new ExternalByteArrayEncoding(tagID)).toParam(); }
switch (id) { case HUFFMAN: return (CRAMEncoding<T>) CanonicalHuffmanIntegerEncoding.fromParams(params); case EXTERNAL: return (CRAMEncoding<T>) ExternalIntegerEncoding.fromParams(params);
switch (id) { case HUFFMAN: return (CRAMEncoding<T>) CanonicalHuffmanIntegerEncoding.fromParams(params); case EXTERNAL: return (CRAMEncoding<T>) ExternalIntegerEncoding.fromParams(params);
/** * Used by buildEncodingForTag to create a ByteArrayLenEncoding with CanonicalHuffmanIntegerEncoding and * ExternalByteArrayEncoding sub-encodings * * @param tagValueSize the size of the tag value, to be Huffman encoded * @param tagID the ID of the tag * @return EncodingParams a complete description of the result Encoding */ private EncodingParams buildTagEncodingForSize(final int tagValueSize, final int tagID) { return new ByteArrayLenEncoding( new CanonicalHuffmanIntegerEncoding(new int[] { tagValueSize }, singleZero), new ExternalByteArrayEncoding(tagID)).toParam(); }
public static CanonicalHuffmanIntegerEncoding fromParams(final byte[] data) { final ByteBuffer buf = ByteBuffer.wrap(data); final int valueSize = ITF8.readUnsignedITF8(buf); final int[] values = new int[valueSize]; for (int i = 0; i < valueSize; i++) { values[i] = ITF8.readUnsignedITF8(buf); } final int lengthSize = ITF8.readUnsignedITF8(buf); final int[] bitLengths = new int[lengthSize]; for (int i = 0; i < lengthSize; i++) { bitLengths[i] = ITF8.readUnsignedITF8(buf); } return new CanonicalHuffmanIntegerEncoding(values, bitLengths); }
public static CanonicalHuffmanIntegerEncoding fromParams(final byte[] data) { final ByteBuffer buf = ByteBuffer.wrap(data); final int valueSize = ITF8.readUnsignedITF8(buf); final int[] values = new int[valueSize]; for (int i = 0; i < valueSize; i++) { values[i] = ITF8.readUnsignedITF8(buf); } final int lengthSize = ITF8.readUnsignedITF8(buf); final int[] bitLengths = new int[lengthSize]; for (int i = 0; i < lengthSize; i++) { bitLengths[i] = ITF8.readUnsignedITF8(buf); } return new CanonicalHuffmanIntegerEncoding(values, bitLengths); }