Package xbird.xquery.dm.value.sequence

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


    private static final String queryFile = "C:/Users/myui/workspace/xbird-db/examples/xqueryd/xmark/local/xpathmark05.xq";

    public void testNormalSequence() throws FileNotFoundException, XQueryException {
        System.out.println(" ============ Materialized ============ ");
        final Sequence<? extends Item> result = doQuery(queryFile);
        final ValueSequence materialized = new ValueSequence(result.materialize(), null);

        StopWatch sw01 = new StopWatch("Sequence encoding time");
        byte[] encoded0 = ObjectUtils.toBytes(materialized);
        System.err.println(sw01);
View Full Code Here


        final ReturnType returnType = request.getReturnType();
        final Serializable ret;
        switch(returnType) {
            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:
View Full Code Here

            }
        }
        if(prefixes.isEmpty()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        return new ValueSequence(prefixes, dynEnv);
    }
View Full Code Here

            return ValueSequence.EMPTY_SEQUENCE;
        }
        if(items.size() == 1) {
            return items.get(0);
        }
        return new ValueSequence(items, DynamicContext.DUMMY);
    }
View Full Code Here

                } else {
                    skvItor = new NestedIterator<Item>(skvItor, skv.iterator());
                }
            }
            JoinTable joinTable = _joinTable;
            final ValueSequence vs = new ValueSequence(dynEnv);
            while(skvItor.hasNext()) {
                final Comparable searchKey;
                if(searchKeyLen == 1) {
                    final Item fsv = skvItor.next();
                    searchKey = mapArgument(fsv, 0, dynEnv);
                } else {
                    final Comparable[] searchKeys = new Comparable[searchKeyLen];
                    for(int i = 0; i < searchKeyLen; i++) {
                        Item fsv = skvItor.next();
                        searchKeys[i] = mapArgument(fsv, i, dynEnv);
                    }
                    searchKey = new JoinTable.Key(searchKeys, _opr);
                }
                final IFocus<Item> jsItor = joinTable.entrySequence(searchKey, dynEnv).iterator();
                for(Item entry : jsItor) {
                    vs.addItem(entry);
                }
                jsItor.closeQuietly();
            }
            if(vs.isEmpty()) {
                return ValueSequence.EMPTY_SEQUENCE;
            }
            return vs;
        }
View Full Code Here

                    skvItor = itor;
                } else {
                    skvItor = new NestedIterator<Item>(skvItor, itor);
                }
            }
            final ValueSequence vs = new ValueSequence(dynEnv);
            while(skvItor.hasNext()) {
                final Comparable searchKey;
                if(searchKeyLen == 1) {
                    final Item fsv = skvItor.next();
                    searchKey = mapArgument(fsv, 0, dynEnv);
                } else {
                    final Comparable[] searchKeys = new Comparable[searchKeyLen];
                    for(int i = 0; i < searchKeyLen; i++) {
                        Item fsv = skvItor.next();
                        searchKeys[i] = mapArgument(fsv, i, dynEnv);
                    }
                    searchKey = new JoinTable.Key(searchKeys, _opr);
                }
                if(_joinTable == null) {
                    this._joinTable = future.get();
                }
                final IFocus<Item> js = _joinTable.entrySequence(searchKey, dynEnv).iterator();
                for(Item entry : js) {
                    vs.addItem(entry);
                }
                js.closeQuietly();
            }
            if(vs.isEmpty()) {
                return ValueSequence.EMPTY_SEQUENCE;
            }
            return vs;
        }
View Full Code Here

                final Entry entry = find(key);
                if(entry == null) {
                    return ValueSequence.EMPTY_SEQUENCE;
                }
                Item[] items = entry.getItems();
                return new ValueSequence(Arrays.asList(items), dynEnv);
            }
            assert (_orderedKey != null);
            final SortedSet<Comparable> sorted;
            if(_opr.indexOf('<') != -1) { // <
                SortedSet<Comparable> heads = _orderedKey.headSet(key); // note that headSet contains key itself.
View Full Code Here

            this._result = _value.eval(contextSeq, dynEnv);
        } else if(ENV_PATH_ELIM) {
            if(!_materialized) {
                if(!(_result instanceof Item)) {
                    Collection<Item> c = _result.materialize();
                    ValueSequence vs = new ValueSequence(new ArrayList<Item>(c), dynEnv);
                    this._result = vs;
                }
                this._materialized = true;
            }
        }
View Full Code Here

        LetVariable lv = (LetVariable) _variable;
        XQExpression letExpr = lv.getValue();
        Sequence<? extends Item> res = letExpr.eval(contextSeq, dynEnv);
        if(lv.attemptEagarEvaluation() && lv.getReferenceCount() > 1) {
            List<? extends Item> items = res.materialize(); // TODO REVIEWME weak memory utilization
            lv.allocateResult(new ValueSequence(items, dynEnv), dynEnv);
        } else {
            lv.allocateResult(res, dynEnv);
        }
        return res;
    }
View Full Code Here

        if(pos < 1) {
            pos = 1;
        }
        Item inserts = argv.getItem(2);
        if(target instanceof ValueSequence) {
            ValueSequence vs = (ValueSequence) target;
            final int last = vs.size();
            if(pos > last) {
                pos = last;
            }
            vs.addSequence(pos - 1, inserts);
            return vs;
        } else {
            return new InsertEmuration(target, inserts, pos, dynEnv);
        }
    }
View Full Code Here

TOP

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

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.