Package edu.uci.ics.hyracks.data.std.util

Examples of edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage


    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final XSQNamePointable qnamep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        final DataOutput dOut = abvs.getDataOutput();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                TaggedValuePointable tvp1 = args[0];

                // Only accept a QNames or empty sequence.
                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp1.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptySequence(result);
                        return;
                    }
                    // Pass through.
                }
                if (tvp1.getTag() != ValueTag.XS_QNAME_TAG) {
                    throw new SystemException(ErrorCode.FORG0006);
                }
                tvp1.getValue(qnamep);
                qnamep.getPrefix(stringp);

                try {
                    // Return empty sequence if no prefix.
                    if (qnamep.getPrefixLength() == 0) {
                        XDMConstants.setEmptySequence(result);
                    } else {
                        abvs.reset();
                        dOut.write(ValueTag.XS_NCNAME_TAG);
                        dOut.write(stringp.getByteArray(), stringp.getStartOffset(), stringp.getLength());
                        result.set(abvs);
                    }
                } catch (Exception e) {
View Full Code Here


    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final XSQNamePointable qnamep = (XSQNamePointable) XSQNamePointable.FACTORY.createPointable();
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        final DataOutput dOut = abvs.getDataOutput();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                TaggedValuePointable tvp1 = args[0];

                // Only accept a QNames or empty sequence.
                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp1.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptySequence(result);
                        return;
                    }
                    // Pass through.
                }
                if (tvp1.getTag() != ValueTag.XS_QNAME_TAG) {
                    throw new SystemException(ErrorCode.FORG0006);
                }
                tvp1.getValue(qnamep);
                qnamep.getUri(stringp);

                try {
                    if (qnamep.getUriLength() == 0) {
                        XDMConstants.setEmptyString(result);
                    } else {
                        abvs.reset();
                        dOut.write(ValueTag.XS_NCNAME_TAG);
                        dOut.write(stringp.getByteArray(), stringp.getStartOffset(), stringp.getLength());
                        result.set(abvs);
                    }
                } catch (Exception e) {
View Full Code Here

    private int childrenCount;

    public DocumentNodeBuilder() {
        childrenSlots = new GrowableIntArray();
        childrenDataArea = new ArrayBackedValueStorage();
    }
View Full Code Here

       
        Map<QName, ArrayBackedValueStorage> vMap = dCtx.getVariableMap();
        int nVars = vMap.size();
        QName[] variableNames = new QName[nVars];
        int[] valueOffsets = new int[nVars];
        ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        int i = 0;
        for (Map.Entry<QName, ArrayBackedValueStorage> e : vMap.entrySet()) {
            variableNames[i] = e.getKey();
            abvs.append(e.getValue());
            valueOffsets[i] = abvs.getLength();
            ++i;
        }

        return new DynamicContextImplFactory(scFactory, currentDateTime, variableNames, valueOffsets,
                Arrays.copyOfRange(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength()));
    }
View Full Code Here

    private int childrenCount;

    public ElementNodeBuilder() {
        attrSlots = new GrowableIntArray();
        attrDataArea = new ArrayBackedValueStorage();
        childrenSlots = new GrowableIntArray();
        childrenDataArea = new ArrayBackedValueStorage();
    }
View Full Code Here

        value.set(currentDateTime, 0, currentDateTime.length);
    }

    @Override
    public void bindVariable(QName var, IValueReference value) {
        ArrayBackedValueStorage abvs = variables.get(var);
        if (abvs == null) {
            abvs = new ArrayBackedValueStorage();
            variables.put(var, abvs);
        }
        abvs.assign(value);
    }
View Full Code Here

        abvs.assign(value);
    }

    @Override
    public void lookupVariable(QName var, IPointable value) {
        ArrayBackedValueStorage abvs = variables.get(var);
        if (abvs == null) {
            value.set(null, -1, -1);
        } else {
            value.set(abvs);
        }
View Full Code Here

    private int nodeIdCounter;

    private boolean pendingText;

    public SAXContentHandler(boolean attachTypes, ITreeNodeIdProvider nodeIdProvider) {
        docABVS = new ArrayBackedValueStorage();
        this.createNodeIds = nodeIdProvider != null;
        this.attachTypes = attachTypes;
        this.nodeIdProvider = nodeIdProvider;
        this.tempABVS = new ArrayBackedValueStorage();
        docb = new DocumentNodeBuilder();
        tnb = new TextNodeBuilder();
        cnb = new CommentNodeBuilder();
        pinb = new PINodeBuilder();
        anb = new AttributeNodeBuilder();
View Full Code Here

                throw new IllegalStateException("Unknown node: " + itemType.getTag());
        }
    }

    private byte[] createUTF8String(String str) {
        ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        StringValueBuilder svb = new StringValueBuilder();
        try {
            svb.write(str, abvs.getDataOutput());
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        return Arrays.copyOf(abvs.getByteArray(), abvs.getLength());
    }
View Full Code Here

    }

    @Override
    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        final SequenceBuilder sb = new SequenceBuilder();
        final SequencePointable seq = new SequencePointable();
        final VoidPointable p = (VoidPointable) VoidPointable.FACTORY.createPointable();
        final DoublePointable doublep = (DoublePointable) DoublePointable.FACTORY.createPointable();
        final LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
        final XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvsRound = new ArrayBackedValueStorage();
        final FnRoundOperation round = new FnRoundOperation();
        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                try {
                    long startingLoc;
                    TaggedValuePointable tvp2 = args[1];
                    startingLoc = getLongFromArgument(tvp2);
                    if (startingLoc < 1) {
                        startingLoc = 1;
                    }

                    // Get length.
                    long endingLoc = Long.MAX_VALUE;
                    if (args.length > 2) {
                        TaggedValuePointable tvp3 = args[2];
                        endingLoc = getLongFromArgument(tvp3) + startingLoc;
                    }

                    abvs.reset();
                    sb.reset(abvs);
                    TaggedValuePointable tvp1 = args[0];
                    if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                        tvp1.getValue(seq);
                        int seqLen = seq.getEntryCount();
                        if (endingLoc < startingLoc) {
                            // Empty sequence.
                        } else if (startingLoc == 1 && endingLoc > seqLen) {
                            // Includes whole sequence.
                            result.set(tvp1);
                            return;
                        } else {
                            for (int j = 0; j < seqLen; ++j) {
                                if (startingLoc <= j + 1 && j + 1 < endingLoc) {
                                    seq.getEntry(j, p);
                                    sb.addItem(p);
                                }
                            }
                        }
                    } else if (startingLoc == 1 && endingLoc > 1) {
                        // Includes item.
                        result.set(tvp1);
                        return;
                    }
                    sb.finish();
                    result.set(abvs);
                } catch (IOException e) {
                    throw new SystemException(ErrorCode.SYSE0001);
                }
            }

            /**
             * XQuery Specification calls for double value. Integer and Decimal are allowed to cut down on casting.
             *
             * @param tvp
             * @return
             * @throws SystemException
             * @throws IOException
             */
            public long getLongFromArgument(TaggedValuePointable tvp) throws SystemException, IOException {
                if (tvp.getTag() == ValueTag.XS_DOUBLE_TAG) {
                    tvp.getValue(doublep);
                    abvsRound.reset();
                    round.operateDouble(doublep, abvsRound.getDataOutput());
                    doublep.set(abvsRound.getByteArray(), abvsRound.getStartOffset() + 1,
                            DoublePointable.TYPE_TRAITS.getFixedLength());
                    return doublep.longValue();
                } else if (tvp.getTag() == ValueTag.XS_INTEGER_TAG) {
                    tvp.getValue(longp);
                    return longp.longValue();
View Full Code Here

TOP

Related Classes of edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage

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.