Examples of TaggedValuePointable


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

    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final AbstractValueComparisonOperation aOp = createValueComparisonOperation();
        final TaggedValuePointable tvpReturn = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpNext = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final VoidPointable p = (VoidPointable) VoidPointable.FACTORY.createPointable();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                // TODO Update the results to be based on specs when different types in sequence.
                TaggedValuePointable tvp = args[0];
                if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp.getValue(seqp);
                    int seqLen = seqp.getEntryCount();
                    if (seqLen == 0) {
                        XDMConstants.setEmptySequence(result);
                    } else {
                        for (int j = 0; j < seqLen; ++j) {
View Full Code Here

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

                result.set(tvpSum);
            }

            @Override
            protected void step(TaggedValuePointable[] args) throws SystemException {
                TaggedValuePointable tvp = args[0];
                FunctionHelper.arithmeticOperation(aOp, dCtx, tvp, tvpSum, tvpSum);
            }
        };
    }
View Full Code Here

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

    }

    @Override
    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final TaggedValuePointable tvp = new TaggedValuePointable();
        final UTF8StringPointable stringp1 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final UTF8StringPointable stringp2 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        final SequencePointable seq = (SequencePointable) SequencePointable.FACTORY.createPointable();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                abvs.reset();

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

                // Only accept a sequence of strings and a string.
                if (!FunctionHelper.isDerivedFromString(tvp2.getTag())) {
                    throw new SystemException(ErrorCode.FORG0006);
                }
                if (FunctionHelper.isDerivedFromString(tvp1.getTag())) {
                    try {
                        // Return first parameter as a string.
                        DataOutput out = abvs.getDataOutput();
                        tvp1.getValue(stringp1);
                        out.write(ValueTag.XS_STRING_TAG);
                        out.write(stringp1.getByteArray(), stringp1.getStartOffset(), stringp1.getLength());
                        result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
                    } catch (IOException e) {
                        throw new SystemException(ErrorCode.SYSE0001, e);
                    }
                    return;
                } else if (tvp1.getTag() != ValueTag.SEQUENCE_TAG) {
                    throw new SystemException(ErrorCode.FORG0006);
                }

                // Operate on a sequence.
                tvp1.getValue(seq);
                tvp2.getValue(stringp2);

                try {
                    // Byte Format: Type (1 byte) + String Length (2 bytes) + String.
                    DataOutput out = abvs.getDataOutput();
                    out.write(ValueTag.XS_STRING_TAG);
View Full Code Here

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

            throws AlgebricksException {
        final DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        final DataOutput dOut = abvs.getDataOutput();
        final TaggedValuePointable tvpNext = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpSum = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final VoidPointable p = (VoidPointable) VoidPointable.FACTORY.createPointable();
        final AddOperation aOp = new AddOperation();

        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) {
                        // Default zero value as second argument.
                        if (args.length == 2) {
                            TaggedValuePointable tvp2 = args[1];
                            result.set(tvp2);
                        } else {
                            // No argument return an integer.
                            try {
                                abvs.reset();
View Full Code Here

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 as input.
                if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp1.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        XDMConstants.setEmptyString(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(stringp2);
                    } else {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                } else {
                    if (!FunctionHelper.isDerivedFromString(tvp2.getTag())) {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                    tvp2.getValue(stringp2);
                }
                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

                // Only need to run comparisons if they both have a non empty string.
                if (stringp1.getLength() > 2 && stringp2.getLength() > 2) {
View Full Code Here

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

        final DataOutput dOutSum = abvsSum.getDataOutput();
        final AddOperation aOp = new AddOperation();
        final DivideOperation aOpDivide = new DivideOperation();
        final LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
        final SequencePointable seq = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final TaggedValuePointable tvpArg = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();

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

            @Override
            public void init() throws AlgebricksException {
                try {
                    abvsCount.reset();
                    dOutCount.write(ValueTag.XS_INTEGER_TAG);
                    dOutCount.writeLong(0);
                    tvpCount.set(abvsCount);
                    abvsSum.reset();
                    dOutSum.write(ValueTag.XS_INTEGER_TAG);
                    dOutSum.writeLong(0);
                    tvpSum.set(abvsSum);
                } catch (Exception e) {
                    throw new AlgebricksException(e);
                }
            }

            @Override
            public void finish(IPointable result) throws AlgebricksException {
                tvpCount.getValue(longp);
                if (longp.getLong() == 0) {
                    XDMConstants.setEmptySequence(result);
                } else {
                    // Set count as a TaggedValuePointable.
                    try {
                        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 (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp.getValue(seq);
                    int seqLen = seq.getEntryCount();
                    if (seqLen == 0) {
                        // No results from nodes.
                        return;
                    } else if (seqLen == 2) {
View Full Code Here

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

        final ITreeNodeIdProvider nodeIdProvider = new TreeNodeIdProvider((short) partition);

        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) {
                        XDMConstants.setEmptySequence(result);
                        return;
                    } else {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                }
                if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
                    throw new SystemException(ErrorCode.FORG0006);
                }
                tvp.getValue(stringp);
                try {
                    // Only one document should be parsed so its ok to have a unique parser.
                    XMLParser parser = new XMLParser(false, nodeIdProvider);
                    FunctionHelper.readInDocFromPointable(stringp, in, bbis, di, abvs, parser);
                } catch (Exception e) {
View Full Code Here

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

            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) {
                        XDMConstants.setFalse(result);
                        return;
                    }
                }
View Full Code Here

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

            super(args);
        }

        @Override
        protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
            TaggedValuePointable tvp = args[0];
            boolean booleanResult = true;
            switch (tvp.getTag()) {
                case ValueTag.SEQUENCE_TAG: {
                    tvp.getValue(seqp);
                    if (seqp.getEntryCount() == 0) {
                        booleanResult = false;
                    }
                    break;
                }

                case ValueTag.XS_BOOLEAN_TAG: {
                    result.set(tvp);
                    return;
                }

                case ValueTag.XS_DECIMAL_TAG: {
                    tvp.getValue(decp);
                    if (decp.longValue() == 0) {
                        booleanResult = false;
                    }
                    break;
                }

                case ValueTag.XS_INTEGER_TAG:
                case ValueTag.XS_LONG_TAG:
                case ValueTag.XS_NEGATIVE_INTEGER_TAG:
                case ValueTag.XS_NON_POSITIVE_INTEGER_TAG:
                case ValueTag.XS_NON_NEGATIVE_INTEGER_TAG:
                case ValueTag.XS_POSITIVE_INTEGER_TAG:
                case ValueTag.XS_UNSIGNED_INT_TAG:
                case ValueTag.XS_UNSIGNED_LONG_TAG: {
                    tvp.getValue(lp);
                    if (lp.longValue() == 0) {
                        booleanResult = false;
                    }
                    break;
                }

                case ValueTag.XS_INT_TAG:
                case ValueTag.XS_UNSIGNED_SHORT_TAG: {
                    tvp.getValue(ip);
                    if (ip.intValue() == 0) {
                        booleanResult = false;
                    }
                    break;
                }

                case ValueTag.XS_SHORT_TAG:
                case ValueTag.XS_UNSIGNED_BYTE_TAG: {
                    tvp.getValue(sp);
                    if (sp.shortValue() == 0) {
                        booleanResult = false;
                    }
                    break;
                }

                case ValueTag.XS_BYTE_TAG: {
                    tvp.getValue(bp);
                    if (bp.byteValue() == 0) {
                        booleanResult = false;
                    }
                    break;
                }

                case ValueTag.XS_DOUBLE_TAG: {
                    tvp.getValue(dp);
                    if (dp.doubleValue() == 0 || Double.isNaN(dp.doubleValue())) {
                        booleanResult = false;
                    }
                    break;
                }

                case ValueTag.XS_FLOAT_TAG: {
                    tvp.getValue(fp);
                    if (fp.floatValue() == 0 || Float.isNaN(fp.floatValue())) {
                        booleanResult = false;
                    }
                    break;
                }

                case ValueTag.XS_ANY_URI_TAG:
                case ValueTag.XS_STRING_TAG: {
                    tvp.getValue(utf8p);
                    if (utf8p.getUTFLength() == 0) {
                        booleanResult = false;
                    }
                    break;
                }
View Full Code Here

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

            private int index;
            private int seqLength;

            @Override
            public boolean step(IPointable result) throws AlgebricksException {
                TaggedValuePointable tvp = tvps[0];
                if (tvp.getTag() != ValueTag.SEQUENCE_TAG) {
                    if (index == 0) {
                        result.set(tvp);
                        ++index;
                        return true;
                    }
                } else {
                    if (index < seqLength) {
                        seqp.getEntry(index, result);
                        ++index;
                        return true;
                    }
                }
                return false;
            }

            @Override
            protected void init(TaggedValuePointable[] args) {
                index = 0;
                TaggedValuePointable tvp = tvps[0];
                if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
                    tvp.getValue(seqp);
                    seqLength = seqp.getEntryCount();
                }
            }
        };
    }
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.