Package org.apache.vxquery.datamodel.accessors

Examples of org.apache.vxquery.datamodel.accessors.SequencePointable


        final AtomizeHelper ah = new AtomizeHelper();
        final FunctionHelper.TypedPointables tp1 = new FunctionHelper.TypedPointables();
        final FunctionHelper.TypedPointables tp2 = new FunctionHelper.TypedPointables();
        final DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
        final SequencePointable seqp1 = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final SequencePointable seqp2 = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final VoidPointable p1 = (VoidPointable) VoidPointable.FACTORY.createPointable();
        final VoidPointable p2 = (VoidPointable) VoidPointable.FACTORY.createPointable();
        final TaggedValuePointable tvpSeq1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpSeq2 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpTransform1 = (TaggedValuePointable) TaggedValuePointable.FACTORY
                .createPointable();
        final TaggedValuePointable tvpTransform2 = (TaggedValuePointable) TaggedValuePointable.FACTORY
                .createPointable();
        final TaggedValuePointable tvpCompare1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpCompare2 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            AbstractCastToOperation aCastToOp = new CastToStringOperation();

            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                boolean booleanResult = false;
                TaggedValuePointable tvpArg1 = args[0];
                TaggedValuePointable tvpArg2 = args[1];
                try {
                    if (tvpArg1.getTag() == ValueTag.SEQUENCE_TAG) {
                        tvpArg1.getValue(seqp1);
                        int seqLen = seqp1.getEntryCount();
                        for (int j = 0; j < seqLen; ++j) {
                            seqp1.getEntry(j, p1);
                            tvpSeq1.set(p1.getByteArray(), p1.getStartOffset(), p1.getLength());
                            if (evaluateTaggedValueArgument2(aOp, tvpSeq1, tvpArg2, dCtx)) {
                                booleanResult = true;
                                break;
                            }
                        }
                    } else {
                        booleanResult = evaluateTaggedValueArgument2(aOp, tvpArg1, tvpArg2, dCtx);
                    }

                    byte[] byteResult = new byte[2];
                    byteResult[0] = ValueTag.XS_BOOLEAN_TAG;
                    byteResult[1] = (byte) (booleanResult ? 1 : 0);
                    result.set(byteResult, 0, 2);
                } catch (SystemException se) {
                    throw se;
                } catch (Exception e) {
                    throw new SystemException(ErrorCode.SYSE0001, e);
                }
            }

            /**
             * Check the second argument for a sequence and loop if required.
             *
             * @param aOp
             * @param tvpArg1
             * @param tvpArg2
             * @param dCtx
             * @return
             * @throws SystemException
             */
            protected boolean evaluateTaggedValueArgument2(AbstractValueComparisonOperation aOp,
                    TaggedValuePointable tvpArg1, TaggedValuePointable tvpArg2, DynamicContext dCtx)
                    throws SystemException {
                try {
                    if (tvpArg2.getTag() == ValueTag.SEQUENCE_TAG) {
                        tvpArg2.getValue(seqp2);
                        int seqLen = seqp2.getEntryCount();
                        for (int j = 0; j < seqLen; ++j) {
                            seqp2.getEntry(j, p2);
                            tvpSeq2.set(p2.getByteArray(), p2.getStartOffset(), p2.getLength());
                            if (transformThenCompareTaggedValues(aOp, tvpArg1, tvpSeq2, dCtx)) {
                                return true;
                            }
                        }
View Full Code Here


            throws AlgebricksException {
        final UTF8StringPointable stringp1 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final UTF8StringPointable stringp2 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final UTF8StringPointable stringp3 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final byte[] integerResult = new byte[LongPointable.TYPE_TRAITS.getFixedLength() + 1];
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();

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

                // Only accept strings or empty sequence as input.
                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp1.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptySequence(result);
                        return;
                    } else {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                } else {
                    if (!FunctionHelper.isDerivedFromString(tvp1.getTag())) {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                    tvp1.getValue(stringp1);
                }
                if (tvp2.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp2.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptySequence(result);
                        return;
                    } else {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
View Full Code Here

                    }
                    break;
                }
                case ValueTag.ELEMENT_NODE_TAG: {
                    ElementNodePointable enp = pp.takeOne(ElementNodePointable.class);
                    SequencePointable sp2 = pp.takeOne(SequencePointable.class);
                    try {
                        tempTVP2.getValue(enp);
                        if (enp.childrenChunkExists()) {
                            enp.getChildrenSequence(ntp, sp2);
                            buildConcatenationRec(sp2, pp, out, ntp);
View Full Code Here

        final DoublePointable doublep = (DoublePointable) DoublePointable.FACTORY.createPointable();
        final LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        final SubstringCharacterIterator charIterator = new SubstringCharacterIterator(new UTF8StringCharacterIterator(
                stringp));
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();

        return new AbstractCharacterIteratorCopyingEvaluator(args, charIterator) {
            @Override
            protected void preEvaluate(TaggedValuePointable[] args) throws SystemException {
                int startingLocation = 1;
                int length = Integer.MAX_VALUE;
                abvs.reset();
                charIterator.reset();

                // Only accept string, double, and optional double as input.
                TaggedValuePointable tvp1 = args[0];
                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp1.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptyString(tvp);
                        tvp.getValue(stringp);
                    } else {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
View Full Code Here

    @Override
    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpNext = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpSum = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpCount = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        final DataOutput dOut = abvs.getDataOutput();
        final AddOperation aOp = new AddOperation();
        final DivideOperation aOpDivide = new DivideOperation();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                TaggedValuePointable tvp = args[0];
                if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp.getValue(seqp);
                    int seqLen = seqp.getEntryCount();
                    if (seqLen == 0) {
                        XDMConstants.setEmptySequence(result);
                    } else {
                        // Add up the sequence.
                        for (int j = 0; j < seqLen; ++j) {
                            seqp.getEntry(j, tvpNext);
                            if (j == 0) {
                                // Init.
                                tvpSum.set(tvpNext);
                            } else {
                                FunctionHelper.arithmeticOperation(aOp, dCtx, tvpNext, tvpSum, tvpSum);
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 DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
        final AbstractValueComparisonOperation aOp = new ValueEqComparisonOperation();
        final TaggedValuePointable tvpDistinct = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpCheck = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final VoidPointable p = (VoidPointable) VoidPointable.FACTORY.createPointable();
        final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                try {
                    abvs.reset();
                    sb.reset(abvs);
                    TaggedValuePointable tvp1 = args[0];
                    // Second  parameter is optional.
                    if (args.length > 1) {
                        TaggedValuePointable tvp2 = args[1];
                        if (tvp2.getTag() != ValueTag.XS_STRING_TAG) {
                            throw new SystemException(ErrorCode.FORG0006);
                        }
                        tvp2.getValue(stringp);
                    }
                    // TODO use the third value as collation

                    if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                        tvp1.getValue(seq);
                        int seqLen = seq.getEntryCount();

                        // Add remaining distinct item.
                        boolean found = false;
                        for (int j = 0; j < seqLen; ++j) {
                            seq.getEntry(j, p);
                            tvpDistinct.set(p.getByteArray(), p.getStartOffset(), p.getLength());

                            // Check if item is distinct.
                            if (j + 1 < seqLen) {
                                for (int k = j + 1; k < seqLen; ++k) {
                                    seq.getEntry(k, p);
                                    tvpCheck.set(p.getByteArray(), p.getStartOffset(), p.getLength());
                                    if (FunctionHelper.compareTaggedValues(aOp, tvpDistinct, tvpCheck, dCtx)) {
                                        found = true;
                                        break;
                                    }
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 = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final VoidPointable p = (VoidPointable) VoidPointable.FACTORY.createPointable();
        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                try {
                    TaggedValuePointable tvp = args[0];
                    if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
                        abvs.reset();
                        sb.reset(abvs);
                        tvp.getValue(seq);
                        int seqLen = seq.getEntryCount();
                        for (int j = 0; j < seqLen; ++j) {
                            seq.getEntry(seqLen - j - 1, p);
                            sb.addItem(p);
                        }
                        sb.finish();
                        result.set(abvs);
                    } else {
View Full Code Here

     * @param nodePointable
     * @throws SystemException
     */
    protected void searchSubtree(TaggedValuePointable nodePointable) throws SystemException {
        try {
            SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
            boolean search = false;

            // Find all child element to search.
            switch (nodePointable.getTag()) {
                case ValueTag.DOCUMENT_NODE_TAG:
                    nodePointable.getValue(dnp);
                    dnp.getContent(ntp, seqp);
                    search = true;
                    break;

                case ValueTag.ELEMENT_NODE_TAG:
                    nodePointable.getValue(enp);
                    if (enp.childrenChunkExists()) {
                        enp.getChildrenSequence(ntp, seqp);
                        search = true;
                    }
                    break;
            }

            if (search) {
                int seqSize = seqp.getEntryCount();
                for (int i = 0; i < seqSize; ++i) {
                    seqp.getEntry(i, itemTvp);
                    // Only search element nodes.
                    if (itemTvp.getTag() == ValueTag.ELEMENT_NODE_TAG) {
                        if (matches()) {
                            appendNodeToResult();
                        }
View Full Code Here

    }

    @Override
    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                TaggedValuePointable tvp = args[0];
                if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp.getValue(seqp);
                    if (seqp.getEntryCount() == 0 || seqp.getEntryCount() == 1) {
                        result.set(tvp);
                    } else {
                        throw new SystemException(ErrorCode.FORG0003);
                    }
                } else {
View Full Code Here

    /**
     * Find the next node to return.
     */
    protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result)
            throws AlgebricksException {
        SequencePointable seqItem = pp.takeOne(SequencePointable.class);
        try {
            getSequence(tvpInput, seqItem);
            int seqLength = seqItem.getEntryCount();
            while (indexSequence[level] < seqLength) {
                // Get the next item
                seqItem.getEntry(indexSequence[level], tvpItem);

                // Test to see if the item fits the path step
                if (filter.get(level).accept(ntp, tvpItem)) {
                    if (level + 1 < indexSequence.length) {
                        if (stepNodeTree(tvpItem, level + 1, result)) {
View Full Code Here

TOP

Related Classes of org.apache.vxquery.datamodel.accessors.SequencePointable

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.