Package xbird.xquery.dm.value.sequence

Examples of xbird.xquery.dm.value.sequence.MarshalledSequence


        if(seq instanceof MarshalledSequence) {
            if(((MarshalledSequence) seq).isRedirectable()) {
                return seq;
            }
        }
        final MarshalledSequence res = new MarshalledSequence(seq, DynamicContext.DUMMY);
        res.setRedirectable(true);
        return res;
    }
View Full Code Here


    }

    public void invokeTest(boolean piped) throws FileNotFoundException, XQueryException {
        final Sequence<? extends Item> result = doQuery(queryFile);

        MarshalledSequence serResult = new MarshalledSequence(result, DynamicContext.DUMMY);       
        serResult.setPiped(piped);

        StopWatch sw1 = new StopWatch("SerializedSequence encoding time");
        byte[] encoded = ObjectUtils.toBytes(serResult);
        System.err.println(sw1);

        System.err.println("encoded size: " + encoded.length + " bytes");

        StopWatch sw2 = new StopWatch("SerializedSequence decoding time");
        Sequence<Item> decodedSeq1 = ObjectUtils.readObjectQuietly(encoded);
        System.err.println(sw2);

        StopWatch sw3 = new StopWatch("IncrementalDecodedSequnece encoding time");
        byte[] encoded2 = ObjectUtils.toBytes(decodedSeq1);
        System.err.println(sw3);

        StopWatch sw4 = new StopWatch("IncrementalDecodedSequnece decoding time");
        Sequence<Item> decodedSeq2 = ObjectUtils.readObjectQuietly(encoded2);
        System.err.println(sw4);

        MarshalledSequence reaccessed2 = (MarshalledSequence) decodedSeq2;
        reaccessed2.setReaccessable(true);
       
        // partial decode
        Iterator<Item> itor2 = decodedSeq2.iterator();
        for(int i = 0; i < 75; i++) {
            itor2.next();
        }

        StopWatch sw5 = new StopWatch("IncrementalDecodedSequnece (partially decoded: 100 items)  encoding time");
        byte[] encoded3 = ObjectUtils.toBytes(decodedSeq2);
        System.err.println(sw5);

        StopWatch sw6 = new StopWatch("IncrementalDecodedSequnece (partially decoded: 100 items) decoding time");
        Sequence<Item> decodedSeq3 = ObjectUtils.readObjectQuietly(encoded3);
        MarshalledSequence reaccessed3 = (MarshalledSequence) decodedSeq3;
        reaccessed3.setReaccessable(true);
        System.err.println(sw6);

        // full decode
        int count1 = 0;
        for(Item it : decodedSeq3) {
View Full Code Here

                return ret;
            } else {
                if(LOG.isInfoEnabled()) {
                    LOG.info("Response method for a task [" + task.getTaskId() + "]: DataShipping");
                }
                MarshalledSequence seq = new MarshalledSequence(result, DynamicContext.DUMMY);
                seq.setRemotePaging(true);
                return seq;
            }
        } else {
            if(LOG.isInfoEnabled()) {
                LOG.info("Response method for a task [" + task.getTaskId() + "]: Raw Sequence");
View Full Code Here

            return wrapResult(piped);
        }
    }

    private static Sequence<? extends Item> wrapResult(final Sequence<? extends Item> seq) {
        final MarshalledSequence res = new MarshalledSequence(seq, DynamicContext.DUMMY);
        res.setRedirectable(true);
        return res;
    }
View Full Code Here

        if(seq instanceof MarshalledSequence) {
            if(((MarshalledSequence) seq).isRedirectable()) {
                return seq;
            }
        }
        final MarshalledSequence res = new MarshalledSequence(seq, DynamicContext.DUMMY);
        res.setRedirectable(redirectable);
        return res;
    }
View Full Code Here

                if(LOG.isInfoEnabled()) {
                    LOG.info("Response method for a task [" + task.getTaskId()
                            + "]: DataShipping [type:" + ClassUtils.getSimpleClassName(result)
                            + ']');
                }
                final MarshalledSequence seq = new MarshalledSequence(result, DynamicContext.DUMMY);
                seq.setRemotePaging(true);
                return seq;
            }
        } else {
            if(LOG.isInfoEnabled()) {
                LOG.info("Response method for a task [" + task.getTaskId() + "]: IncrEvalSequence");
View Full Code Here

            return wrapResult(piped, isRedirectable, this);
        }
    }

    private static Sequence<? extends Item> wrapResult(final Sequence<? extends Item> seq, final boolean isRedirectable, final QueryExecJob job) {
        final MarshalledSequence res = new MarshalledSequence(seq, DynamicContext.DUMMY);
        res.setRedirectable(isRedirectable);
        if(LOG.isInfoEnabled()) {
            LOG.info("Response of a job [" + job.getJobId() + "] is "
                    + (isRedirectable ? "redirected" : "not redirected"));
        }
        return res;
View Full Code Here

            case SEQUENCE:
                final List<Item> materialized = result.materialize();
                ret = new ValueSequence(materialized, dynEnv);
                break;
            case MARSHALLED_SEQUENCE:
                ret = new MarshalledSequence(result, dynEnv);
                break;
            case AUTO:
            case REDIRECTABLE_MARSHALLED_SEQUENCE:
            case REMOTE_PADED_SEQUENCE: {
                final RedirectableChecker check = new RedirectableChecker();
                try {
                    check.visit(queryExpr, null);
                } catch (XQueryException e) {
                    throw new IllegalStateException(e);
                }
                if(check.isRedirectable()) {
                    MarshalledSequence seq = new MarshalledSequence(result, dynEnv);
                    seq.setRedirectable(true);
                    ret = seq;
                } else if(returnType == ReturnType.REMOTE_PADED_SEQUENCE) {
                    MarshalledSequence seq = new MarshalledSequence(result, dynEnv);
                    seq.setRemotePaging(true);
                    ret = seq;
                } else if(returnType == ReturnType.AUTO) {// treat as THROTTLED_ASYNC_REMOTE_SEQUENCE
                    final ThrottedRemoteSequenceProxy remote = new ThrottedRemoteSequenceProxy(_throttle, result, request);
                    try {
                        UnicastRemoteObject.exportObject(remote, 0, TimeoutSocketProdiver.createClientSocketFactory(), TimeoutSocketProdiver.createServerSocketFactory());
                    } catch (RemoteException e) {
                        throw new IllegalStateException("failed exporting result sequence", e);
                    }
                    ret = new RemoteSequence(remote, result.getType());
                    _executors.execute(remote);
                } else {
                    assert (returnType == ReturnType.REDIRECTABLE_MARSHALLED_SEQUENCE) : returnType;
                    ret = new MarshalledSequence(result, dynEnv);
                }
                break;
            }
            case REMOTE_SEQUENCE: {
                final RemoteSequenceProxy remote = new RemoteSequenceProxy(result, request);
View Full Code Here

    private static void prepareVariablesToShip(final QueryRequest request, final ShippedVariable shippedVar, final Sequence<? extends Item> contextSeq, final DynamicContext dynEnv)
            throws XQueryException {
        final Sequence result = shippedVar.eval(contextSeq, dynEnv);
        final ReturnType rettype = request.getReturnType();
        if(RemoteEval.ENV_NOWRAP_VARSHIP || !rettype.isRemoteSequnece()) {
            shippedVar.setResult(new MarshalledSequence(result, dynEnv));
        } else if(result instanceof SingleItem) {
            shippedVar.setResult(result);
        } else {
            final RemoteSequenceProxy proxy = new RemoteSequenceProxy(result, request);
            try {
View Full Code Here

            result = var.eval(contextSeq, dynEnv);
        }
        ReturnType rettype = request.getReturnType();
        final ShippedVariable shiped;
        if(ENV_NOWRAP_VARSHIP || !rettype.isRemoteSequnece()) {
            shiped = new ShippedVariable(varname, new MarshalledSequence(result, dynEnv));
        } else {
            final RemoteSequenceProxy proxy = new RemoteSequenceProxy(result, request);
            try {
                UnicastRemoteObject.exportObject(proxy, 0, TimeoutSocketProdiver.createClientSocketFactory(), TimeoutSocketProdiver.createServerSocketFactory());
            } catch (RemoteException e) {
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.value.sequence.MarshalledSequence

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.