Examples of TaggedValuePointable


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

                // Default result is false.
                byte[] booleanResult = new byte[2];
                booleanResult[0] = ValueTag.XS_BOOLEAN_TAG;
                booleanResult[1] = 0;

                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.XPTY0004);
                    }
                } else {
                    if (!FunctionHelper.isDerivedFromString(tvp1.getTag())) {
                        throw new SystemException(ErrorCode.XPTY0004);
                    }
                    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.XPTY0004);
                    }
                } else {
                    if (!FunctionHelper.isDerivedFromString(tvp2.getTag())) {
                        throw new SystemException(ErrorCode.XPTY0004);
                    }
                    tvp2.getValue(stringp2);
                }

                if (stringp1.compareTo(stringp2) == 0) {
                    booleanResult[1] = 1;
                }
View Full Code Here

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

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                dCtx.getCurrentDateTime(ctxDatetimep);
                TaggedValuePointable tvp1 = args[0];
                if (tvp1.getTag() != ValueTag.XS_TIME_TAG) {
                    throw new SystemException(ErrorCode.FORG0006);
                }
                tvp1.getValue(timep);

                // Second argument is optional and will used the dynamic context if not supplied.
                long tz;
                if (args.length == 2) {
                    TaggedValuePointable tvp2 = args[1];
                    if (tvp2.getTag() == ValueTag.XS_DAY_TIME_DURATION_TAG) {
                        tvp2.getValue(longp);
                        if (Math.abs(longp.getLong()) > DateTime.CHRONON_OF_HOUR * 14) {
                            throw new SystemException(ErrorCode.FODT0003);
                        }
                        tz = longp.getLong() / DateTime.CHRONON_OF_MINUTE;
                    } else {
View Full Code Here

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

    public AbstractTaggedValueArgumentUnnestingEvaluator(IScalarEvaluator[] args) {
        this.args = args;
        tvps = new TaggedValuePointable[args.length];
        for (int i = 0; i < tvps.length; ++i) {
            tvps[i] = new TaggedValuePointable();
        }
    }
View Full Code Here

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

        final UTF8StringPointable stringp3 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final SubstringBeforeCharacterIterator stringIterator = new SubstringBeforeCharacterIterator(
                new UTF8StringCharacterIterator(stringp1));
        final UTF8StringCharacterIterator searchIterator = new UTF8StringCharacterIterator(stringp2);
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();

        return new AbstractCharacterIteratorCopyingEvaluator(args, stringIterator) {
            @Override
            protected void preEvaluate(TaggedValuePointable[] args) 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.setEmptyString(tvp);
                        tvp.getValue(stringp1);
                    } 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.setEmptyString(tvp);
                        tvp.getValue(stringp2);
                    } else {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                } else {
                    if (!FunctionHelper.isDerivedFromString(tvp2.getTag())) {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                    tvp2.getValue(stringp2);
                }
                stringIterator.reset();
                searchIterator.reset();

                // Third parameter is optional.
                if (args.length > 2) {
                    TaggedValuePointable tvp3 = args[2];
                    if (!FunctionHelper.isDerivedFromString(tvp3.getTag())) {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                    tvp3.getValue(stringp3);
                }

                stringIterator.setSearch(searchIterator);
            }
        };
View Full Code Here

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

    public AbstractTaggedValueArgumentAggregateEvaluator(IScalarEvaluator[] args) {
        this.args = args;
        tvps = new TaggedValuePointable[args.length];
        for (int i = 0; i < tvps.length; ++i) {
            tvps[i] = new TaggedValuePointable();
        }
    }
View Full Code Here

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

            final DataOutput dOutInteger = abvsInteger.getDataOutput();
            final FunctionHelper.TypedPointables tp = new FunctionHelper.TypedPointables();

            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                TaggedValuePointable tvp = args[0];
                int tid = getBaseTypeForArithmetics(tvp.getTag());
                abvs.reset();
                try {
                    switch (tid) {
                        case ValueTag.SEQUENCE_TAG:
                            tvp.getValue(tp.seqp);
                            if (tp.seqp.getEntryCount() == 0) {
                                XDMConstants.setEmptySequence(result);
                                return;
                            }

                        case ValueTag.XS_DECIMAL_TAG:
                            tvp.getValue(tp.decp);
                            aOp.operateDecimal(tp.decp, dOut);
                            result.set(abvs);
                            return;

                        case ValueTag.XS_INTEGER_TAG:
                            LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
                            switch (tvp.getTag()) {
                                case ValueTag.XS_INTEGER_TAG:
                                case ValueTag.XS_NON_POSITIVE_INTEGER_TAG:
                                case ValueTag.XS_NEGATIVE_INTEGER_TAG:
                                case ValueTag.XS_LONG_TAG:
                                case ValueTag.XS_NON_NEGATIVE_INTEGER_TAG:
                                case ValueTag.XS_UNSIGNED_LONG_TAG:
                                case ValueTag.XS_POSITIVE_INTEGER_TAG:
                                case ValueTag.XS_INT_TAG:
                                case ValueTag.XS_UNSIGNED_INT_TAG:
                                case ValueTag.XS_SHORT_TAG:
                                case ValueTag.XS_UNSIGNED_SHORT_TAG:
                                case ValueTag.XS_BYTE_TAG:
                                case ValueTag.XS_UNSIGNED_BYTE_TAG:
                                    abvsInteger.reset();
                                    FunctionHelper.getIntegerPointable(tvp, dOutInteger);
                                    longp.set(abvsInteger.getByteArray(), abvsInteger.getStartOffset() + 1,
                                            LongPointable.TYPE_TRAITS.getFixedLength());
                            }
                            aOp.operateInteger(longp, dOut);
                            result.set(abvs);
                            return;

                        case ValueTag.XS_FLOAT_TAG:
                            tvp.getValue(tp.floatp);
                            aOp.operateFloat(tp.floatp, dOut);
                            result.set(abvs);
                            return;

                        case ValueTag.XS_DOUBLE_TAG:
                            tvp.getValue(tp.doublep);
                            aOp.operateDouble(tp.doublep, dOut);
                            result.set(abvs);
                            return;
                    }
                } catch (SystemException se) {
View Full Code Here

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

        final UTF8StringPointable stringp2 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final UTF8StringPointable stringp3 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final ICharacterIterator charIterator1 = new UTF8StringCharacterIterator(stringp1);
        final ICharacterIterator charIterator2 = new UTF8StringCharacterIterator(stringp2);
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                // Default result is false.
                byte[] booleanResult = new byte[2];
                booleanResult[0] = ValueTag.XS_BOOLEAN_TAG;
                booleanResult[1] = 0;

                TaggedValuePointable tvp1 = args[0];
                TaggedValuePointable tvp2 = args[1];

                // Only accept strings as input.
                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp1.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptyString(tvp);
                        tvp.getValue(stringp1);
                    } 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.setEmptyString(tvp);
                        tvp.getValue(stringp2);
                    } else {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                } else {
                    if (!FunctionHelper.isDerivedFromString(tvp2.getTag())) {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                    tvp2.getValue(stringp2);
                }
                int stringLength1 = stringp1.getStringLength();
                int stringLength2 = stringp2.getStringLength();
                charIterator1.reset();
                charIterator2.reset();

                // Third parameter is optional.
                if (args.length > 2) {
                    TaggedValuePointable tvp3 = args[2];
                    if (!FunctionHelper.isDerivedFromString(tvp3.getTag())) {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                    tvp3.getValue(stringp3);
                }
                // TODO use the third value as collation

                int stringCharOffset = stringLength1 - stringLength2;
View Full Code Here

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

        final DataOutput dOut = abvs.getDataOutput();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                TaggedValuePointable tvp1 = args[0];
                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp1.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptySequence(result);
                        return;
                    }
                }
                if (tvp1.getTag() != ValueTag.XS_DATE_TAG) {
                    throw new SystemException(ErrorCode.FORG0006);
                }
                tvp1.getValue(datep);

                TaggedValuePointable tvp2 = args[1];
                if (tvp2.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp2.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptySequence(result);
                        return;
                    }
                }
                if (tvp2.getTag() != ValueTag.XS_TIME_TAG) {
                    throw new SystemException(ErrorCode.FORG0006);
                }
                tvp2.getValue(timep);

                // Set the timezone.
                byte timezoneHour, timezoneMinute;
                if (datep.getTimezoneHour() == DateTime.TIMEZONE_HOUR_NULL
                        && datep.getTimezoneMinute() == DateTime.TIMEZONE_MINUTE_NULL
View Full Code Here

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

        super(args);
    }

    @Override
    protected IAggregateEvaluator createEvaluator(IScalarEvaluator[] args) throws AlgebricksException {
        final TaggedValuePointable tvpCount = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvsSum = new ArrayBackedValueStorage();
        final DataOutput dOutSum = abvsSum.getDataOutput();
        final ArrayBackedValueStorage abvsCount = new ArrayBackedValueStorage();
        final DataOutput dOutCount = abvsCount.getDataOutput();
        final AddOperation aOp = new AddOperation();
        final DivideOperation aOpDivide = new DivideOperation();

        return new AbstractTaggedValueArgumentAggregateEvaluator(args) {
            long count;
            TaggedValuePointable tvpSum = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();

            @Override
            public void init() throws AlgebricksException {
                count = 0;
            }

            @Override
            public void finish(IPointable result) throws AlgebricksException {
                if (count == 0) {
                    XDMConstants.setEmptySequence(result);
                } else {
                    // Set count as a TaggedValuePointable.
                    try {
                        abvsCount.reset();
                        dOutCount.write(ValueTag.XS_INTEGER_TAG);
                        dOutCount.writeLong(count);
                        tvpCount.set(abvsCount);

                        FunctionHelper.arithmeticOperation(aOpDivide, dCtx, tvpSum, tvpCount, tvpSum);
                        result.set(tvpSum);
                    } catch (Exception e) {
                        throw new AlgebricksException(e);
                    }
                }
            }

            @Override
            protected void step(TaggedValuePointable[] args) throws SystemException {
                TaggedValuePointable tvp = args[0];
                if (count == 0) {
                    // Init.
                    try {
                        abvsSum.reset();
                        dOutSum.write(tvp.getByteArray(), tvp.getStartOffset(), tvp.getLength());
                        tvpSum.set(abvsSum);
                    } catch (IOException e) {
                        throw new SystemException(ErrorCode.SYSE0001, e.toString());
                    }
                } else {
View Full Code Here

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

        final DataOutput dOutInner = abvsInner.getDataOutput();

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

                // Only accept strings 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(stringp);
                    if (stringp.getLength() == 2) {
                        XDMConstants.setEmptySequence(result);
                        return;
                    }
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.