Write the length of the compressed bytes. Life is much easier if the header is constant length, so just use 3 bytes. Considering most of the codecs want between 32k (snappy) and 256k (lzo, zlib), 3 bytes should be plenty. We also use the low bit for whether it is the original or compressed bytes. @p
(ByteBuffer buffer,
int position,
int val,
boolean original)
| 181 | * @param original is it uncompressed |
| 182 | */ |
| 183 | private static void writeHeader(ByteBuffer buffer, |
| 184 | int position, |
| 185 | int val, |
| 186 | boolean original) { |
| 187 | buffer.put(position, (byte) ((val << 1) + (original ? 1 : 0))); |
| 188 | buffer.put(position + 1, (byte) (val >> 7)); |
| 189 | buffer.put(position + 2, (byte) (val >> 15)); |
| 190 | } |
| 191 | |
| 192 | private void getNewInputBuffer() { |
| 193 | if (codec == null) { |
no test coverage detected