Search in sources :

Example 1 with LRUDictionary

use of org.apache.hadoop.hbase.io.util.LRUDictionary in project hbase by apache.

the class TestCompressor method testCompressingWithClearDictionaries.

@Test
public void testCompressingWithClearDictionaries() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    Dictionary dictionary = new LRUDictionary();
    dictionary.init(Short.MAX_VALUE);
    byte[] blahBytes = Bytes.toBytes("blah");
    Compressor.writeCompressed(blahBytes, 0, blahBytes.length, dos, dictionary);
    dos.close();
    byte[] dosbytes = baos.toByteArray();
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dosbytes));
    dictionary = new LRUDictionary();
    dictionary.init(Short.MAX_VALUE);
    byte[] product = Compressor.readCompressed(dis, dictionary);
    assertTrue(Bytes.equals(blahBytes, product));
}
Also used : LRUDictionary(org.apache.hadoop.hbase.io.util.LRUDictionary) Dictionary(org.apache.hadoop.hbase.io.util.Dictionary) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) LRUDictionary(org.apache.hadoop.hbase.io.util.LRUDictionary) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 Dictionary (org.apache.hadoop.hbase.io.util.Dictionary)1 LRUDictionary (org.apache.hadoop.hbase.io.util.LRUDictionary)1 Test (org.junit.Test)1