@@ -0,0 +1,2543 @@
+package xerial.larray.japi;%0A%0Aimport org.junit.Test;%0Aimport org.xerial.snappy.Snappy;%0Aimport xerial.larray.LByteArray;%0Aimport xerial.larray.LIntArray;%0Aimport xerial.larray.MMapMode;%0Aimport xerial.larray.MappedLByteArray;%0Aimport xerial.larray.util.Logger;%0A%0Aimport java.io.File;%0A%0Apublic class JSnappyCompressTest %7B%0A%0A    private Logger _logger = new Logger(this.getClass());%0A%0A    @Test%0A    public void testCompress() throws Exception %7B%0A%0A        long N = 100000000L;%0A        LIntArray l = LArrayJ.newLIntArray(N);%0A        for (int i = 0; i %3C N; i++) %7B%0A            l.update(i, (int) (Math.toDegrees(Math.sin(i / 360))));%0A        %7D%0A        for (int iter = 0; iter %3C 10; iter++) %7B%0A            long sum = 0;%0A            long start = System.currentTimeMillis();%0A            for (int i = 0; i %3C l.length(); i++) %7B%0A                sum += l.apply(i);%0A            %7D%0A            long end = System.currentTimeMillis();%0A            _logger.debug(%22time:%22 + (end - start) + %22 sum:%22 + sum);%0A        %7D%0A        _logger.debug(%22compressing the data%22);%0A        int maxLen = Snappy.maxCompressedLength((int) l.byteLength());%0A        LByteArray compressedBuf = LArrayJ.newLByteArray(maxLen);%0A        long compressedLen = Snappy.rawCompress(l.address(), l.byteLength(),%0A                compressedBuf.address());%0A        LByteArray compressed = (LByteArray) compressedBuf.slice(0,%0A                compressedLen);%0A        File f = File.createTempFile(%22snappy%22, %22.dat%22, new File(%22target%22));%0A        f.deleteOnExit();%0A        compressed.saveTo(f);%0A%0A        _logger.debug(%22decompressing the data%22);%0A        long T1 = System.currentTimeMillis();%0A        MappedLByteArray b = LArrayJ.mmap(f, 0, f.length(), MMapMode.READ_ONLY);%0A        long T2 = System.currentTimeMillis();%0A%0A        long len = Snappy.uncompressedLength(b.address(), b.length());%0A        LIntArray decompressed = LArrayJ.newLIntArray(len / 4);%0A        Snappy.rawUncompress(b.address(), b.length(), decompressed.address());%0A        long T3 = System.currentTimeMillis();%0A        _logger.debug(%22Map time:%22 + (T2 - T1));%0A        _logger.debug(%22decompress time:%22 + (T3 - T2));%0A%0A%0A        _logger.debug(%22Summing decompressed array%22);%0A        for (int iter = 0; iter %3C 10; iter++) %7B%0A            long sum = 0;%0A            long start = System.currentTimeMillis();%0A            for (int i = 0; i %3C decompressed.length(); i++) %7B%0A                sum += decompressed.apply(i);%0A            %7D%0A            long end = System.currentTimeMillis();%0A            _logger.debug(%22time:%22 + (end - start) + %22 sum:%22 + sum);%0A        %7D%0A    %7D%0A%7D

Add compression tests in Java