incubator-vxquery-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eldon Carman <>
Subject Re: Arithmetic Functions
Date Fri, 15 Jun 2012 23:01:34 GMT
I have implemented several functions. The attached patch shows the
changes. How can I write a  xquery to test the different numeric
types? I tried casting value to one I want, but it always comes back
as an integer.

Also it looks like the decimal pointable is only supported by xquery
and not Hyracks. Should we add all the other features you find in the
other classes for FloatPointable, IntegerPointable and
DoublePointable? As it stands, we do not have access to some functions
like floatValue().

Thanks for your feedback.

On Fri, Jun 15, 2012 at 7:09 AM, Vinayak Borkar <> wrote:
> Preston,
> I have now added some scaffolding so that implementing the arithmetic
> functions will be easier.
> I have also added the code for xs:integer + xs:integer which is needed for
> the 1 + 1 example, ant it works end-to-end.
> Look at the AddScalarEvaluatorFactory class. You will be creating a class
> like that for each of Subtract, Multiply, and Divide by extending
> AbstractArithmeticScalarEvaluatorFactory.
> The only method that you have to implement when you extend
> AbstractArithmeticScalarEvaluatorFactory is the createArithmeticOperation()
> method that creates an instance of AbstractArithmeticOperation.
> For example, the one for Add looks like this:
>    @Override
>    protected AbstractArithmeticOperation createArithmeticOperation() {
>        return new AddOperation();
>    }
> The AddOperation implements all the logic for what it means to add two
> values of various types.
> The AbstractArithmeticScalarEvaluatorFactory has all the logic to correctly
> dispatch to the correct method in AbstractArithmeticOperation based on
> XQuery rules.
> As your next step, please implement all the methods in AddOperation. The
> methods in this class look like
> void operateXY(X x, Y y, DataOutput dOut)
> where X and Y are type names.
> For example the method that computes the result for xs:integer and xs:double
> would read:
> void operateIntegerDouble(LongPointable longp, DoublePointable doublep,
> DataOutput dOut)
> Since Add is commutative, you can implement about half of the methods by
> delegating to the other half (by switching the arguments). The convention
> you should follow is have operateXY delegate to operateYX when X is
> lexicographically greater than Y.
> So in the above example, operateIntegerDouble will delegate to
> operateDoubleInteger in the AddOperation class.
> Note that this trick does not apply to Minus and Divide, but applied to
> Multiply.
> Let us know how it goes with implementing the unimplemented methods in
> AddOperation and then implemnting the other arithmetic operation classes.
> Vinayak

  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message