Examples of LongPointable


Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

    @Override
    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        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();
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
        final XSDateTimePointable datetimep = (XSDateTimePointable) XSDateTimePointable.FACTORY.createPointable();
        final XSDateTimePointable ctxDatetimep = (XSDateTimePointable) XSDateTimePointable.FACTORY.createPointable();
        final LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
        final DataOutput dOutInner = abvsInner.getDataOutput();

        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_DATETIME_TAG) {
                    throw new SystemException(ErrorCode.FORG0006);
                }
                tvp1.getValue(datetimep);

                // 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 {
                        throw new SystemException(ErrorCode.FORG0006);
                    }
                } else {
                    tz = ctxDatetimep.getTimezoneHour() * 60 + ctxDatetimep.getTimezoneMinute();
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

                            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;
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

    @Override
    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
        final LongPointable longp = (LongPointable) LongPointable.FACTORY.createPointable();
        final SequencePointable seqp = (SequencePointable) SequencePointable.FACTORY.createPointable();
        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
        final VoidPointable p = (VoidPointable) VoidPointable.FACTORY.createPointable();

        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                TaggedValuePointable tvp1 = args[0];
                try {
                    // Byte Format: Type (1 byte) + String Length (2 bytes) + String.
                    DataOutput out = abvs.getDataOutput();
                    out.write(ValueTag.XS_STRING_TAG);

                    // Default values for the length and update later
                    out.write(0);
                    out.write(0);

                    // Only accept sequences of integers or an integer as input.
                    if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
                        tvp1.getValue(seqp);
                        for (int j = 0; j < seqp.getEntryCount(); ++j) {
                            seqp.getEntry(j, p);
                            tvp.set(p.getByteArray(), p.getStartOffset(), p.getLength());
                            tvp.getValue(longp);
                            if (!Character.isDefined(longp.intValue())) {
                                throw new SystemException(ErrorCode.FOCH0001);
                            }
                            FunctionHelper.writeChar((char) longp.intValue(), out);
                        }
                    } else if (tvp1.getTag() == ValueTag.XS_INTEGER_TAG) {
                        tvp1.getValue(longp);
                        if (!Character.isDefined(longp.intValue())) {
                            throw new SystemException(ErrorCode.FOCH0001);
                        }
                        FunctionHelper.writeChar((char) longp.intValue(), out);
                    } else {
                        throw new SystemException(ErrorCode.FORG0006);
                    }

                    // Update the full length string in the byte array.
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

            pp.giveBack(dtp);
        }
    }

    private void printDTDuration(PrintStream ps, TaggedValuePointable tvp) {
        LongPointable lp = pp.takeOne(LongPointable.class);
        try {
            tvp.getValue(lp);
            abvs.reset();
            castToString.convertDTDuration(lp, dOut);
            printStringAbvs(ps);
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

            pp.giveBack(ip);
        }
    }

    private void printInteger(PrintStream ps, TaggedValuePointable tvp) {
        LongPointable lp = pp.takeOne(LongPointable.class);
        try {
            tvp.getValue(lp);
            ps.print(lp.longValue());
        } finally {
            pp.giveBack(lp);
        }
    }
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

        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();
                } else if (tvp.getTag() == ValueTag.XS_DECIMAL_TAG) {
                    tvp.getValue(decp);
                    return decp.longValue();
                } else {
                    throw new SystemException(ErrorCode.FORG0006);
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

            pp.giveBack(dtp);
        }
    }

    private void printDTDuration(PrintStream ps, TaggedValuePointable tvp) {
        LongPointable lp = pp.takeOne(LongPointable.class);
        try {
            tvp.getValue(lp);
            abvs.reset();
            castToString.convertDTDuration(lp, dOut);
            printStringAbvs(ps);
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

            pp.giveBack(ip);
        }
    }

    private void printInteger(PrintStream ps, TaggedValuePointable tvp) {
        LongPointable lp = pp.takeOne(LongPointable.class);
        try {
            tvp.getValue(lp);
            ps.print(lp.longValue());
        } finally {
            pp.giveBack(lp);
        }
    }
View Full Code Here

Examples of edu.uci.ics.hyracks.data.std.primitive.LongPointable

    @Override
    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
            throws AlgebricksException {
        final SequencePointable seqp = new SequencePointable();
        final LongPointable lp = (LongPointable) LongPointable.FACTORY.createPointable();
        final IntegerPointable ip = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
        final ShortPointable sp = (ShortPointable) ShortPointable.FACTORY.createPointable();
        final BytePointable bp = (BytePointable) BytePointable.FACTORY.createPointable();
        final XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        final DoublePointable dp = (DoublePointable) DoublePointable.FACTORY.createPointable();
        final FloatPointable fp = (FloatPointable) FloatPointable.FACTORY.createPointable();
        final UTF8StringPointable utf8p = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
            @Override
            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
                TaggedValuePointable tvp = args[0];
                switch (tvp.getTag()) {
                    case ValueTag.SEQUENCE_TAG: {
                        tvp.getValue(seqp);
                        if (seqp.getEntryCount() == 0) {
                            XDMConstants.setFalse(result);
                            return;
                        }
                        XDMConstants.setTrue(result);
                        return;
                    }

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

                    case ValueTag.XS_DECIMAL_TAG: {
                        tvp.getValue(decp);
                        if (decp.longValue() == 0) {
                            XDMConstants.setFalse(result);
                            return;
                        }
                        XDMConstants.setTrue(result);
                        return;
                    }

                    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) {
                            XDMConstants.setFalse(result);
                            return;
                        }
                        XDMConstants.setTrue(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.