incubator-vxquery-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vinayak Borkar <vbo...@yahoo.com>
Subject Re: Arithmetic Functions
Date Fri, 15 Jun 2012 23:39:24 GMT
Lexicographical order is text sort order. So:

decimal
double
float
integer

xs:integer is supposed to be infinite precision, but we represent it as 
a 64 bit fixed-precision signed-integer which is a long in java.

Vinayak


On 6/15/12 3:11 PM, Eldon Carman wrote:
> Thanks for the scaffolding. I have two questions. Is this the correct
> lexicographical order?
>   1. double
>   2. float
>   3. decimal
>   4. integer
>
> Also do we always referrer to a integer as a long for this implementation?
>
> Preston
>
> On Fri, Jun 15, 2012 at 7:09 AM, Vinayak Borkar<vborky@yahoo.com>  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
>


Mime
View raw message