Package xbird.util.io

Examples of xbird.util.io.FastByteArrayOutputStream


        return decoder;
    }

    private static void bulkOut(ObjectOutput out, Sequence<Item> entity, boolean remotePaing)
            throws IOException {
        final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
        final ObjectOutputStream objOut = new ObjectOutputStream(bufOut);
        final XQEventEncoder encoder = new XQEventEncoder(objOut);
        if(remotePaing) {
            encoder.setRemotePaging(true);
        }
        try {
            encoder.emit(entity);
            objOut.flush();
        } catch (XQueryException xqe) {
            throw new IllegalStateException("failed encoding", xqe);
        } catch (Throwable e) {
            LOG.fatal(e);
            throw new IllegalStateException("failed encoding", e);
        }
        final byte[] buf = bufOut.toByteArray();
        bufOut.clear();
        final int buflen = buf.length;
        if(LOG.isDebugEnabled()) {
            LOG.debug("encoded sequence size: " + buflen);
        }
        out.writeInt(buflen);
View Full Code Here


            final ObjectInputStream objInput = new NoHeaderObjectInputStream(inputBuf);
            this._decoder = new XQEventDecoder(objInput); // replace old Decoder with fresh Decoder
        }

        private void incrBulkOut(final ObjectOutput out) throws IOException {
            final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
            final ObjectOutputStream objectOut = new ObjectOutputStream(bufOut);
            final XQEventDecoder decoder = _decoder;
            decoder.redirectTo(objectOut);
            decoder.close();
            objectOut.flush();
            final byte[] buf = bufOut.toByteArray();
            bufOut.clear();

            // Because input of decoder fully read, this section required for re-object serialization, etc.
            if(_reaccessable) {
                final FastByteArrayInputStream inputBuf = new FastByteArrayInputStream(buf);
                final ObjectInputStream objectInput = new ObjectInputStream(inputBuf);
View Full Code Here

        return actualSequence.next(focus);
    }

    public synchronized void doEncode() throws IOException {
        if(encodedSequence != null) {
            final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
            final ObjectOutputStream objOut = new ObjectOutputStream(bufOut);
            final XQEventEncoder encoder = new XQEventEncoder(objOut);
            try {
                encoder.emit(actualSequence);
                objOut.flush();
            } catch (XQueryException xqe) {
                throw new IOException(PrintUtils.prettyPrintStackTrace(xqe));
            } catch (Throwable e) {
                LOG.fatal(e);
                throw new IOException(PrintUtils.prettyPrintStackTrace(e));
            }
            this.encodedSequence = bufOut.toByteArray();
        }
    }
View Full Code Here

        verify(Integer.MAX_VALUE - 1);
        verify(Integer.MAX_VALUE);
    }

    private static void verify(int i) throws IOException {
        FastByteArrayOutputStream os = new FastByteArrayOutputStream(256);
        VariableByteCodec.encodeInt(i, os);
        byte[] b1 = os.toByteArray();
        Assert.assertEquals(i, VariableByteCodec.decodeInt(b1));
    }
View Full Code Here

    public static byte[] compress(final char[] input) {
        int n = input.length;
        int bitwidth = estimateAdequateBitWidth(input, n);
        CompressedSegment segment = new CompressedSegment(bitwidth);
        compress(input, n, segment);
        FastByteArrayOutputStream bos = new FastByteArrayOutputStream(4096);
        DataOutputStream dos = new DataOutputStream(bos);
        try {
            segment.writeTo(dos);
            dos.flush();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        byte[] b = bos.toByteArray();
        return b;
    }
View Full Code Here

    }

    public static byte[] compress(final char[] input, final int bitwidth) {
        CompressedSegment segment = new CompressedSegment(bitwidth);
        compress(input, input.length, segment);
        FastByteArrayOutputStream bos = new FastByteArrayOutputStream(4096);
        DataOutputStream dos = new DataOutputStream(bos);
        try {
            segment.writeTo(dos);
            dos.flush();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        byte[] b = bos.toByteArray();
        return b;
    }
View Full Code Here

            final ObjectInputStream objInput = new AppendedObjectInputStream(inputBuf);
            this._decoder = new XQEventDecoder(objInput); // replace Old Decoder with fresh Decoder
        }

        private void incrBulkOut(final ObjectOutput out) throws IOException {
            final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
            final ObjectOutputStream objectOut = new ObjectOutputStream(bufOut);
            final XQEventDecoder decoder = _decoder;
            decoder.redirectTo(objectOut);
            decoder.close();
            objectOut.flush();
            final byte[] buf = bufOut.toByteArray();
            bufOut.clear();

            // Because input of decoder fully read, this section required for re-object serialization, etc.
            if(_reaccessable) {
                final FastByteArrayInputStream inputBuf = new FastByteArrayInputStream(buf);
                final ObjectInputStream objectInput = new ObjectInputStream(inputBuf);
View Full Code Here

        return decoder;
    }

    private static void bulkOut(ObjectOutput out, Sequence<Item> entity, boolean remotePaing)
            throws IOException {
        final FastByteArrayOutputStream bufOut = new FastByteArrayOutputStream(16384);
        final ObjectOutputStream objOut = new ObjectOutputStream(bufOut);
        final XQEventEncoder encoder = new XQEventEncoder(objOut);
        if(remotePaing) {
            encoder.setRemotePaging(true);
        }
        try {
            encoder.emit(entity);
        } catch (XQueryException xqe) {
            throw new IllegalStateException("failed encoding", xqe);
        } catch (Throwable e) {
            LOG.fatal(e);
            throw new IllegalStateException("failed encoding", e);
        } finally {
            objOut.flush();
        }
        final byte[] buf = bufOut.toByteArray();
        bufOut.clear();
        final int buflen = buf.length;
        if(LOG.isDebugEnabled()) {
            LOG.debug("encoded sequence size: " + buflen);
        }
        out.writeInt(buflen);
View Full Code Here

TOP

Related Classes of xbird.util.io.FastByteArrayOutputStream

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.