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 02:32:14 UTC
svn commit: r1375346 - in
/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison:
ValueEqComparisonOperation.java ValueLtComparisonOperation.java
Author: prestonc
Date: Tue Aug 21 00:32:14 2012
New Revision: 1375346
URL: http://svn.apache.org/viewvc?rev=1375346&view=rev
Log:
Date comparisons now use one array backed value store and pass the equal tests.
Modified:
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueEqComparisonOperation.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueLtComparisonOperation.java
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueEqComparisonOperation.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueEqComparisonOperation.java?rev=1375346&r1=1375345&r2=1375346&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueEqComparisonOperation.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueEqComparisonOperation.java Tue Aug 21 00:32:14 2012
@@ -23,10 +23,8 @@ import edu.uci.ics.hyracks.data.std.prim
import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
public class ValueEqComparisonOperation extends AbstractValueComparisonOperation {
- protected final ArrayBackedValueStorage abvs1 = new ArrayBackedValueStorage();
- protected final DataOutput dOut1 = abvs1.getDataOutput();
- protected final ArrayBackedValueStorage abvs2 = new ArrayBackedValueStorage();
- protected final DataOutput dOut2 = abvs1.getDataOutput();
+ protected final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
+ protected final DataOutput dOutInner = abvsInner.getDataOutput();
@Override
public boolean operateAnyURIAnyURI(UTF8StringPointable stringp1, UTF8StringPointable stringp2)
@@ -50,16 +48,15 @@ public class ValueEqComparisonOperation
@Override
public boolean operateDateDate(XSDatePointable datep1, XSDatePointable datep2, DynamicContext dCtx)
throws SystemException, IOException {
- abvs1.reset();
- DateTime.getTimezoneDateTime(datep1, dCtx, dOut1);
- byte[] bytes1 = abvs1.getByteArray();
-
- abvs2.reset();
- DateTime.getTimezoneDateTime(datep2, dCtx, dOut2);
- byte[] bytes2 = abvs2.getByteArray();
-
- if (XSDateTimePointable.getYearMonth(bytes1, abvs1.getStartOffset()) == XSDateTimePointable.getYearMonth(bytes2, abvs2.getStartOffset())
- && XSDateTimePointable.getDayTime(bytes1, abvs1.getStartOffset()) == XSDateTimePointable.getDayTime(bytes2, abvs2.getStartOffset())) {
+ abvsInner.reset();
+ DateTime.getTimezoneDateTime(datep1, dCtx, dOutInner);
+ DateTime.getTimezoneDateTime(datep2, dCtx, dOutInner);
+ int startOffset1 = abvsInner.getStartOffset() + 1;
+ int startOffset2 = startOffset1 + 1 + XSDateTimePointable.TYPE_TRAITS.getFixedLength();
+ if (XSDateTimePointable.getYearMonth(abvsInner.getByteArray(), startOffset1) == XSDateTimePointable.getYearMonth(
+ abvsInner.getByteArray(), startOffset2)
+ && XSDateTimePointable.getDayTime(abvsInner.getByteArray(), startOffset1) == XSDateTimePointable
+ .getDayTime(abvsInner.getByteArray(), startOffset2)) {
return true;
}
return false;
@@ -68,16 +65,15 @@ public class ValueEqComparisonOperation
@Override
public boolean operateDatetimeDatetime(XSDateTimePointable datetimep1, XSDateTimePointable datetimep2,
DynamicContext dCtx) throws SystemException, IOException {
- abvs1.reset();
- DateTime.getTimezoneDateTime(datetimep1, dCtx, dOut1);
- byte[] bytes1 = abvs1.getByteArray();
-
- abvs2.reset();
- DateTime.getTimezoneDateTime(datetimep2, dCtx, dOut2);
- byte[] bytes2 = abvs2.getByteArray();
-
- if (XSDateTimePointable.getYearMonth(bytes1, 0) == XSDateTimePointable.getYearMonth(bytes2, 0)
- && XSDateTimePointable.getDayTime(bytes1, 0) == XSDateTimePointable.getDayTime(bytes2, 0)) {
+ abvsInner.reset();
+ DateTime.getTimezoneDateTime(datetimep1, dCtx, dOutInner);
+ DateTime.getTimezoneDateTime(datetimep2, dCtx, dOutInner);
+ int startOffset1 = abvsInner.getStartOffset() + 1;
+ int startOffset2 = startOffset1 + 1 + XSDateTimePointable.TYPE_TRAITS.getFixedLength();
+ if (XSDateTimePointable.getYearMonth(abvsInner.getByteArray(), startOffset1) == XSDateTimePointable.getYearMonth(
+ abvsInner.getByteArray(), startOffset2)
+ && XSDateTimePointable.getDayTime(abvsInner.getByteArray(), startOffset1) == XSDateTimePointable
+ .getDayTime(abvsInner.getByteArray(), startOffset2)) {
return true;
}
return false;
@@ -275,15 +271,18 @@ public class ValueEqComparisonOperation
@Override
public boolean operateTimeTime(XSTimePointable timep1, XSTimePointable timep2, DynamicContext dCtx)
throws SystemException, IOException {
- abvs1.reset();
- DateTime.getTimezoneDateTime(timep1, dCtx, dOut1);
- byte[] bytes1 = abvs1.getByteArray();
-
- abvs2.reset();
- DateTime.getTimezoneDateTime(timep2, dCtx, dOut2);
- byte[] bytes2 = abvs2.getByteArray();
-
- return XSDateTimePointable.getDayTime(bytes1, 0) == XSDateTimePointable.getDayTime(bytes2, 0);
+ abvsInner.reset();
+ DateTime.getTimezoneDateTime(timep1, dCtx, dOutInner);
+ DateTime.getTimezoneDateTime(timep2, dCtx, dOutInner);
+ int startOffset1 = abvsInner.getStartOffset() + 1;
+ int startOffset2 = startOffset1 + 1 + XSDateTimePointable.TYPE_TRAITS.getFixedLength();
+ if (XSDateTimePointable.getYearMonth(abvsInner.getByteArray(), startOffset1) == XSDateTimePointable.getYearMonth(
+ abvsInner.getByteArray(), startOffset2)
+ && XSDateTimePointable.getDayTime(abvsInner.getByteArray(), startOffset1) == XSDateTimePointable
+ .getDayTime(abvsInner.getByteArray(), startOffset2)) {
+ return true;
+ }
+ return false;
}
@Override
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueLtComparisonOperation.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueLtComparisonOperation.java?rev=1375346&r1=1375345&r2=1375346&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueLtComparisonOperation.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/ValueLtComparisonOperation.java Tue Aug 21 00:32:14 2012
@@ -23,10 +23,8 @@ import edu.uci.ics.hyracks.data.std.prim
import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
public class ValueLtComparisonOperation extends AbstractValueComparisonOperation {
- protected final ArrayBackedValueStorage abvs1 = new ArrayBackedValueStorage();
- protected final DataOutput dOut1 = abvs1.getDataOutput();
- protected final ArrayBackedValueStorage abvs2 = new ArrayBackedValueStorage();
- protected final DataOutput dOut2 = abvs2.getDataOutput();
+ protected final ArrayBackedValueStorage abvsInner = new ArrayBackedValueStorage();
+ protected final DataOutput dOutInner = abvsInner.getDataOutput();
@Override
public boolean operateAnyURIAnyURI(UTF8StringPointable stringp1, UTF8StringPointable stringp2)
@@ -49,16 +47,15 @@ public class ValueLtComparisonOperation
@Override
public boolean operateDateDate(XSDatePointable datep1, XSDatePointable datep2, DynamicContext dCtx)
throws SystemException, IOException {
- abvs1.reset();
- DateTime.getTimezoneDateTime(datep1, dCtx, dOut1);
- byte[] bytes1 = abvs1.getByteArray();
-
- abvs2.reset();
- DateTime.getTimezoneDateTime(datep2, dCtx, dOut2);
- byte[] bytes2 = abvs2.getByteArray();
-
- if (XSDateTimePointable.getYearMonth(bytes1, 0) < XSDateTimePointable.getYearMonth(bytes2, 0)
- && XSDateTimePointable.getDayTime(bytes1, 0) < XSDateTimePointable.getDayTime(bytes2, 0)) {
+ abvsInner.reset();
+ DateTime.getTimezoneDateTime(datep1, dCtx, dOutInner);
+ DateTime.getTimezoneDateTime(datep2, dCtx, dOutInner);
+ int startOffset1 = abvsInner.getStartOffset() + 1;
+ int startOffset2 = startOffset1 + 1 + XSDateTimePointable.TYPE_TRAITS.getFixedLength();
+ if (XSDateTimePointable.getYearMonth(abvsInner.getByteArray(), startOffset1) < XSDateTimePointable
+ .getYearMonth(abvsInner.getByteArray(), startOffset2)
+ && XSDateTimePointable.getDayTime(abvsInner.getByteArray(), startOffset1) < XSDateTimePointable
+ .getDayTime(abvsInner.getByteArray(), startOffset2)) {
return true;
}
return false;
@@ -67,16 +64,15 @@ public class ValueLtComparisonOperation
@Override
public boolean operateDatetimeDatetime(XSDateTimePointable datetimep1, XSDateTimePointable datetimep2,
DynamicContext dCtx) throws SystemException, IOException {
- abvs1.reset();
- DateTime.getTimezoneDateTime(datetimep1, dCtx, dOut1);
- byte[] bytes1 = abvs1.getByteArray();
-
- abvs2.reset();
- DateTime.getTimezoneDateTime(datetimep2, dCtx, dOut2);
- byte[] bytes2 = abvs2.getByteArray();
-
- if (XSDateTimePointable.getYearMonth(bytes1, 0) < XSDateTimePointable.getYearMonth(bytes2, 0)
- && XSDateTimePointable.getDayTime(bytes1, 0) < XSDateTimePointable.getDayTime(bytes2, 0)) {
+ abvsInner.reset();
+ DateTime.getTimezoneDateTime(datetimep1, dCtx, dOutInner);
+ DateTime.getTimezoneDateTime(datetimep2, dCtx, dOutInner);
+ int startOffset1 = abvsInner.getStartOffset() + 1;
+ int startOffset2 = startOffset1 + 1 + XSDateTimePointable.TYPE_TRAITS.getFixedLength();
+ if (XSDateTimePointable.getYearMonth(abvsInner.getByteArray(), startOffset1) < XSDateTimePointable
+ .getYearMonth(abvsInner.getByteArray(), startOffset2)
+ && XSDateTimePointable.getDayTime(abvsInner.getByteArray(), startOffset1) < XSDateTimePointable
+ .getDayTime(abvsInner.getByteArray(), startOffset2)) {
return true;
}
return false;
@@ -271,15 +267,18 @@ public class ValueLtComparisonOperation
@Override
public boolean operateTimeTime(XSTimePointable timep1, XSTimePointable timep2, DynamicContext dCtx)
throws SystemException, IOException {
- abvs1.reset();
- DateTime.getTimezoneDateTime(timep1, dCtx, dOut1);
- byte[] bytes1 = abvs1.getByteArray();
-
- abvs2.reset();
- DateTime.getTimezoneDateTime(timep2, dCtx, dOut2);
- byte[] bytes2 = abvs2.getByteArray();
-
- return XSDateTimePointable.getDayTime(bytes1, 0) < XSDateTimePointable.getDayTime(bytes2, 0);
+ abvsInner.reset();
+ DateTime.getTimezoneDateTime(timep1, dCtx, dOutInner);
+ DateTime.getTimezoneDateTime(timep2, dCtx, dOutInner);
+ int startOffset1 = abvsInner.getStartOffset() + 1;
+ int startOffset2 = startOffset1 + 1 + XSDateTimePointable.TYPE_TRAITS.getFixedLength();
+ if (XSDateTimePointable.getYearMonth(abvsInner.getByteArray(), startOffset1) < XSDateTimePointable.getYearMonth(
+ abvsInner.getByteArray(), startOffset2)
+ && XSDateTimePointable.getDayTime(abvsInner.getByteArray(), startOffset1) < XSDateTimePointable
+ .getDayTime(abvsInner.getByteArray(), startOffset2)) {
+ return true;
+ }
+ return false;
}
@Override