You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@vxquery.apache.org by Eldon Carman <ec...@ucr.edu> on 2012/06/07 04:30:44 UTC

VXQuery Number Query Plans

As we talked about starting with simple queries, I have outlined a few
of the basic integer math queries. The first two queries are just
numbers. VXQuery starts with a empty tuple and assigned the integer to
a variable. The system detects the value is a integer and labels the
value as such. The remaining queries are for addition, subtraction,
multiplication an division. Each of these queries are basically the
same, with the exception of the math function call. First creating
variables for each of the numbers, starting with the first in the
equation. Next passing both variables into the math function call. I
am a little confused by all the functions arguments and sub arguments
for each of the math functions. Let me know if this assessment is
correct.

For example "add" takes two arguments.
  1. The first argument is the result of "promote" which is a function
that takes two arguments.
    a. The first argument to "promote" is another function called
"data" that takes one parameter, the variable of the integer.
    b. The second argument is the type for "promote".
  2. The second is similar for the other variable.


My questions:
 - in 1. The plan use the function promote. Is this to ensure the type
is correct for the addition function?
 - in 1b. Why does the type here show anyAtomicType instead of integer?

Thanks
Preston

Number Queries
----------------------
1

assign [$$1] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(1)] -- |UNPARTITIONED|
  empty-tuple-source -- |UNPARTITIONED|

17

assign [$$1] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(17)] -- |UNPARTITIONED|
  empty-tuple-source -- |UNPARTITIONED|

1 + 1

assign [$$3] <- [function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}add,
Args:[function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$1],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)], function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$2],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)]]] -- |UNPARTITIONED|
  assign [$$2] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(1)] -- |UNPARTITIONED|
    assign [$$1] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(1)] -- |UNPARTITIONED|
      empty-tuple-source -- |UNPARTITIONED|

5 + 4

assign [$$3] <- [function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}add,
Args:[function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$1],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)], function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$2],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)]]] -- |UNPARTITIONED|
  assign [$$2] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(4)] -- |UNPARTITIONED|
    assign [$$1] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(5)] -- |UNPARTITIONED|
      empty-tuple-source -- |UNPARTITIONED|

5 - 4

assign [$$3] <- [function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}subtract,
Args:[function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$1],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)], function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$2],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)]]] -- |UNPARTITIONED|
  assign [$$2] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(4)] -- |UNPARTITIONED|
    assign [$$1] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(5)] -- |UNPARTITIONED|
      empty-tuple-source -- |UNPARTITIONED|

5 * 4

assign [$$3] <- [function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}multiply,
Args:[function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$1],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)], function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$2],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)]]] -- |UNPARTITIONED|
  assign [$$2] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(4)] -- |UNPARTITIONED|
    assign [$$1] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(5)] -- |UNPARTITIONED|
      empty-tuple-source -- |UNPARTITIONED|

6 div 3

assign [$$3] <- [function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}divide,
Args:[function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$1],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)], function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[$$2],
{http://www.w3.org/2001/XMLSchema-extensions}type
QUANT_ONE({http://www.w3.org/2001/XMLSchema}anyAtomicType
QUANT_QUESTION)]]] -- |UNPARTITIONED|
  assign [$$2] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(3)] -- |UNPARTITIONED|
    assign [$$1] <- [{http://www.w3.org/2001/XMLSchema}integer
QUANT_ONE(6)] -- |UNPARTITIONED|
      empty-tuple-source -- |UNPARTITIONED|

Re: VXQuery Number Query Plans

Posted by Vinayak Borkar <vb...@yahoo.com>.
The data(.) function is required by the XQuery spec for atomization.

Look at: http://www.w3.org/TR/xquery/#id-atomization

When a node is passed to anything that expects an atomic type, the typed 
value is extracted. Since at the time of translation we have no idea 
what the input is, we always throw in the data(.) call. The optimizer 
will eliminate it later if it was not required (like in these cases).

Vinayak


On 6/6/12 10:46 PM, Michael Carey wrote:
> And the data(.) function is needed for these expressions because...? :-)
> (I'm enjoying following his explorations - great way to learn!)
>
> On 6/6/12 7:54 PM, Vinayak Borkar wrote:
>>> My questions:
>>> - in 1. The plan use the function promote. Is this to ensure the type
>>> is correct for the addition function?
>>> - in 1b. Why does the type here show anyAtomicType instead of integer?
>>>
>>
>> The add function you use in the query is defined as an operator in the
>> builtin-operators.xml file. Remember that this operator is
>> polymorphic. It can add integers, doubles, duration to dates etc. So
>> the static type of the operator's argument specify that they should be
>> the supertype of all acceptable argument types and that is
>> anyAtomicType in this case.
>>
>> You are correct in that the promote will ensure that the input data is
>> compliant with the expected argument type of the addition function.
>>
>> At runtime, the function needs to make sure that the inputs are
>> correct and throw a dynamic error otherwise.
>>
>> Vinayak
>


Re: VXQuery Number Query Plans

Posted by Michael Carey <mj...@ics.uci.edu>.
And the data(.) function is needed for these expressions because...?  :-)
(I'm enjoying following his explorations - great way to learn!)

On 6/6/12 7:54 PM, Vinayak Borkar wrote:
>> My questions:
>>   - in 1. The plan use the function promote. Is this to ensure the type
>> is correct for the addition function?
>>   - in 1b. Why does the type here show anyAtomicType instead of integer?
>>
>
> The add function you use in the query is defined as an operator in the 
> builtin-operators.xml file. Remember that this operator is 
> polymorphic. It can add integers, doubles, duration to dates etc. So 
> the static type of the operator's argument specify that they should be 
> the supertype of all acceptable argument types and that is 
> anyAtomicType in this case.
>
> You are correct in that the promote will ensure that the input data is 
> compliant with the expected argument type of the addition function.
>
> At runtime, the function needs to make sure that the inputs are 
> correct and throw a dynamic error otherwise.
>
> Vinayak

Re: VXQuery Number Query Plans

Posted by Vinayak Borkar <vb...@yahoo.com>.
> My questions:
>   - in 1. The plan use the function promote. Is this to ensure the type
> is correct for the addition function?
>   - in 1b. Why does the type here show anyAtomicType instead of integer?
>

The add function you use in the query is defined as an operator in the 
builtin-operators.xml file. Remember that this operator is polymorphic. 
It can add integers, doubles, duration to dates etc. So the static type 
of the operator's argument specify that they should be the supertype of 
all acceptable argument types and that is anyAtomicType in this case.

You are correct in that the promote will ensure that the input data is 
compliant with the expected argument type of the addition function.

At runtime, the function needs to make sure that the inputs are correct 
and throw a dynamic error otherwise.

Vinayak