Package xbird.xquery.dm.coder

Examples of xbird.xquery.dm.coder.XQEventDecoder


                IncrDecodedSequnece entity = IncrDecodedSequnece.readFrom(in);
                entity._type = type;
                this._entity = entity;
            } else {
                final boolean piped = in.readBoolean();
                final XQEventDecoder decoder;
                if(piped) {
                    this._piped = true;
                    decoder = pipedIn(in, _reaccessable);
                } else {
                    this._piped = false;
                    decoder = bulkIn(in); // This is required for nested Object serialization/deserialization                   
                }
                if(DEBUG_DESER_SPEED) {
                    try {
                        this._entity = decoder.decode();
                    } catch (XQueryException e) {
                        throw new IllegalStateException("failed decoding", e);
                    }
                } else {
                    final IncrDecodedSequnece entity = new IncrDecodedSequnece(decoder, type);
View Full Code Here


    }

    private static XQEventDecoder pipedIn(ObjectInput in, boolean reaccessable) throws IOException {
        final FastMultiByteArrayOutputStream bufOut = new FastMultiByteArrayOutputStream(BUFFERING_BLOCK_SIZE);
        final ObjectOutputStream objectOut = new ObjectOutputStream(bufOut);
        final XQEventDecoder decoder = new XQEventDecoder(in);
        decoder.redirectTo(objectOut);
        objectOut.flush();

        final byte[][] buf = bufOut.toMultiByteArray();
        final int totalBufSize = bufOut.size();
        bufOut.clear();

        // Because input of decoder fully read, this section required for re-object serialization, etc.
        final FastMultiByteArrayInputStream inputBuf = new FastMultiByteArrayInputStream(buf, BUFFERING_BLOCK_SIZE, totalBufSize);
        if(!reaccessable) {
            inputBuf.setCleanable(true);
        }
        final ObjectInputStream objectInput = new ObjectInputStream(inputBuf);
        final XQEventDecoder newDecoder = new XQEventDecoder(objectInput); // replace old Decoder with fresh Decoder
        return newDecoder;
    }
View Full Code Here

        if(LOG.isDebugEnabled()) {
            LOG.debug("decoding sequence size: " + inputLen);
        }
        FastByteArrayInputStream inputBuf = new FastByteArrayInputStream(buf);
        ObjectInputStream objInput = new ObjectInputStream(inputBuf);
        XQEventDecoder decoder = new XQEventDecoder(objInput);
        return decoder;
    }
View Full Code Here

            }
        }

        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
            assert (_toReplace == null);
            final XQEventDecoder decoder = new XQEventDecoder(in);
            final Sequence<Item> decoded;
            try {
                decoded = decoder.decode();
            } catch (IOException ioe) {
                throw new XQRTException("decode failed", ioe);
            } catch (XQueryException xqe) {
                throw new XQRTException(xqe);
            } catch (Throwable e) {
View Full Code Here

            if(isRemoteSeq) {
                this._result = RemoteSequence.readFrom(in);
            } else {
                final StopWatch sw = new StopWatch("Elapsed time for decoding `$" + getName()
                        + '\'');
                final XQEventDecoder decoder = new XQEventDecoder(in);
                try {
                    this._result = decoder.decode();
                } catch (XQueryException xqe) {
                    throw new IllegalStateException("failed decoding `$" + getName() + '\'', xqe);
                } catch (Throwable e) {
                    throw new IllegalStateException("failed decoding `$" + getName() + '\'', e);
                }
View Full Code Here

            }
        }

        private void incrPipedOut(final ObjectOutputStream out) throws IOException {
            assert (!_reaccessable);
            final XQEventDecoder decoder = _decoder;
            decoder.redirectTo(out);
            decoder.close();
        }
View Full Code Here

        private void incrPipedOutReaccessable(final ObjectOutputStream out) throws IOException {
            assert (_reaccessable);
            final FastMultiByteArrayOutputStream bufOut = new FastMultiByteArrayOutputStream(BUFFERING_BLOCK_SIZE);
            final TeeOutputStream tee = new TeeOutputStream(out, bufOut);
            final ObjectOutputStream objectOut = new NoHeaderObjectOutputStream(tee);
            final XQEventDecoder decoder = _decoder;
            decoder.redirectTo(objectOut);
            decoder.close();
            objectOut.flush();

            // Because input of decoder fully read, this section required for re-object serialization, etc.
            final byte[][] buf = bufOut.toMultiByteArray();
            final int bufTotalSize = bufOut.size();
            bufOut.clear();
            final FastMultiByteArrayInputStream inputBuf = new FastMultiByteArrayInputStream(buf, BUFFERING_BLOCK_SIZE, bufTotalSize);
            if(!_reaccessable) {
                inputBuf.setCleanable(true);
            }
            final ObjectInputStream objInput = new NoHeaderObjectInputStream(inputBuf);
            this._decoder = new XQEventDecoder(objInput); // replace old Decoder with fresh Decoder
        }
View Full Code Here

        }

        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);
                this._decoder = new XQEventDecoder(objectInput); // replace old Decoder with fresh Decoder
            }

            final int buflen = buf.length;
            if(LOG.isDebugEnabled()) {
                LOG.debug("encoded sequence size: " + buflen);
View Full Code Here

    }

    private static Sequence decode(final byte[] b) throws IOException {
        FastByteArrayInputStream inputBuf = new FastByteArrayInputStream(b);
        ObjectInputStream objInput = new ObjectInputStream(inputBuf);
        final XQEventDecoder decoder = new XQEventDecoder(objInput);
        try {
            return decoder.decode();
        } catch (XQueryException e) {
            throw new IOException(PrintUtils.prettyPrintStackTrace(e));
        }
    }
View Full Code Here

            if(isRemoteSeq) {
                this._result = RemoteSequence.readFrom(in);
            } else {
                final StopWatch sw = new StopWatch("Elapsed time for decoding `$" + getName()
                        + '\'');
                final XQEventDecoder decoder = new XQEventDecoder(in);
                try {
                    this._result = decoder.decode();
                } catch (XQueryException xqe) {
                    throw new IllegalStateException("failed decoding `$" + getName() + '\'', xqe);
                } catch (Throwable e) {
                    throw new IllegalStateException("failed decoding `$" + getName() + '\'', e);
                }
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.coder.XQEventDecoder

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.