Examples of CBZip2InputStream


Examples of org.apache.tools.bzip2.CBZip2InputStream

        if (source.lastModified() > dest.lastModified()) {
            log("Expanding " + source.getAbsolutePath() + " to "
                + dest.getAbsolutePath());

            FileOutputStream out = null;
            CBZip2InputStream zIn = null;
            InputStream fis = null;
            BufferedInputStream bis = null;
            try {
                out = new FileOutputStream(dest);
                fis = srcResource.getInputStream();
                bis = new BufferedInputStream(fis);
                int b = bis.read();
                if (b != 'B') {
                    throw new BuildException("Invalid bz2 file.", getLocation());
                }
                b = bis.read();
                if (b != 'Z') {
                    throw new BuildException("Invalid bz2 file.", getLocation());
                }
                zIn = new CBZip2InputStream(bis, true);
                byte[] buffer = new byte[BUFFER_SIZE];
                int count = 0;
                do {
                    out.write(buffer, 0, count);
                    count = zIn.read(buffer, 0, buffer.length);
                } while (count != -1);
            } catch (IOException ioe) {
                String msg = "Problem expanding bzip2 " + ioe.getMessage();
                throw new BuildException(msg, ioe, getLocation());
            } finally {
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2InputStream

                        if (istream.read() != magic[i]) {
                            throw new BuildException(
                                "Invalid bz2 file." + file.toString());
                        }
                    }
                    return new CBZip2InputStream(istream);
                }
            }
            return istream;
        }
View Full Code Here

Examples of org.apache.tools.bzip2.CBZip2InputStream

        InputStream actualIn =
            new BufferedInputStream(new FileInputStream(actualFile));
        assertEquals((byte) 'B', actualIn.read());
        assertEquals((byte) 'Z', actualIn.read());

        originalIn = new CBZip2InputStream(originalIn);
        actualIn   = new CBZip2InputStream(actualIn);

        while (true) {
            int expected = originalIn.read();
            int actual   = actualIn.read();
            if (expected >= 0) {
View Full Code Here

Examples of org.apache.tools.bzip2r.CBZip2InputStream

            fileIn.seek(start);
       
            if(file.toString().endsWith(".bz2") || file.toString().endsWith(".bz"))
            {
              // For bzip2 files use CBZip2InputStream to read and supply the upper input stream.
               CBZip2InputStream in = new CBZip2InputStream(fileIn,9, end);
               this.xmlLoaderBPIS = new XMLLoaderBufferedPositionedInputStream(in,start,end);
            }
            else if (file.toString().endsWith(".gz"))
            {
              CompressionCodecFactory compressionCodecs =  new CompressionCodecFactory(job);
View Full Code Here

Examples of org.apache.tools.bzip2r.CBZip2InputStream

        pig.registerQuery("store A into '" + out.getAbsolutePath() + "';");
        FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration(
                pig.getPigContext().getProperties()));
        FSDataInputStream is = fs.open(new Path(out.getAbsolutePath() +
                "/part-r-00000.bz2"));
        CBZip2InputStream cis = new CBZip2InputStream(is);
       
        // Just a sanity check, to make sure it was a bzip file; we
        // will do the value verification later
        assertEquals(100, cis.read(new byte[100]));
        cis.close();
       
        pig.registerQuery("B = load '" + out.getAbsolutePath() + "';");
       
        Iterator<Tuple> i = pig.openIterator("B");
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
View Full Code Here

Examples of org.apache.tools.bzip2r.CBZip2InputStream

        pig.registerQuery("store A into '" + out.getAbsolutePath() + "/';");
        FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration(
                pig.getPigContext().getProperties()));
        FSDataInputStream is = fs.open(new Path(out.getAbsolutePath() +
                "/part-r-00000.bz2"));
        CBZip2InputStream cis = new CBZip2InputStream(is);
       
        // Just a sanity check, to make sure it was a bzip file; we
        // will do the value verification later
        assertEquals(100, cis.read(new byte[100]));
        cis.close();
       
        pig.registerQuery("B = load '" + out.getAbsolutePath() + "';");
       
        Iterator<Tuple> i = pig.openIterator("B");
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
View Full Code Here

Examples of org.apache.tools.bzip2r.CBZip2InputStream

        pig.registerQuery("store A into '" + out.getAbsolutePath() + "';");
        FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration(
                pig.getPigContext().getProperties()));
        FSDataInputStream is = fs.open(new Path(out.getAbsolutePath() +
                "/part-r-00000.bz2"));
        CBZip2InputStream cis = new CBZip2InputStream(is);
       
        // Just a sanity check, to make sure it was a bzip file; we
        // will do the value verification later
        assertEquals(-1, cis.read(new byte[100]));
        cis.close();
       
        pig.registerQuery("B = load '" + out.getAbsolutePath() + "';");
        pig.openIterator("B");
       
        in.delete();
View Full Code Here

Examples of org.apache.tools.bzip2r.CBZip2InputStream

        CBZip2OutputStream cos = new CBZip2OutputStream(new FileOutputStream(
                tmp));
        cos.close();
        assertNotSame(0, tmp.length());
        FileSystem fs = FileSystem.getLocal(new Configuration(false));
        CBZip2InputStream cis = new CBZip2InputStream(
                fs.open(new Path(tmp.getAbsolutePath())));
        assertEquals(-1, cis.read(new byte[100]));
        cis.close();
        tmp.delete();
    }
View Full Code Here

Examples of org.apache.tools.bzip2r.CBZip2InputStream

        pig.registerQuery("store A into '" + out.getAbsolutePath() + "';");
        FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration(
                pig.getPigContext().getProperties()));
        FSDataInputStream is = fs.open(new Path(out.getAbsolutePath() +
                "/part-r-00000.bz2"));
        CBZip2InputStream cis = new CBZip2InputStream(is, -1, out.length());
       
        // Just a sanity check, to make sure it was a bzip file; we
        // will do the value verification later
        assertEquals(100, cis.read(new byte[100]));
        cis.close();
       
        pig.registerQuery("B = load '" + out.getAbsolutePath() + "';");
       
        Iterator<Tuple> i = pig.openIterator("B");
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
View Full Code Here

Examples of org.apache.tools.bzip2r.CBZip2InputStream

        pig.registerQuery("store A into '" + out.getAbsolutePath() + "/';");
        FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration(
                pig.getPigContext().getProperties()));
        FSDataInputStream is = fs.open(new Path(out.getAbsolutePath() +
                "/part-r-00000.bz2"));
        CBZip2InputStream cis = new CBZip2InputStream(is, -1, out.length());
       
        // Just a sanity check, to make sure it was a bzip file; we
        // will do the value verification later
        assertEquals(100, cis.read(new byte[100]));
        cis.close();
       
        pig.registerQuery("B = load '" + out.getAbsolutePath() + "';");
       
        Iterator<Tuple> i = pig.openIterator("B");
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
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.