You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2012/08/21 00:56:55 UTC

svn commit: r1375294 - in /incubator/vxquery/trunk/vxquery: src/site/apt/ vxquery-core/src/main/java/org/apache/vxquery/functions/ vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/

Author: prestonc
Date: Mon Aug 20 22:56:54 2012
New Revision: 1375294

URL: http://svn.apache.org/viewvc?rev=1375294&view=rev
Log:
VXQUERY-52, VXQUERY-53 The missing numeric operations. mod and idiv.

Added:
    incubator/vxquery/trunk/vxquery/src/site/apt/development_tips.apt   (with props)
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/IntegerDivideOperation.java   (with props)
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModOperation.java   (with props)
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModScalarEvaluatorFactory.java   (with props)
Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml

Added: incubator/vxquery/trunk/vxquery/src/site/apt/development_tips.apt
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/site/apt/development_tips.apt?rev=1375294&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/src/site/apt/development_tips.apt (added)
+++ incubator/vxquery/trunk/vxquery/src/site/apt/development_tips.apt Mon Aug 20 22:56:54 2012
@@ -0,0 +1,156 @@
+~~ Licensed to the Apache Software Foundation (ASF) under one or more
+~~ contributor license agreements.  See the NOTICE file distributed with
+~~ this work for additional information regarding copyright ownership.
+~~ The ASF licenses this file to You under the Apache License, Version 2.0
+~~ (the "License"); you may not use this file except in compliance with
+~~ the License.  You may obtain a copy of the License at
+~~
+~~     http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing, software
+~~ distributed under the License is distributed on an "AS IS" BASIS,
+~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~~ See the License for the specific language governing permissions and
+~~ limitations under the License.
+
+Developer Tips
+
+
+* Installation
+
+  Install instructions can be found in the {{{https://svn.apache.org/repos/asf/incubator/vxquery/trunk/vxquery/docs/README}README file}}.
+
+
+* Hyracks Data Mapping
+
+  Hyracks supports several basic data types stored in byte arrays. The byte arrays can be
+  accessed through objects referred to as pointables. The pointable helps with tracking the 
+  bytes stored in a larger storage array. Some pointables support converting the byte array 
+  into a desired format such as for numeric type.
+  
+  In VXQuery the TaggedValuePointable is used to read a result from this byte array. The 
+  first byte defines the data type and alerts us to what pointable to use for reading the
+  rest of the data.
+
+** Fixed Length Data
+
+  Fixed length data types can be stored in a set field size. The following outlines the
+  Hyracks data type or custom VXQuery definition with the details about the implementation.
+  
+*-------------------------+----------------------+---------------+
+| <<Data Type>>           | <<Pointable Name>>   | <<Data Size>> |
+*-------------------------+----------------------+---------------:
+| xs:boolean              | BooleanPointable     |             1 |
+*-------------------------+----------------------+---------------:
+| xs:byte                 | BytePointable        |             1 |
+*-------------------------+----------------------+---------------:
+| xs:date                 | XSDatePointable      |             6 |
+*-------------------------+----------------------+---------------:
+| xs:dateTime             | XSDateTimePointable  |            12 |
+*-------------------------+----------------------+---------------:
+| xs:dayTimeDuration      | IntegerPointable     |             4 |
+*-------------------------+----------------------+---------------:
+| xs:decimal              | XSDecimalPointable   |             9 |
+*-------------------------+----------------------+---------------:
+| xs:double               | DoublePointable      |             8 |
+*-------------------------+----------------------+---------------:
+| xs:duration             | XSDurationPointable  |             8 |
+*-------------------------+----------------------+---------------:
+| xs:float                | FloatPointable       |             4 |
+*-------------------------+----------------------+---------------:
+| xs:gDay                 | XSDatePointable      |             6 |
+*-------------------------+----------------------+---------------:
+| xs:gMonth               | XSDatePointable      |             6 |
+*-------------------------+----------------------+---------------:
+| xs:gMonthDay            | XSDatePointable      |             6 |
+*-------------------------+----------------------+---------------:
+| xs:gYear                | XSDatePointable      |             6 |
+*-------------------------+----------------------+---------------:
+| xs:gYearMonth           | XSDatePointable      |             6 |
+*-------------------------+----------------------+---------------:
+| xs:int                  | IntegerPointable     |             4 |
+*-------------------------+----------------------+---------------:
+| xs:integer              | LongPointable        |             8 |
+*-------------------------+----------------------+---------------:
+| xs:negativeInteger      | LongPointable        |             8 |
+*-------------------------+----------------------+---------------:
+| xs:nonNegativeInteger   | LongPointable        |             8 |
+*-------------------------+----------------------+---------------:
+| xs:nonPositiveInteger   | LongPointable        |             8 |
+*-------------------------+----------------------+---------------:
+| xs:positiveInteger      | LongPointable        |             8 |
+*-------------------------+----------------------+---------------:
+| xs:short                | ShortPointable       |             2 |
+*-------------------------+----------------------+---------------:
+| xs:time                 | XSTimePointable      |             8 |
+*-------------------------+----------------------+---------------:
+| xs:unsignedByte         | ShortPointable       |             2 |
+*-------------------------+----------------------+---------------:
+| xs:unsignedInt          | LongPointable        |             8 |
+*-------------------------+----------------------+---------------:
+| xs:unsignedLong         | LongPointable        |             8 |
+*-------------------------+----------------------+---------------:
+| xs:unsignedShort        | IntegerPointable     |             4 |
+*-------------------------+----------------------+---------------:
+| xs:yearMonthDuration    | IntegerPointable     |             4 |
+*-------------------------+----------------------+---------------:
+  
+** Variable Length Data
+
+  Some information can not be stored in a fixed length value. The following data types are 
+  stored in variable length values. Because the size varies, the first two bytes are used to 
+  store the length of the total value in bytes. QName is one exception to this rule because 
+  the QName field has three distinct variable length fields. In this case we basically are 
+  storing three strings right after each other.
+  
+  Please note that all strings are stored in UTF8. The UTF8 characters range in size from one
+  to three bytes. UTF9StringWriter supports writing a character sequence into the 
+  UTF8StringPointable format.
+  
+*-------------------------+----------------------+---------------+
+| <<Data Type>>           | <<Pointable Name>>   | <<Data Size>> |
+*-------------------------+----------------------+---------------:
+| xs:anyURI               | UTF8StringPointable  |    2 + length |
+*-------------------------+----------------------+---------------:
+| xs:base64Binary         | XSBinaryPointable    |    2 + length |
+*-------------------------+----------------------+---------------:
+| xs:hexBinary            | XSBinaryPointable    |    2 + length |
+*-------------------------+----------------------+---------------:
+| xs:NOTATION             | UTF8StringPointable  |    2 + length |
+*-------------------------+----------------------+---------------:
+| xs:QName                | XSQNamePointable     |    6 + length |
+*-------------------------+----------------------+---------------:
+| xs:string               | UTF8StringPointable  |    2 + length |
+*-------------------------+----------------------+---------------:
+  
+  
+* String Iterators
+
+  For many string functions, we have used string iterators to traverse the string. The iterator
+  allows the user to ignore the details about the byte size and number of characters. The iterator
+  returns the next character or an end of string value. Stacking iterators can be used to alter
+  the string into a desired form.
+  
+  * LowerCaseStringCharacterIterator
+   
+  * SubstringAfterStringCharacterIterator
+   
+  * SubstringBeforeStringCharacterIterator
+   
+  * SubstringStringCharacterIterator
+   
+  * UpperCaseStringCharacterIterator
+   
+  * UTF8StringCharacterIterator
+  
+* Array Backed Value Store
+
+  The array back value store is a key design element of Hyracks. The object is used to manage an
+  output array. The system creates an array large enough to hold your output. Adding to the result,
+  if necessary. The array can be reused and can hold multiple pointable results due to the starting 
+  offset parameter in the pointable.
+  
+  
+  
+  
+  
\ No newline at end of file

Propchange: incubator/vxquery/trunk/vxquery/src/site/apt/development_tips.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml?rev=1375294&r1=1375293&r2=1375294&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml Mon Aug 20 22:56:54 2012
@@ -635,6 +635,7 @@
         <param name="arg1" type="xsext:numeric?"/>
         <param name="arg2" type="xsext:numeric?"/>
         <return type="xs:integer?"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.arithmetic.IntegerDivideScalarEvaluatorFactory"/>
     </operator>
 
     <!-- opext:mod($arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType?) as xs:anyAtomicType? -->
@@ -642,6 +643,7 @@
         <param name="arg1" type="xsext:numeric?"/>
         <param name="arg2" type="xsext:numeric?"/>
         <return type="xs:integer?"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.arithmetic.ModScalarEvaluatorFactory"/>
     </operator>
 
     <!-- opext:and($arg1 as xs:boolean?, $arg2 as xs:boolean?) as xs:boolean? -->

Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/IntegerDivideOperation.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/IntegerDivideOperation.java?rev=1375294&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/IntegerDivideOperation.java (added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/IntegerDivideOperation.java Mon Aug 20 22:56:54 2012
@@ -0,0 +1,441 @@
+package org.apache.vxquery.runtime.functions.arithmetic;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.vxquery.context.DynamicContext;
+import org.apache.vxquery.datamodel.accessors.atomic.XSDatePointable;
+import org.apache.vxquery.datamodel.accessors.atomic.XSDateTimePointable;
+import org.apache.vxquery.datamodel.accessors.atomic.XSDecimalPointable;
+import org.apache.vxquery.datamodel.accessors.atomic.XSTimePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+
+import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
+import edu.uci.ics.hyracks.data.std.primitive.FloatPointable;
+import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+
+public class IntegerDivideOperation extends AbstractArithmeticOperation {
+    protected final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
+
+    @Override
+    public void operateDateDate(XSDatePointable datep, XSDatePointable datep2, DynamicContext dCtx, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDateDTDuration(XSDatePointable datep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDatetimeDatetime(XSDateTimePointable datetimep, XSDateTimePointable datetimep2,
+            DynamicContext dCtx, DataOutput dOut) throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDatetimeDTDuration(XSDateTimePointable datetimep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDatetimeYMDuration(XSDateTimePointable datetimep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDateYMDuration(XSDatePointable datep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDecimalDecimal(XSDecimalPointable decp1, XSDecimalPointable decp2, DataOutput dOut)
+            throws SystemException, IOException {
+        // Prepare
+        long value1 = decp1.getDecimalValue();
+        long value2 = decp2.getDecimalValue();
+        byte place1 = decp1.getDecimalPlace();
+        byte place2 = decp2.getDecimalPlace();
+        byte count1 = decp1.getDigitCount();
+        byte count2 = decp2.getDigitCount();
+        if (value2 == 0) {
+            throw new SystemException(ErrorCode.FOAR0001);
+        }
+        // Convert to matching values
+        while (place1 > place2) {
+            ++place2;
+            value2 *= 10;
+            ++count2;
+        }
+        while (place1 < place2) {
+            ++place1;
+            value1 *= 10;
+            ++count1;
+        }
+        // Add
+        if (count1 > XSDecimalPointable.PRECISION || count2 > XSDecimalPointable.PRECISION) {
+            throw new SystemException(ErrorCode.XPDY0002);
+        }
+        value1 /= value2;
+
+        // Save
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong(value1);
+    }
+
+    @Override
+    public void operateDecimalDouble(XSDecimalPointable decp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        if (Double.isNaN(doublep.getDouble())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        double value = decp.doubleValue();
+        value /= doublep.doubleValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateDecimalDTDuration(XSDecimalPointable decp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDecimalFloat(XSDecimalPointable decp, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        if (floatp.getFloat() == 0) {
+            throw new SystemException(ErrorCode.FOAR0001);
+        }
+        if (Float.isNaN(floatp.getFloat())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        float value = decp.floatValue();
+        value /= floatp.floatValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateDecimalInteger(XSDecimalPointable decp1, LongPointable longp2, DataOutput dOut)
+            throws SystemException, IOException {
+        abvsInner.reset();
+        XSDecimalPointable decp2 = new XSDecimalPointable();
+        decp2.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
+        decp2.setDecimal(longp2.longValue(), (byte) 0);
+        operateDecimalDecimal(decp1, decp2, dOut);
+    }
+
+    @Override
+    public void operateDecimalYMDuration(XSDecimalPointable decp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDoubleDecimal(DoublePointable doublep1, XSDecimalPointable decp2, DataOutput dOut)
+            throws SystemException, IOException {
+        if (Double.isNaN(doublep1.getDouble()) || Double.isInfinite(doublep1.getDouble())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        double value = doublep1.doubleValue();
+        value /= decp2.doubleValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateDoubleDouble(DoublePointable doublep1, DoublePointable doublep2, DataOutput dOut)
+            throws SystemException, IOException {
+        if (doublep2.getDouble() == 0) {
+            throw new SystemException(ErrorCode.FOAR0001);
+        }
+        if (Double.isNaN(doublep1.getDouble()) || Double.isInfinite(doublep1.getDouble())
+                || Double.isNaN(doublep2.getDouble())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        double value = doublep1.doubleValue();
+        value /= doublep2.doubleValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateDoubleDTDuration(DoublePointable doublep1, IntegerPointable intp2, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDoubleFloat(DoublePointable doublep, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        if (doublep.getDouble() == 0) {
+            throw new SystemException(ErrorCode.FOAR0001);
+        }
+        if (Double.isNaN(doublep.getDouble()) || Double.isInfinite(doublep.getDouble())
+                || Float.isNaN(floatp.getFloat())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        double value = doublep.doubleValue();
+        value /= floatp.doubleValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateDoubleInteger(DoublePointable doublep, LongPointable longp, DataOutput dOut)
+            throws SystemException, IOException {
+        if (Double.isNaN(doublep.getDouble()) || Double.isInfinite(doublep.getDouble())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        double value = doublep.doubleValue();
+        value /= longp.doubleValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateDoubleYMDuration(DoublePointable doublep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDate(IntegerPointable intp, XSDatePointable datep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDatetime(IntegerPointable intp, XSDateTimePointable datetimep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDecimal(IntegerPointable intp, XSDecimalPointable decp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDouble(IntegerPointable intp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDTDuration(IntegerPointable intp, IntegerPointable intp2, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationFloat(IntegerPointable intp, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationInteger(IntegerPointable intp, LongPointable longp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationTime(IntegerPointable intp1, XSTimePointable timep2, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateFloatDecimal(FloatPointable floatp, XSDecimalPointable decp, DataOutput dOut)
+            throws SystemException, IOException {
+        if (Float.isNaN(floatp.getFloat()) || Float.isInfinite(floatp.getFloat())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        float value = floatp.floatValue();
+        value /= decp.floatValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateFloatDouble(FloatPointable floatp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        if (doublep.getDouble() == 0) {
+            throw new SystemException(ErrorCode.FOAR0001);
+        }
+        if (Float.isNaN(floatp.getFloat()) || Float.isInfinite(floatp.getFloat()) || Double.isNaN(doublep.getDouble())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        double value = floatp.doubleValue();
+        value /= doublep.doubleValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateFloatDTDuration(FloatPointable floatp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateFloatFloat(FloatPointable floatp, FloatPointable floatp2, DataOutput dOut)
+            throws SystemException, IOException {
+        if (floatp2.getFloat() == 0) {
+            throw new SystemException(ErrorCode.FOAR0001);
+        }
+        if (Float.isNaN(floatp.getFloat()) || Float.isInfinite(floatp.getFloat()) || Float.isNaN(floatp2.getFloat())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        float value = floatp.floatValue();
+        value /= floatp2.floatValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateFloatInteger(FloatPointable floatp, LongPointable longp, DataOutput dOut)
+            throws SystemException, IOException {
+        if (Float.isNaN(floatp.getFloat()) || Float.isInfinite(floatp.getFloat())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        float value = floatp.floatValue();
+        value /= longp.floatValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateFloatYMDuration(FloatPointable floatp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateIntegerDecimal(LongPointable longp1, XSDecimalPointable decp2, DataOutput dOut)
+            throws SystemException, IOException {
+        abvsInner.reset();
+        XSDecimalPointable decp1 = new XSDecimalPointable();
+        decp1.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
+        decp1.setDecimal(longp1.longValue(), (byte) 0);
+        operateDecimalDecimal(decp1, decp2, dOut);
+    }
+
+    @Override
+    public void operateIntegerDouble(LongPointable longp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        if (doublep.getDouble() == 0) {
+            throw new SystemException(ErrorCode.FOAR0001);
+        }
+        if (Double.isNaN(doublep.getDouble())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        double value = longp.doubleValue();
+        value /= doublep.doubleValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateIntegerDTDuration(LongPointable longp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateIntegerFloat(LongPointable longp, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        if (floatp.getFloat() == 0) {
+            throw new SystemException(ErrorCode.FOAR0001);
+        }
+        if (Float.isNaN(floatp.getFloat())) {
+            throw new SystemException(ErrorCode.FOAR0002);
+        }
+        float value = longp.floatValue();
+        value /= floatp.floatValue();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong((long) value);
+    }
+
+    @Override
+    public void operateIntegerInteger(LongPointable longp, LongPointable longp2, DataOutput dOut)
+            throws SystemException, IOException {
+        long value = longp.getLong();
+        value /= longp2.getLong();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong(value);
+    }
+
+    @Override
+    public void operateIntegerYMDuration(LongPointable longp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateTimeDTDuration(XSTimePointable timep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateTimeTime(XSTimePointable timep, XSTimePointable timep2, DynamicContext dCtx, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationDate(IntegerPointable intp, XSDatePointable datep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationDatetime(IntegerPointable intp, XSDateTimePointable datetimep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationDecimal(IntegerPointable intp, XSDecimalPointable decp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationDouble(IntegerPointable intp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationFloat(IntegerPointable intp, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationInteger(IntegerPointable intp, LongPointable longp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationYMDuration(IntegerPointable intp, IntegerPointable intp2, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+}
\ No newline at end of file

Propchange: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/IntegerDivideOperation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModOperation.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModOperation.java?rev=1375294&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModOperation.java (added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModOperation.java Mon Aug 20 22:56:54 2012
@@ -0,0 +1,380 @@
+package org.apache.vxquery.runtime.functions.arithmetic;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.vxquery.context.DynamicContext;
+import org.apache.vxquery.datamodel.accessors.atomic.XSDatePointable;
+import org.apache.vxquery.datamodel.accessors.atomic.XSDateTimePointable;
+import org.apache.vxquery.datamodel.accessors.atomic.XSDecimalPointable;
+import org.apache.vxquery.datamodel.accessors.atomic.XSTimePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+
+import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
+import edu.uci.ics.hyracks.data.std.primitive.FloatPointable;
+import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+
+public class ModOperation extends AbstractArithmeticOperation {
+    protected final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
+
+    @Override
+    public void operateDateDate(XSDatePointable datep, XSDatePointable datep2, DynamicContext dCtx, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDateDTDuration(XSDatePointable datep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDatetimeDatetime(XSDateTimePointable datetimep, XSDateTimePointable datetimep2,
+            DynamicContext dCtx, DataOutput dOut) throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDatetimeDTDuration(XSDateTimePointable datetimep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDatetimeYMDuration(XSDateTimePointable datetimep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDateYMDuration(XSDatePointable datep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDecimalDecimal(XSDecimalPointable decp1, XSDecimalPointable decp2, DataOutput dOut)
+            throws SystemException, IOException {
+        // Prepare
+        long value1 = decp1.getDecimalValue();
+        long value2 = decp2.getDecimalValue();
+        byte place1 = decp1.getDecimalPlace();
+        byte place2 = decp2.getDecimalPlace();
+        byte count1 = decp1.getDigitCount();
+        byte count2 = decp2.getDigitCount();
+        // Convert to matching values
+        while (place1 > place2) {
+            ++place2;
+            value2 *= 10;
+            ++count2;
+        }
+        while (place1 < place2) {
+            ++place1;
+            value1 *= 10;
+            ++count1;
+        }
+        // Add
+        if (count1 > XSDecimalPointable.PRECISION || count2 > XSDecimalPointable.PRECISION) {
+            throw new SystemException(ErrorCode.XPDY0002);
+        }
+        value1 %= value2;
+
+        // Save
+        dOut.write(ValueTag.XS_DECIMAL_TAG);
+        dOut.writeByte(0);
+        dOut.writeLong(value1);
+    }
+
+    @Override
+    public void operateDecimalDouble(XSDecimalPointable decp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        double value = decp.doubleValue();
+        value %= doublep.doubleValue();
+        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        dOut.writeDouble(value);
+    }
+
+    @Override
+    public void operateDecimalDTDuration(XSDecimalPointable decp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDecimalFloat(XSDecimalPointable decp, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        float value = decp.floatValue();
+        value %= floatp.floatValue();
+        dOut.write(ValueTag.XS_FLOAT_TAG);
+        dOut.writeFloat(value);
+    }
+
+    @Override
+    public void operateDecimalInteger(XSDecimalPointable decp1, LongPointable longp2, DataOutput dOut)
+            throws SystemException, IOException {
+        abvsInner.reset();
+        XSDecimalPointable decp2 = new XSDecimalPointable();
+        decp2.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
+        decp2.setDecimal(longp2.longValue(), (byte) 0);
+        operateDecimalDecimal(decp1, decp2, dOut);
+    }
+
+    @Override
+    public void operateDecimalYMDuration(XSDecimalPointable decp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDoubleDecimal(DoublePointable doublep1, XSDecimalPointable decp2, DataOutput dOut)
+            throws SystemException, IOException {
+        double value = doublep1.doubleValue();
+        value %= decp2.doubleValue();
+        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        dOut.writeDouble(value);
+    }
+
+    @Override
+    public void operateDoubleDouble(DoublePointable doublep1, DoublePointable doublep2, DataOutput dOut)
+            throws SystemException, IOException {
+        double value = doublep1.doubleValue();
+        value %= doublep2.doubleValue();
+        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        dOut.writeDouble(value);
+    }
+
+    @Override
+    public void operateDoubleDTDuration(DoublePointable doublep1, IntegerPointable intp2, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDoubleFloat(DoublePointable doublep, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        double value = doublep.doubleValue();
+        value %= floatp.doubleValue();
+        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        dOut.writeDouble(value);
+    }
+
+    @Override
+    public void operateDoubleInteger(DoublePointable doublep, LongPointable longp, DataOutput dOut)
+            throws SystemException, IOException {
+        double value = doublep.doubleValue();
+        value %= longp.doubleValue();
+        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        dOut.writeDouble(value);
+    }
+
+    @Override
+    public void operateDoubleYMDuration(DoublePointable doublep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDate(IntegerPointable intp, XSDatePointable datep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDatetime(IntegerPointable intp, XSDateTimePointable datetimep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDecimal(IntegerPointable intp, XSDecimalPointable decp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDouble(IntegerPointable intp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationDTDuration(IntegerPointable intp, IntegerPointable intp2, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationFloat(IntegerPointable intp, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationInteger(IntegerPointable intp, LongPointable longp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateDTDurationTime(IntegerPointable intp1, XSTimePointable timep2, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateFloatDecimal(FloatPointable floatp, XSDecimalPointable decp, DataOutput dOut)
+            throws SystemException, IOException {
+        float value = floatp.floatValue();
+        value %= decp.floatValue();
+        dOut.write(ValueTag.XS_FLOAT_TAG);
+        dOut.writeFloat(value);
+    }
+
+    @Override
+    public void operateFloatDouble(FloatPointable floatp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        double value = floatp.doubleValue();
+        value %= doublep.doubleValue();
+        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        dOut.writeDouble(value);
+    }
+
+    @Override
+    public void operateFloatDTDuration(FloatPointable floatp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateFloatFloat(FloatPointable floatp, FloatPointable floatp2, DataOutput dOut)
+            throws SystemException, IOException {
+        float value = floatp.floatValue();
+        value %= floatp2.floatValue();
+        dOut.write(ValueTag.XS_FLOAT_TAG);
+        dOut.writeFloat(value);
+    }
+
+    @Override
+    public void operateFloatInteger(FloatPointable floatp, LongPointable longp, DataOutput dOut)
+            throws SystemException, IOException {
+        float value = floatp.floatValue();
+        value %= longp.floatValue();
+        dOut.write(ValueTag.XS_FLOAT_TAG);
+        dOut.writeFloat(value);
+    }
+
+    @Override
+    public void operateFloatYMDuration(FloatPointable floatp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateIntegerDecimal(LongPointable longp1, XSDecimalPointable decp2, DataOutput dOut)
+            throws SystemException, IOException {
+        abvsInner.reset();
+        XSDecimalPointable decp1 = new XSDecimalPointable();
+        decp1.set(abvsInner.getByteArray(), abvsInner.getStartOffset(), XSDecimalPointable.TYPE_TRAITS.getFixedLength());
+        decp1.setDecimal(longp1.longValue(), (byte) 0);
+        operateDecimalDecimal(decp1, decp2, dOut);
+    }
+
+    @Override
+    public void operateIntegerDouble(LongPointable longp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        double value = longp.doubleValue();
+        value %= doublep.doubleValue();
+        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        dOut.writeDouble(value);
+    }
+
+    @Override
+    public void operateIntegerDTDuration(LongPointable longp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateIntegerFloat(LongPointable longp, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        float value = longp.floatValue();
+        value %= floatp.floatValue();
+        dOut.write(ValueTag.XS_FLOAT_TAG);
+        dOut.writeFloat(value);
+    }
+
+    @Override
+    public void operateIntegerInteger(LongPointable longp, LongPointable longp2, DataOutput dOut)
+            throws SystemException, IOException {
+        long value = longp.getLong();
+        value %= longp2.getLong();
+        dOut.write(ValueTag.XS_INTEGER_TAG);
+        dOut.writeLong(value);
+    }
+
+    @Override
+    public void operateIntegerYMDuration(LongPointable longp, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateTimeDTDuration(XSTimePointable timep, IntegerPointable intp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateTimeTime(XSTimePointable timep, XSTimePointable timep2, DynamicContext dCtx, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationDate(IntegerPointable intp, XSDatePointable datep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationDatetime(IntegerPointable intp, XSDateTimePointable datetimep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationDecimal(IntegerPointable intp, XSDecimalPointable decp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationDouble(IntegerPointable intp, DoublePointable doublep, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationFloat(IntegerPointable intp, FloatPointable floatp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationInteger(IntegerPointable intp, LongPointable longp, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void operateYMDurationYMDuration(IntegerPointable intp, IntegerPointable intp2, DataOutput dOut)
+            throws SystemException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+}
\ No newline at end of file

Propchange: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModOperation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModScalarEvaluatorFactory.java?rev=1375294&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModScalarEvaluatorFactory.java (added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModScalarEvaluatorFactory.java Mon Aug 20 22:56:54 2012
@@ -0,0 +1,16 @@
+package org.apache.vxquery.runtime.functions.arithmetic;
+
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+
+public class ModScalarEvaluatorFactory extends AbstractArithmeticScalarEvaluatorFactory {
+    private static final long serialVersionUID = 1L;
+
+    public ModScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected AbstractArithmeticOperation createArithmeticOperation() {
+        return new ModOperation();
+    }
+}
\ No newline at end of file

Propchange: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/arithmetic/ModScalarEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native