Package de.jarnbjo.jsnappy

Examples of de.jarnbjo.jsnappy.SnzOutputStream


        RandomAccessFile raf = new RandomAccessFile(f, "r");
        byte[] data = new byte[(int) raf.length()];
        raf.readFully(data);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SnzOutputStream sos = new SnzOutputStream(baos, 4096);
        sos.write(data);
        sos.close();

        byte[] compressed = baos.toByteArray();

        long l = 0;
        int r = 0;
View Full Code Here


        int nativeLength = (int)new File(tmpDirectory, org.getName() + ".snz").length();
        double nativeSize = 100. * nativeLength / originalData.length;

        ByteArrayOutputStream jsnappyData = new ByteArrayOutputStream();
        SnzOutputStream sos = new SnzOutputStream(jsnappyData);
        sos.setCompressionEffort(1);
        sos.write(originalData);
        sos.close();
        double javaSize1 = 100. * jsnappyData.toByteArray().length / originalData.length;
       
        jsnappyData = new ByteArrayOutputStream();
        sos = new SnzOutputStream(jsnappyData);
        sos.setCompressionEffort(50);
        sos.write(originalData);
        sos.close();
        double javaSize50 = 100. * jsnappyData.toByteArray().length / originalData.length;
       
        jsnappyData = new ByteArrayOutputStream();
        sos = new SnzOutputStream(jsnappyData);
        sos.setCompressionEffort(100);
        sos.write(originalData);
        sos.close();
        double javaSize100 = 100. * jsnappyData.toByteArray().length / originalData.length;

        System.out.printf("%s: native: %.1f%%, Java: %.1f%% - %.1f%% - %.1f%% %n", org.getName(), nativeSize, javaSize1, javaSize50, javaSize100);
      }
    }
View Full Code Here

      if(org.isFile()) {
        System.out.println("checking " + org.getName());
        byte[] originalData = TestUtil.readFully(org);
       
        ByteArrayOutputStream compressedData = new ByteArrayOutputStream();       
        SnzOutputStream sos = new SnzOutputStream(compressedData);
        sos.write(originalData);
        sos.close();
       
        ByteArrayOutputStream decompressedData = new ByteArrayOutputStream();
        SnzInputStream sis = new SnzInputStream(new ByteArrayInputStream(compressedData.toByteArray()));
        TestUtil.pipe(sis, decompressedData);
        Assert.assertArrayEquals(originalData, decompressedData.toByteArray());
View Full Code Here

    tmpDirectory.mkdirs();
   
    for(File org : testdataDirectory.listFiles()) {
      if(org.isFile()) {
        System.out.println("compressing " + org.getName());       
        SnzOutputStream sos = new SnzOutputStream(new FileOutputStream(new File(tmpDirectory, org.getName() + ".snz")));
        sos.setCompressionEffort(effort);
        FileInputStream fis = new FileInputStream(org);
        TestUtil.pipe(fis, sos);
        fis.close();
        sos.close();
      }
    }
   
    ProcessBuilder pb = new ProcessBuilder(TestUtil.snzipArgs(snzipExecutable, "-d -t snzip", tmpDirectory));
    pb.directory(tmpDirectory);
View Full Code Here

TOP

Related Classes of de.jarnbjo.jsnappy.SnzOutputStream

Copyright © 2018 www.massapicom. 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.