Examples of CanonicalHuffmanIntegerCodec


Examples of net.sf.cram.encoding.CanonicalHuffmanIntegerCodec

      cal.add(ReadTag.nameType3BytesToInt("AM", 'c'));
    }

    cal.calculate();

    CanonicalHuffmanIntegerCodec c = new CanonicalHuffmanIntegerCodec(
        cal.values(), cal.bitLens());
    long time6 = System.nanoTime() ;

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DefaultBitOutputStream bos = new DefaultBitOutputStream(baos);
   
    long time1=System.nanoTime() ;
    for (int i = 0; i < size; i++) {
      for (int b : cal.values()) {
        c.write(bos, b);
      }
    }

    bos.close();
    long time2=System.nanoTime() ;

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DefaultBitInputStream bis = new DefaultBitInputStream(bais);

    long time3=System.nanoTime() ;
    for (int i = 0; i < size; i++) {
      for (int b : cal.values()) {
        int v = c.read(bis);
        if (v != b)
          fail("Mismatch: " + v + " vs " + b);
      }
    }
    long time4=System.nanoTime() ;
View Full Code Here

Examples of net.sf.cram.encoding.CanonicalHuffmanIntegerCodec

  @Test
  public void test() throws IOException {
    int[] values = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
    int[] lens = new int[] { 1, 2, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8 };
    CanonicalHuffmanIntegerCodec c = new CanonicalHuffmanIntegerCodec(values,
        lens);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DefaultBitOutputStream bos = new DefaultBitOutputStream(baos);
    for (int b : values) {
      c.write(bos, b);
    }

    bos.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DefaultBitInputStream bis = new DefaultBitInputStream(bais);

    for (int b : values) {
      int v = c.read(bis);
      if (v != b)
        fail("Mismatch: " + v + " vs " + b);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.