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 2013/12/13 19:30:44 UTC
svn commit: r1550796 - in
/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions:
bool/FnBooleanScalarEvaluatorFactory.java
type/PromoteScalarEvaluatorFactory.java
Author: prestonc
Date: Fri Dec 13 18:30:43 2013
New Revision: 1550796
URL: http://svn.apache.org/r1550796
Log:
Updated the functions to have a single return. Allowed for easier debugging when tracking time in the evaluator.
Modified:
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/type/PromoteScalarEvaluatorFactory.java
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java?rev=1550796&r1=1550795&r2=1550796&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java Fri Dec 13 18:30:43 2013
@@ -62,15 +62,14 @@ public class FnBooleanScalarEvaluatorFac
@Override
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
TaggedValuePointable tvp = args[0];
+ boolean booleanResult = true;
switch (tvp.getTag()) {
case ValueTag.SEQUENCE_TAG: {
tvp.getValue(seqp);
if (seqp.getEntryCount() == 0) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
case ValueTag.XS_BOOLEAN_TAG: {
@@ -81,11 +80,9 @@ public class FnBooleanScalarEvaluatorFac
case ValueTag.XS_DECIMAL_TAG: {
tvp.getValue(decp);
if (decp.longValue() == 0) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
case ValueTag.XS_INTEGER_TAG:
@@ -98,77 +95,69 @@ public class FnBooleanScalarEvaluatorFac
case ValueTag.XS_UNSIGNED_LONG_TAG: {
tvp.getValue(lp);
if (lp.longValue() == 0) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
case ValueTag.XS_INT_TAG:
case ValueTag.XS_UNSIGNED_SHORT_TAG: {
tvp.getValue(ip);
if (ip.intValue() == 0) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
case ValueTag.XS_SHORT_TAG:
case ValueTag.XS_UNSIGNED_BYTE_TAG: {
tvp.getValue(sp);
if (sp.shortValue() == 0) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
case ValueTag.XS_BYTE_TAG: {
tvp.getValue(bp);
if (bp.byteValue() == 0) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
case ValueTag.XS_DOUBLE_TAG: {
tvp.getValue(dp);
if (dp.doubleValue() == 0 || Double.isNaN(dp.doubleValue())) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
case ValueTag.XS_FLOAT_TAG: {
tvp.getValue(fp);
if (fp.floatValue() == 0 || Float.isNaN(fp.floatValue())) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
case ValueTag.XS_ANY_URI_TAG:
case ValueTag.XS_STRING_TAG: {
tvp.getValue(utf8p);
if (utf8p.getUTFLength() == 0) {
- XDMConstants.setFalse(result);
- return;
+ booleanResult = false;
}
- XDMConstants.setTrue(result);
- return;
+ break;
}
+ default:
+ throw new SystemException(ErrorCode.FORG0006);
+ }
+ if (booleanResult) {
+ XDMConstants.setTrue(result);
+ } else {
+ XDMConstants.setFalse(result);
}
- throw new SystemException(ErrorCode.FORG0006);
}
};
}
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/type/PromoteScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/type/PromoteScalarEvaluatorFactory.java?rev=1550796&r1=1550795&r2=1550796&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/type/PromoteScalarEvaluatorFactory.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/type/PromoteScalarEvaluatorFactory.java Fri Dec 13 18:30:43 2013
@@ -69,114 +69,114 @@ public class PromoteScalarEvaluatorFacto
tvp.getValue(tp.utf8sp);
aOp.convertAnyURI(tp.utf8sp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_BYTE_TAG:
tvp.getValue(tp.bytep);
aOp.convertByte(tp.bytep, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_DECIMAL_TAG:
tvp.getValue(tp.decp);
aOp.convertDecimal(tp.decp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_DOUBLE_TAG:
tvp.getValue(tp.doublep);
aOp.convertDouble(tp.doublep, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_FLOAT_TAG:
tvp.getValue(tp.floatp);
aOp.convertFloat(tp.floatp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_INT_TAG:
tvp.getValue(tp.intp);
aOp.convertInt(tp.intp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_INTEGER_TAG:
tvp.getValue(tp.longp);
aOp.convertInteger(tp.longp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_LONG_TAG:
tvp.getValue(tp.longp);
aOp.convertLong(tp.longp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_NEGATIVE_INTEGER_TAG:
tvp.getValue(tp.longp);
aOp.convertNegativeInteger(tp.longp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_NON_NEGATIVE_INTEGER_TAG:
tvp.getValue(tp.longp);
aOp.convertNonNegativeInteger(tp.longp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_NON_POSITIVE_INTEGER_TAG:
tvp.getValue(tp.longp);
aOp.convertNonPositiveInteger(tp.longp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_POSITIVE_INTEGER_TAG:
tvp.getValue(tp.longp);
aOp.convertPositiveInteger(tp.longp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_SHORT_TAG:
tvp.getValue(tp.shortp);
aOp.convertShort(tp.shortp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_STRING_TAG:
tvp.getValue(tp.utf8sp);
aOp.convertString(tp.utf8sp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_UNSIGNED_BYTE_TAG:
tvp.getValue(tp.shortp);
aOp.convertUnsignedByte(tp.shortp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_UNSIGNED_INT_TAG:
tvp.getValue(tp.longp);
aOp.convertUnsignedInt(tp.longp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_UNSIGNED_LONG_TAG:
tvp.getValue(tp.longp);
aOp.convertUnsignedLong(tp.longp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
case ValueTag.XS_UNSIGNED_SHORT_TAG:
tvp.getValue(tp.intp);
aOp.convertUnsignedShort(tp.intp, dOut);
result.set(abvs.getByteArray(), abvs.getStartOffset(), abvs.getLength());
- return;
+ break;
default:
// Promote type does not require us to change the value.
result.set(tvp);
- return;
+ break;
}
} catch (SystemException se) {
throw se;