addressed Sattam's comments to eliminate object creation (introduced some copy-and-paste code, but have not found a better solution for this; could be revised later if better solution can be found)
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_temp_missing_tests@1340 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
index d4ce0e5..5f68522 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.AMutableDate;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -63,9 +62,7 @@
long chrononTimeInMs = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
- charAccessor.reset(date, 0, date.length());
- chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor);
+ chrononTimeInMs = ADateParserFactory.parseDatePart(date, 0, date.length());
} catch (Exception e) {
throw new HyracksDataException(e);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
index 93825b9..aadaac3 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.AMutableDateTime;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
@@ -66,27 +65,22 @@
long chrononTimeInMs = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-
- charAccessor.reset(datetime, 0, datetime.length());
// +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ short timeOffset = (short) ((datetime.charAt(0) == '-') ? 1 : 0);
timeOffset += 8;
- if(charAccessor.getCharAt(timeOffset) != 'T'){
+ if(datetime.charAt(timeOffset) != 'T'){
timeOffset += 2;
- if(charAccessor.getCharAt(timeOffset) != 'T'){
+ if(datetime.charAt(timeOffset) != 'T'){
throw new AlgebricksException(errorMessage + ": missing T");
}
}
- charAccessor.reset(datetime, 0, timeOffset);
- chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor);
+ chrononTimeInMs = ADateParserFactory.parseDatePart(datetime, 0, timeOffset);
- charAccessor.reset(datetime, timeOffset + 1, datetime.length() - timeOffset - 1);
- chrononTimeInMs += ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMs += ATimeParserFactory.parseTimePart(datetime, timeOffset + 1, datetime.length() - timeOffset - 1);
} catch (Exception e) {
throw new HyracksDataException(e);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
index 88e2ea5..2c38443 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
@@ -8,7 +8,6 @@
import edu.uci.ics.asterix.om.base.ADuration;
import edu.uci.ics.asterix.om.base.AMutableDuration;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -47,9 +46,7 @@
public static void parse(String duration, DataOutput out) throws HyracksDataException {
try {
AMutableDuration aDuration = new AMutableDuration(0, 0);
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
- charAccessor.reset(duration, 0, duration.length());
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory.parseDuration(duration, 0, duration.length(), aDuration);
durationSerde.serialize(aDuration, out);
} catch (Exception e) {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
index 25ef597..5156bf9 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
@@ -24,7 +24,6 @@
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.ATypeTag;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -93,8 +92,6 @@
long chrononTimeInMsEnd = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-
// the starting point for parsing (so for the accessor)
int startOffset = 0;
int endOffset, timeSeperatorOffsetInDatetimeString;
@@ -115,24 +112,22 @@
startOffset++;
}
- charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
-
// +1 if it is negative (-)
- timeSeperatorOffsetInDatetimeString = ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ timeSeperatorOffsetInDatetimeString = ((interval.charAt(startOffset) == '-') ? 1 : 0);
timeSeperatorOffsetInDatetimeString += 8;
- if (charAccessor.getCharAt(timeSeperatorOffsetInDatetimeString) != 'T') {
+ if (interval.charAt(startOffset + timeSeperatorOffsetInDatetimeString) != 'T') {
timeSeperatorOffsetInDatetimeString += 2;
- if (charAccessor.getCharAt(timeSeperatorOffsetInDatetimeString) != 'T') {
+ if (interval.charAt(startOffset + timeSeperatorOffsetInDatetimeString) != 'T') {
throw new AlgebricksException(errorMessage + ": missing T for a datetime value.");
}
}
- charAccessor.reset(interval, startOffset, timeSeperatorOffsetInDatetimeString);
- chrononTimeInMsStart = ADateParserFactory.parseDatePart(charAccessor);
- charAccessor.reset(interval, startOffset + timeSeperatorOffsetInDatetimeString + 1, endOffset
+
+ chrononTimeInMsStart = ADateParserFactory.parseDatePart(interval, startOffset, timeSeperatorOffsetInDatetimeString);
+
+ chrononTimeInMsStart += ATimeParserFactory.parseTimePart(interval, startOffset + timeSeperatorOffsetInDatetimeString + 1, endOffset
- (startOffset + timeSeperatorOffsetInDatetimeString + 1) + 1);
- chrononTimeInMsStart += ATimeParserFactory.parseTimePart(charAccessor);
// Interval End
startOffset = commaIndex + 1;
@@ -145,24 +140,22 @@
startOffset++;
}
- charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
-
// +1 if it is negative (-)
- timeSeperatorOffsetInDatetimeString = ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ timeSeperatorOffsetInDatetimeString = ((interval.charAt(startOffset) == '-') ? 1 : 0);
timeSeperatorOffsetInDatetimeString += 8;
- if (charAccessor.getCharAt(timeSeperatorOffsetInDatetimeString) != 'T') {
+ if (interval.charAt(startOffset + timeSeperatorOffsetInDatetimeString) != 'T') {
timeSeperatorOffsetInDatetimeString += 2;
- if (charAccessor.getCharAt(timeSeperatorOffsetInDatetimeString) != 'T') {
+ if (interval.charAt(startOffset + timeSeperatorOffsetInDatetimeString) != 'T') {
throw new AlgebricksException(errorMessage + ": missing T for a datetime value.");
}
}
- charAccessor.reset(interval, startOffset, timeSeperatorOffsetInDatetimeString);
- chrononTimeInMsEnd = ADateParserFactory.parseDatePart(charAccessor);
- charAccessor.reset(interval, startOffset + timeSeperatorOffsetInDatetimeString + 1, endOffset
+
+ chrononTimeInMsEnd = ADateParserFactory.parseDatePart(interval, startOffset, timeSeperatorOffsetInDatetimeString);
+
+ chrononTimeInMsEnd += ATimeParserFactory.parseTimePart(interval, startOffset + timeSeperatorOffsetInDatetimeString + 1, endOffset
- (startOffset + timeSeperatorOffsetInDatetimeString + 1) + 1);
- chrononTimeInMsEnd += ATimeParserFactory.parseTimePart(charAccessor);
} catch (Exception e) {
throw new HyracksDataException(e);
}
@@ -179,8 +172,6 @@
long chrononTimeInMsEnd = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-
int startOffset = 0;
int endOffset;
@@ -201,8 +192,7 @@
}
// Interval Start
- charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
- chrononTimeInMsStart = ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMsStart = ATimeParserFactory.parseTimePart(interval, startOffset, endOffset - startOffset + 1);
if (chrononTimeInMsStart < 0) {
chrononTimeInMsStart += GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -220,8 +210,7 @@
endOffset--;
}
- charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
- chrononTimeInMsEnd = ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMsEnd = ATimeParserFactory.parseTimePart(interval, startOffset, endOffset - startOffset + 1);
if (chrononTimeInMsEnd < 0) {
chrononTimeInMsEnd += GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -243,7 +232,6 @@
short tempStart = 0;
short tempEnd = 0;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
// the starting point for parsing (so for the accessor)
int startOffset = 0;
@@ -265,8 +253,7 @@
startOffset++;
}
- charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
- chrononTimeInMsStart = ADateParserFactory.parseDatePart(charAccessor);
+ chrononTimeInMsStart = ADateParserFactory.parseDatePart(interval, startOffset, endOffset - startOffset + 1);
// Interval End
startOffset = commaIndex + 1;
@@ -279,8 +266,7 @@
startOffset++;
}
- charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
- chrononTimeInMsEnd = ADateParserFactory.parseDatePart(charAccessor);
+ chrononTimeInMsEnd = ADateParserFactory.parseDatePart(interval, startOffset, endOffset - startOffset + 1);
} catch (Exception e) {
throw new HyracksDataException(e);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
index 26e8d7a..78baeed 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
@@ -8,7 +8,6 @@
import edu.uci.ics.asterix.om.base.AMutableTime;
import edu.uci.ics.asterix.om.base.ATime;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -51,9 +50,7 @@
int chrononTimeInMs;
try {
- StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
- charAccessor.reset(time, 0, time.length());
- chrononTimeInMs = ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMs = ATimeParserFactory.parseTimePart(time, 0, time.length());
} catch (Exception e) {
throw new HyracksDataException(e);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
index 7a335a7..c1fbcb2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
@@ -36,15 +36,12 @@
@Override
public IValueParser createValueParser() {
- final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
return new IValueParser() {
@Override
public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
- charArrayAccessor.reset(buffer, start, length);
try {
- out.writeInt((int) (parseDatePart(charArrayAccessor) / GregorianCalendarSystem.CHRONON_OF_DAY));
+ out.writeInt((int) (parseDatePart(buffer, start, length) / GregorianCalendarSystem.CHRONON_OF_DAY));
} catch (IOException ex) {
throw new HyracksDataException(ex);
}
@@ -63,10 +60,9 @@
* @return
* @throws Exception
*/
- public static <T> long parseDatePart(ICharSequenceAccessor<T> charAccessor)
+ public static long parseDatePart(String dateString, int start, int length)
throws HyracksDataException {
- int length = charAccessor.getLength();
int offset = 0;
int year = 0, month = 0, day = 0;
@@ -74,25 +70,25 @@
boolean isExtendedForm = false;
- if (charAccessor.getCharAt(offset) == '-') {
+ if (dateString.charAt(start + offset) == '-') {
offset++;
positive = false;
}
- if (charAccessor.getCharAt(offset + 4) == '-') {
+ if (dateString.charAt(start + offset + 4) == '-') {
isExtendedForm = true;
}
if (isExtendedForm) {
- if (charAccessor.getCharAt(offset + 4) != '-' || charAccessor.getCharAt(offset + 7) != '-') {
+ if (dateString.charAt(start + offset + 4) != '-' || dateString.charAt(start + offset + 7) != '-') {
throw new HyracksDataException("Missing dash in the date string as an extended form");
}
}
// year
for (int i = 0; i < 4; i++) {
- if (charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9') {
- year = year * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if (dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9') {
+ year = year * 10 + dateString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException("Non-numeric value in year field");
}
@@ -107,8 +103,8 @@
// month
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- month = month * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9')) {
+ month = month * 10 + dateString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException("Non-numeric value in month field");
}
@@ -122,8 +118,105 @@
// day
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- day = day * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9')) {
+ day = day * 10 + dateString.charAt(start + offset + i) - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in day field");
+ }
+ }
+
+ if (day < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.DAY.ordinal()]
+ || day > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.DAY.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": day " + day);
+ }
+
+ offset += 2;
+
+ if (!positive) {
+ year *= -1;
+ }
+
+ if (length > offset) {
+ throw new HyracksDataException("Too many chars for a date only value");
+ }
+
+ if (!GregorianCalendarSystem.getInstance().validate(year, month, day, 0, 0, 0, 0)){
+ throw new HyracksDataException(dateErrorMessage);
+ }
+
+ return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
+ }
+
+ /**
+ * A copy-and-paste of {@link #parseDatePart(String, int, int)} but for a char array, in order
+ * to avoid object creation.
+ *
+ * @param dateString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static long parseDatePart(char[] dateString, int start, int length)
+ throws HyracksDataException {
+
+ int offset = 0;
+
+ int year = 0, month = 0, day = 0;
+ boolean positive = true;
+
+ boolean isExtendedForm = false;
+
+ if (dateString[start + offset] == '-') {
+ offset++;
+ positive = false;
+ }
+
+ if (dateString[start + offset + 4] == '-') {
+ isExtendedForm = true;
+ }
+
+ if (isExtendedForm) {
+ if (dateString[start + offset + 4] != '-' || dateString[start + offset + 7] != '-') {
+ throw new HyracksDataException("Missing dash in the date string as an extended form");
+ }
+ }
+
+ // year
+ for (int i = 0; i < 4; i++) {
+ if (dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9') {
+ year = year * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in year field");
+ }
+ }
+
+ if (year < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.YEAR.ordinal()]
+ || year > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.YEAR.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": year " + year);
+ }
+
+ offset += (isExtendedForm) ? 5 : 4;
+
+ // month
+ for (int i = 0; i < 2; i++) {
+ if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+ month = month * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in month field");
+ }
+ }
+
+ if (month < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MONTH.ordinal()]
+ || month > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MONTH.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": month " + month);
+ }
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // day
+ for (int i = 0; i < 2; i++) {
+ if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+ day = day * 10 + dateString[start + offset + i] - '0';
} else {
throw new HyracksDataException("Non-numeric value in day field");
}
@@ -151,4 +244,100 @@
return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
}
+ /**
+ * A copy-and-paste of {@link #parseDatePart(String, int, int)} but for a byte array, in order
+ * to avoid object creation.
+ *
+ * @param dateString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static long parseDatePart(byte[] dateString, int start, int length)
+ throws HyracksDataException {
+
+ int offset = 0;
+
+ int year = 0, month = 0, day = 0;
+ boolean positive = true;
+
+ boolean isExtendedForm = false;
+
+ if (dateString[start + offset] == '-') {
+ offset++;
+ positive = false;
+ }
+
+ if (dateString[start + offset + 4] == '-') {
+ isExtendedForm = true;
+ }
+
+ if (isExtendedForm) {
+ if (dateString[start + offset + 4] != '-' || dateString[start + offset + 7] != '-') {
+ throw new HyracksDataException("Missing dash in the date string as an extended form");
+ }
+ }
+
+ // year
+ for (int i = 0; i < 4; i++) {
+ if (dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9') {
+ year = year * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in year field");
+ }
+ }
+
+ if (year < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.YEAR.ordinal()]
+ || year > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.YEAR.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": year " + year);
+ }
+
+ offset += (isExtendedForm) ? 5 : 4;
+
+ // month
+ for (int i = 0; i < 2; i++) {
+ if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+ month = month * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in month field");
+ }
+ }
+
+ if (month < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MONTH.ordinal()]
+ || month > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MONTH.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": month " + month);
+ }
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // day
+ for (int i = 0; i < 2; i++) {
+ if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+ day = day * 10 + dateString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException("Non-numeric value in day field");
+ }
+ }
+
+ if (day < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.DAY.ordinal()]
+ || day > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.DAY.ordinal()]) {
+ throw new HyracksDataException(dateErrorMessage + ": day " + day);
+ }
+
+ offset += 2;
+
+ if (!positive) {
+ year *= -1;
+ }
+
+ if (length > offset) {
+ throw new HyracksDataException("Too many chars for a date only value");
+ }
+
+ if (!GregorianCalendarSystem.getInstance().validate(year, month, day, 0, 0, 0, 0)){
+ throw new HyracksDataException(dateErrorMessage);
+ }
+
+ return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
+ }
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
index b555c38..c95ac3a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
@@ -36,32 +36,27 @@
@Override
public IValueParser createValueParser() {
- final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
return new IValueParser() {
@Override
public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
long chrononTimeInMs = 0;
- charArrayAccessor.reset(buffer, start, length);
-
- short timeOffset = (short) ((charArrayAccessor.getCharAt(0) == '-') ? 1 : 0);
+ short timeOffset = (short) ((buffer[start] == '-') ? 1 : 0);
timeOffset += 8;
- if (charArrayAccessor.getCharAt(timeOffset) != 'T') {
+ if (buffer[start + timeOffset] != 'T') {
timeOffset += 2;
- if (charArrayAccessor.getCharAt(timeOffset) != 'T') {
+ if (buffer[start + timeOffset] != 'T') {
throw new HyracksDataException(dateTimeErrorMessage + ": missing T");
}
}
- charArrayAccessor.reset(buffer, start, timeOffset);
- chrononTimeInMs = ADateParserFactory.parseDatePart(charArrayAccessor);
+ chrononTimeInMs = ADateParserFactory.parseDatePart(buffer, start, timeOffset);
- charArrayAccessor.reset(buffer, start + timeOffset + 1, length - timeOffset - 1);
- chrononTimeInMs += ATimeParserFactory.parseTimePart(charArrayAccessor);
+ chrononTimeInMs += ATimeParserFactory.parseTimePart(buffer, start + timeOffset + 1, length - timeOffset
+ - 1);
try {
out.writeLong(chrononTimeInMs);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
index b176061..de5a6a1 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
@@ -36,14 +36,12 @@
@Override
public IValueParser createValueParser() {
- final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
final AMutableDuration aMutableDuration = new AMutableDuration(0, 0);
return new IValueParser() {
@Override
public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
- charArrayAccessor.reset(buffer, start, length);
- parseDuration(charArrayAccessor, aMutableDuration);
+ parseDuration(buffer, start, length, aMutableDuration);
try {
out.writeInt(aMutableDuration.getMonths());
out.writeLong(aMutableDuration.getMilliseconds());
@@ -66,7 +64,7 @@
SEC;
};
- public static <T> void parseDuration(ICharSequenceAccessor<T> charAccessor, AMutableDuration aDuration)
+ public static void parseDuration(String durationString, int start, int length, AMutableDuration aDuration)
throws HyracksDataException {
boolean positive = true;
@@ -74,21 +72,23 @@
int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
State state = State.NOTHING_READ;
- if (charAccessor.getCharAt(offset) == '-') {
+ if (durationString.charAt(start + offset) == '-') {
offset++;
positive = false;
}
- if (charAccessor.getCharAt(offset++) != 'P') {
+ if (durationString.charAt(start + offset) != 'P') {
throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
}
- for (; offset < charAccessor.getLength(); offset++) {
- if (charAccessor.getCharAt(offset) >= '0' && charAccessor.getCharAt(offset) <= '9') {
+ offset++;
+
+ for (; offset < length; offset++) {
+ if (durationString.charAt(start + offset) >= '0' && durationString.charAt(start + offset) <= '9') {
// accumulate the digit fields
- value = value * 10 + charAccessor.getCharAt(offset) - '0';
+ value = value * 10 + durationString.charAt(start + offset) - '0';
} else {
- switch (charAccessor.getCharAt(offset)) {
+ switch (durationString.charAt(start + offset)) {
case 'Y':
if (state.compareTo(State.YEAR) < 0) {
year = value;
@@ -139,11 +139,276 @@
case '.':
if (state.compareTo(State.MILLISEC) < 0) {
int i = 1;
- for (; offset + i < charAccessor.getLength(); i++) {
- if (charAccessor.getCharAt(offset + i) >= '0'
- && charAccessor.getCharAt(offset + i) <= '9') {
+ for (; offset + i < length; i++) {
+ if (durationString.charAt(start + offset + i) >= '0'
+ && durationString.charAt(start + offset + i) <= '9') {
if (i < 4) {
- millisecond = millisecond * 10 + (charAccessor.getCharAt(offset + i) - '0');
+ millisecond = millisecond * 10
+ + (durationString.charAt(start + offset + i) - '0');
+ } else {
+ throw new HyracksDataException(durationErrorMessage
+ + ": wrong MILLISECOND field.");
+ }
+ } else {
+ break;
+ }
+ }
+ offset += i;
+ state = State.MILLISEC;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MILLISECOND field.");
+ }
+ case 'S':
+ if (state.compareTo(State.SEC) < 0) {
+ second = value;
+ state = State.SEC;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong SECOND field.");
+ }
+ break;
+ default:
+ throw new HyracksDataException(durationErrorMessage + ": wrong format for duration.");
+
+ }
+ value = 0;
+ }
+ }
+
+ if (state.compareTo(State.TIME) == 0) {
+ throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
+ }
+
+ short temp = 1;
+ if (!positive) {
+ temp = -1;
+ }
+
+ aDuration.setValue(temp * (year * 12 + month), temp
+ * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
+
+ }
+
+ /**
+ * Copy-and-paste the code in {@link #parseDuration(String, int, int, AMutableDuration)} in order to eliminate
+ * object creation.
+ *
+ * @param charAccessor
+ * @param start
+ * @param length
+ * @param aDuration
+ * @throws HyracksDataException
+ */
+ public static void parseDuration(char[] charAccessor, int start, int length, AMutableDuration aDuration)
+ throws HyracksDataException {
+
+ boolean positive = true;
+ int offset = 0;
+ int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
+ State state = State.NOTHING_READ;
+
+ if (charAccessor[start + offset] == '-') {
+ offset++;
+ positive = false;
+ }
+
+ if (charAccessor[start + offset] != 'P') {
+ throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
+ }
+
+ offset++;
+
+ for (; offset < length; offset++) {
+ if (charAccessor[start + offset] >= '0' && charAccessor[start + offset] <= '9') {
+ // accumulate the digit fields
+ value = value * 10 + charAccessor[start + offset] - '0';
+ } else {
+ switch (charAccessor[start + offset]) {
+ case 'Y':
+ if (state.compareTo(State.YEAR) < 0) {
+ year = value;
+ state = State.YEAR;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong YEAR feild.");
+ }
+ break;
+ case 'M':
+ if (state.compareTo(State.TIME) < 0) {
+ if (state.compareTo(State.MONTH) < 0) {
+ month = value;
+ state = State.MONTH;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
+ }
+ } else if (state.compareTo(State.MIN) < 0) {
+ minute = value;
+ state = State.MIN;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MIN field.");
+ }
+ break;
+ case 'D':
+ if (state.compareTo(State.DAY) < 0) {
+ day = value;
+ state = State.DAY;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong DAY field");
+ }
+ break;
+ case 'T':
+ if (state.compareTo(State.TIME) < 0) {
+ state = State.TIME;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
+ }
+ break;
+
+ case 'H':
+ if (state.compareTo(State.HOUR) < 0) {
+ hour = value;
+ state = State.HOUR;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong HOUR field.");
+ }
+ break;
+ case '.':
+ if (state.compareTo(State.MILLISEC) < 0) {
+ int i = 1;
+ for (; offset + i < length; i++) {
+ if (charAccessor[start + offset + i] >= '0' && charAccessor[start + offset + i] <= '9') {
+ if (i < 4) {
+ millisecond = millisecond * 10 + (charAccessor[start + offset + i] - '0');
+ } else {
+ throw new HyracksDataException(durationErrorMessage
+ + ": wrong MILLISECOND field.");
+ }
+ } else {
+ break;
+ }
+ }
+ offset += i;
+ state = State.MILLISEC;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MILLISECOND field.");
+ }
+ case 'S':
+ if (state.compareTo(State.SEC) < 0) {
+ second = value;
+ state = State.SEC;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong SECOND field.");
+ }
+ break;
+ default:
+ throw new HyracksDataException(durationErrorMessage + ": wrong format for duration.");
+
+ }
+ value = 0;
+ }
+ }
+
+ if (state.compareTo(State.TIME) == 0) {
+ throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
+ }
+
+ short temp = 1;
+ if (!positive) {
+ temp = -1;
+ }
+
+ aDuration.setValue(temp * (year * 12 + month), temp
+ * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
+
+ }
+
+ /**
+ * Copy-and-paste the code in {@link #parseDuration(String, int, int, AMutableDuration)} in order to eliminate
+ * object creation.
+ *
+ * @param charAccessor
+ * @param start
+ * @param length
+ * @param aDuration
+ * @throws HyracksDataException
+ */
+ public static void parseDuration(byte[] charAccessor, int start, int length, AMutableDuration aDuration)
+ throws HyracksDataException {
+
+ boolean positive = true;
+ int offset = 0;
+ int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
+ State state = State.NOTHING_READ;
+
+ if (charAccessor[start + offset] == '-') {
+ offset++;
+ positive = false;
+ }
+
+ if (charAccessor[start + offset] != 'P') {
+ throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
+ }
+
+ offset++;
+
+ for (; offset < length; offset++) {
+ if (charAccessor[start + offset] >= '0' && charAccessor[start + offset] <= '9') {
+ // accumulate the digit fields
+ value = value * 10 + charAccessor[start + offset] - '0';
+ } else {
+ switch (charAccessor[start + offset]) {
+ case 'Y':
+ if (state.compareTo(State.YEAR) < 0) {
+ year = value;
+ state = State.YEAR;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong YEAR feild.");
+ }
+ break;
+ case 'M':
+ if (state.compareTo(State.TIME) < 0) {
+ if (state.compareTo(State.MONTH) < 0) {
+ month = value;
+ state = State.MONTH;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
+ }
+ } else if (state.compareTo(State.MIN) < 0) {
+ minute = value;
+ state = State.MIN;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong MIN field.");
+ }
+ break;
+ case 'D':
+ if (state.compareTo(State.DAY) < 0) {
+ day = value;
+ state = State.DAY;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong DAY field");
+ }
+ break;
+ case 'T':
+ if (state.compareTo(State.TIME) < 0) {
+ state = State.TIME;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
+ }
+ break;
+
+ case 'H':
+ if (state.compareTo(State.HOUR) < 0) {
+ hour = value;
+ state = State.HOUR;
+ } else {
+ throw new HyracksDataException(durationErrorMessage + ": wrong HOUR field.");
+ }
+ break;
+ case '.':
+ if (state.compareTo(State.MILLISEC) < 0) {
+ int i = 1;
+ for (; offset + i < length; i++) {
+ if (charAccessor[start + offset + i] >= '0' && charAccessor[start + offset + i] <= '9') {
+ if (i < 4) {
+ millisecond = millisecond * 10 + (charAccessor[start + offset + i] - '0');
} else {
throw new HyracksDataException(durationErrorMessage
+ ": wrong MILLISECOND field.");
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
index d76f41d..4c4e3fa 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
@@ -36,15 +36,12 @@
@Override
public IValueParser createValueParser() {
- final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
return new IValueParser() {
@Override
public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
- charArrayAccessor.reset(buffer, start, length);
try {
- out.writeInt(parseTimePart(charArrayAccessor));
+ out.writeInt(parseTimePart(buffer, start, length));
} catch (IOException ex) {
throw new HyracksDataException(ex);
}
@@ -53,32 +50,34 @@
}
/**
- * Parse the given char sequence as a time string, and return the milliseconds represented by the time.
+ * Parse the given string as a time string, and return the milliseconds represented by the time.
*
- * @param charAccessor
+ * @param timeString
+ * @param start
+ * @param length
* @return
- * @throws Exception
+ * @throws HyracksDataException
*/
- public static <T> int parseTimePart(ICharSequenceAccessor<T> charAccessor) throws HyracksDataException {
+ public static <T> int parseTimePart(String timeString, int start, int length) throws HyracksDataException {
- int length = charAccessor.getLength();
int offset = 0;
int hour = 0, min = 0, sec = 0, millis = 0;
int timezone = 0;
boolean isExtendedForm = false;
- if (charAccessor.getCharAt(offset + 2) == ':') {
+ if (timeString.charAt(start + offset + 2) == ':') {
isExtendedForm = true;
}
- if (isExtendedForm && (charAccessor.getCharAt(offset + 2) != ':' || charAccessor.getCharAt(offset + 5) != ':')) {
+ if (isExtendedForm
+ && (timeString.charAt(start + offset + 2) != ':' || timeString.charAt(start + offset + 5) != ':')) {
throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
}
// hour
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- hour = hour * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+ hour = hour * 10 + timeString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
}
@@ -93,8 +92,8 @@
// minute
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- min = min * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+ min = min * 10 + timeString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
}
@@ -109,8 +108,8 @@
// second
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
- sec = sec * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+ sec = sec * 10 + timeString.charAt(start + offset + i) - '0';
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
}
@@ -123,14 +122,14 @@
offset += 2;
- if ((isExtendedForm && length > offset && charAccessor.getCharAt(offset) == '.')
+ if ((isExtendedForm && length > offset && timeString.charAt(start + offset) == '.')
|| (!isExtendedForm && length > offset)) {
offset += (isExtendedForm) ? 1 : 0;
int i = 0;
for (; i < 3 && offset + i < length; i++) {
- if (charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9') {
- millis = millis * 10 + charAccessor.getCharAt(offset + i) - '0';
+ if (timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9') {
+ millis = millis * 10 + timeString.charAt(start + offset + i) - '0';
} else {
break;
}
@@ -143,32 +142,31 @@
}
// error is thrown if more than three digits are seen for the millisecond part
- if (charAccessor.getLength() > offset && charAccessor.getCharAt(offset) >= '0'
- && charAccessor.getCharAt(offset) <= '9') {
+ if (length > offset && timeString.charAt(start + offset) >= '0' && timeString.charAt(start + offset) <= '9') {
throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
}
}
if (length > offset) {
- timezone = parseTimezonePart(charAccessor, offset);
+ timezone = parseTimezonePart(timeString, start + offset);
}
return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
}
/**
- * Parse the given char sequence as a time string, and return the milliseconds represented by the time.
+ * Parse the given string as a time string, and parse the timezone field.
*
- * @param charAccessor
+ * @param timeString
+ * @param start
* @return
- * @throws Exception
+ * @throws HyracksDataException
*/
- public static <T> int parseTimezonePart(ICharSequenceAccessor<T> charAccessor, int offset)
- throws HyracksDataException {
+ public static <T> int parseTimezonePart(String timeString, int start) throws HyracksDataException {
int timezone = 0;
- if (charAccessor.getCharAt(offset) != 'Z') {
- if ((charAccessor.getCharAt(offset) != '+' && charAccessor.getCharAt(offset) != '-')) {
+ if (timeString.charAt(start) != 'Z') {
+ if ((timeString.charAt(start) != '+' && timeString.charAt(start) != '-')) {
throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
}
@@ -176,8 +174,8 @@
short timezoneMinute = 0;
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + 1 + i) >= '0' && charAccessor.getCharAt(offset + 1 + i) <= '9')) {
- timezoneHour = (short) (timezoneHour * 10 + charAccessor.getCharAt(offset + 1 + i) - '0');
+ if ((timeString.charAt(start + 1 + i) >= '0' && timeString.charAt(start + 1 + i) <= '9')) {
+ timezoneHour = (short) (timezoneHour * 10 + timeString.charAt(start + 1 + i) - '0');
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
}
@@ -188,13 +186,12 @@
throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
}
- int temp_offset = (charAccessor.getCharAt(offset + 3) == ':') ? 1 : 0;
+ int temp_offset = (timeString.charAt(start + 3) == ':') ? 1 : 0;
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + temp_offset + 3 + i) >= '0' && charAccessor.getCharAt(offset
- + temp_offset + 3 + i) <= '9')) {
- timezoneMinute = (short) (timezoneMinute * 10
- + charAccessor.getCharAt(offset + temp_offset + 3 + i) - '0');
+ if ((timeString.charAt(start + temp_offset + 3 + i) >= '0' && timeString.charAt(start + temp_offset + 3
+ + i) <= '9')) {
+ timezoneMinute = (short) (timezoneMinute * 10 + timeString.charAt(start + temp_offset + 3 + i) - '0');
} else {
throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
}
@@ -205,7 +202,333 @@
throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
}
- if (charAccessor.getCharAt(offset) == '-') {
+ if (timeString.charAt(start) == '-') {
+ timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
+ } else {
+ timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
+ }
+ }
+ return timezone;
+ }
+
+ /**
+ * Similar to {@link #parseTimePart(String, int, int)} but use a char array as input; although this is almost
+ * a copy-and-past code but it avoids object creation.
+ *
+ * @param timeString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static int parseTimePart(char[] timeString, int start, int length) throws HyracksDataException {
+
+ int offset = 0;
+
+ int hour = 0, min = 0, sec = 0, millis = 0;
+ int timezone = 0;
+
+ boolean isExtendedForm = false;
+ if (timeString[start + offset + 2] == ':') {
+ isExtendedForm = true;
+ }
+
+ if (isExtendedForm && (timeString[start + offset + 2] != ':' || timeString[start + offset + 5] != ':')) {
+ throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
+ }
+ // hour
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ hour = hour * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
+ }
+ }
+
+ if (hour < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.HOUR.ordinal()]
+ || hour > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.HOUR.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": hour " + hour);
+ }
+
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // minute
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ min = min * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
+ }
+ }
+
+ if (min < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]
+ || min > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": min " + min);
+ }
+
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // second
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ sec = sec * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
+ }
+ }
+
+ if (sec < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.SECOND.ordinal()]
+ || sec > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.SECOND.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": sec " + sec);
+ }
+
+ offset += 2;
+
+ if ((isExtendedForm && length > offset && timeString[start + offset] == '.')
+ || (!isExtendedForm && length > offset)) {
+
+ offset += (isExtendedForm) ? 1 : 0;
+ int i = 0;
+ for (; i < 3 && offset + i < length; i++) {
+ if (timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9') {
+ millis = millis * 10 + timeString[start + offset + i] - '0';
+ } else {
+ break;
+ }
+ }
+
+ offset += i;
+
+ for (; i < 3; i++) {
+ millis = millis * 10;
+ }
+
+ // error is thrown if more than three digits are seen for the millisecond part
+ if (length > offset && timeString[start + offset] >= '0' && timeString[start + offset] <= '9') {
+ throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
+ }
+ }
+
+ if (length > offset) {
+ timezone = parseTimezonePart(timeString, start + offset);
+ }
+
+ return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
+ }
+
+ /**
+ * Similar to {@link #parseTimezonePart(String, int)} but use a char array as input; although this is almost
+ * a copy-and-past code but it avoids object creation.
+ *
+ * @param timeString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static int parseTimezonePart(char[] timeString, int start) throws HyracksDataException {
+ int timezone = 0;
+
+ if (timeString[start] != 'Z') {
+ if ((timeString[start] != '+' && timeString[start] != '-')) {
+ throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
+ }
+
+ short timezoneHour = 0;
+ short timezoneMinute = 0;
+
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + 1 + i] >= '0' && timeString[start + 1 + i] <= '9')) {
+ timezoneHour = (short) (timezoneHour * 10 + timeString[start + 1 + i] - '0');
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
+ }
+ }
+
+ if (timezoneHour < GregorianCalendarSystem.TIMEZONE_HOUR_MIN
+ || timezoneHour > GregorianCalendarSystem.TIMEZONE_HOUR_MAX) {
+ throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
+ }
+
+ int temp_offset = (timeString[start + 3] == ':') ? 1 : 0;
+
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + temp_offset + 3 + i] >= '0' && timeString[start + temp_offset + 3 + i] <= '9')) {
+ timezoneMinute = (short) (timezoneMinute * 10 + timeString[start + temp_offset + 3 + i] - '0');
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
+ }
+ }
+
+ if (timezoneMinute < GregorianCalendarSystem.TIMEZONE_MIN_MIN
+ || timezoneMinute > GregorianCalendarSystem.TIMEZONE_MIN_MAX) {
+ throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
+ }
+
+ if (timeString[start] == '-') {
+ timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
+ } else {
+ timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
+ }
+ }
+ return timezone;
+ }
+
+ /**
+ * Similar to {@link #parseTimePart(String, int, int)} but use a byte array as input; although this is almost
+ * a copy-and-past code but it avoids object creation.
+ *
+ * @param timeString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static int parseTimePart(byte[] timeString, int start, int length) throws HyracksDataException {
+
+ int offset = 0;
+
+ int hour = 0, min = 0, sec = 0, millis = 0;
+ int timezone = 0;
+
+ boolean isExtendedForm = false;
+ if (timeString[start + offset + 2] == ':') {
+ isExtendedForm = true;
+ }
+
+ if (isExtendedForm && (timeString[start + offset + 2] != ':' || timeString[start + offset + 5] != ':')) {
+ throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
+ }
+ // hour
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ hour = hour * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
+ }
+ }
+
+ if (hour < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.HOUR.ordinal()]
+ || hour > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.HOUR.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": hour " + hour);
+ }
+
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // minute
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ min = min * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
+ }
+ }
+
+ if (min < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]
+ || min > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": min " + min);
+ }
+
+ offset += (isExtendedForm) ? 3 : 2;
+
+ // second
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+ sec = sec * 10 + timeString[start + offset + i] - '0';
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
+ }
+ }
+
+ if (sec < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.SECOND.ordinal()]
+ || sec > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.SECOND.ordinal()]) {
+ throw new HyracksDataException(timeErrorMessage + ": sec " + sec);
+ }
+
+ offset += 2;
+
+ if ((isExtendedForm && length > offset && timeString[start + offset] == '.')
+ || (!isExtendedForm && length > offset)) {
+
+ offset += (isExtendedForm) ? 1 : 0;
+ int i = 0;
+ for (; i < 3 && offset + i < length; i++) {
+ if (timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9') {
+ millis = millis * 10 + timeString[start + offset + i] - '0';
+ } else {
+ break;
+ }
+ }
+
+ offset += i;
+
+ for (; i < 3; i++) {
+ millis = millis * 10;
+ }
+
+ // error is thrown if more than three digits are seen for the millisecond part
+ if (length > offset && timeString[start + offset] >= '0' && timeString[start + offset] <= '9') {
+ throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
+ }
+ }
+
+ if (length > offset) {
+ timezone = parseTimezonePart(timeString, start + offset);
+ }
+
+ return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
+ }
+
+ /**
+ * Similar to {@link #parseTimezonePart(String, int)} but use a byte array as input; although this is almost
+ * a copy-and-past code but it avoids object creation.
+ *
+ * @param timeString
+ * @param start
+ * @param length
+ * @return
+ * @throws HyracksDataException
+ */
+ public static int parseTimezonePart(byte[] timeString, int start) throws HyracksDataException {
+ int timezone = 0;
+
+ if (timeString[start] != 'Z') {
+ if ((timeString[start] != '+' && timeString[start] != '-')) {
+ throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
+ }
+
+ short timezoneHour = 0;
+ short timezoneMinute = 0;
+
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + 1 + i] >= '0' && timeString[start + 1 + i] <= '9')) {
+ timezoneHour = (short) (timezoneHour * 10 + timeString[start + 1 + i] - '0');
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
+ }
+ }
+
+ if (timezoneHour < GregorianCalendarSystem.TIMEZONE_HOUR_MIN
+ || timezoneHour > GregorianCalendarSystem.TIMEZONE_HOUR_MAX) {
+ throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
+ }
+
+ int temp_offset = (timeString[start + 3] == ':') ? 1 : 0;
+
+ for (int i = 0; i < 2; i++) {
+ if ((timeString[start + temp_offset + 3 + i] >= '0' && timeString[start + temp_offset + 3 + i] <= '9')) {
+ timezoneMinute = (short) (timezoneMinute * 10 + timeString[start + temp_offset + 3 + i] - '0');
+ } else {
+ throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
+ }
+ }
+
+ if (timezoneMinute < GregorianCalendarSystem.TIMEZONE_MIN_MIN
+ || timezoneMinute > GregorianCalendarSystem.TIMEZONE_MIN_MAX) {
+ throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
+ }
+
+ if (timeString[start] == '-') {
timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
} else {
timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java
deleted file mode 100644
index 453c86f..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed 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 from
- *
- * 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.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class ByteArrayCharSequenceAccessor implements ICharSequenceAccessor<Byte[]> {
-
- private byte[] buf;
- private int offset;
- private int length;
-
- @Override
- public char getCharAt(int index) throws AsterixRuntimeException {
- if (index < 0 || index >= length) {
- throw new AsterixRuntimeException("Byte array char accessor is out of bound: " + index + ":" + length);
- }
- return (char) (buf[index + offset]);
- }
-
- /**
- * Reset the wrapped byte array.
- *
- * @param obj
- * The byte array to be wrapped
- * @param beginOffset
- * The offset of the string stored in the byte array.
- * @param offset
- * The offset of the substring of the string stored (offset from the beginOffset).
- */
- public void reset(byte[] obj, int offset, int length) {
- this.buf = obj;
- this.offset = offset;
- this.length = length;
- }
-
- @Override
- public int getLength() {
- return length;
- }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java
deleted file mode 100644
index 404f0ee..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed 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 from
- *
- * 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.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class CharArrayCharSequenceAccessor implements ICharSequenceAccessor<char[]> {
-
- private char[] buf;
- private int offset;
- private int length;
-
- @Override
- public char getCharAt(int index) throws AsterixRuntimeException {
- if (index < 0 || index >= length) {
- throw new AsterixRuntimeException("Byte array char accessor is out of bound: " + index + ":" + length);
- }
- return (char) (buf[index + offset]);
- }
-
- /**
- * Reset the wrapped byte array.
- *
- * @param obj
- * The byte array to be wrapped
- * @param beginOffset
- * The offset of the string stored in the byte array.
- * @param offset
- * The offset of the substring of the string stored (offset from the beginOffset).
- */
- public void reset(char[] obj, int offset, int length) {
- this.buf = obj;
- this.offset = offset;
- this.length = length;
- }
-
- @Override
- public int getLength() {
- return length;
- }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java
deleted file mode 100644
index d5a99a0..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed 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 from
- *
- * 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.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public interface ICharSequenceAccessor<T> {
-
- /**
- * Return the character in the wrapped char sequence at the given index.
- *
- * @param index
- * @return
- */
- public char getCharAt(int index) throws AsterixRuntimeException;
-
- /**
- * Get the length of the wrapped char sequence.
- *
- * @return
- */
- public int getLength();
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java
deleted file mode 100644
index 17e483a..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed 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 from
- *
- * 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.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class StringCharSequenceAccessor implements ICharSequenceAccessor<String> {
-
- private String string;
- private int offset;
- private int length;
-
- @Override
- public char getCharAt(int index) throws AsterixRuntimeException {
- if (index >= length) {
- throw new AsterixRuntimeException("String accessor is out of bound.");
- }
- return string.charAt(index + offset);
- }
-
- public void reset(String obj, int offset, int len) {
- this.string = obj;
- this.offset = offset;
- this.length = len;
- }
-
- @Override
- public int getLength() {
- return length;
- }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
index d5d703d..a1f9911 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
@@ -22,7 +22,6 @@
import edu.uci.ics.asterix.om.base.AMutableDate;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -73,8 +72,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -95,8 +92,8 @@
endOffset--;
}
- charAccessor.reset(serString, startOffset, endOffset - startOffset + 1);
- long chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor);
+ long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, startOffset,
+ endOffset - startOffset + 1);
short temp = 0;
if (chrononTimeInMs < 0
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
index f1565aa..83f4c8b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -72,7 +71,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -85,27 +83,22 @@
int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
- charAccessor.reset(serString, 3, stringLength);
-
// +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ short timeOffset = (short) ((serString[3] == '-') ? 1 : 0);
timeOffset += 8;
- if (charAccessor.getCharAt(timeOffset) != 'T') {
+ if (serString[3 + timeOffset] != 'T') {
timeOffset += 2;
- if (charAccessor.getCharAt(timeOffset) != 'T') {
+ if (serString[3 + timeOffset] != 'T') {
throw new AlgebricksException(errorMessage + ": missing T");
}
}
- charAccessor.reset(serString, 3, timeOffset);
+ long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, 3, timeOffset);
- long chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor);
-
- charAccessor.reset(serString, 3 + timeOffset + 1, stringLength - timeOffset - 1);
-
- chrononTimeInMs += ATimeParserFactory.parseTimePart(charAccessor);
+ chrononTimeInMs += ATimeParserFactory.parseTimePart(serString, 3 + timeOffset + 1,
+ stringLength - timeOffset - 1);
aDateTime.setValue(chrononTimeInMs);
datetimeSerde.serialize(aDateTime, out);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
index b2b3f4e..a84ae1d 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
@@ -21,7 +21,6 @@
import edu.uci.ics.asterix.om.base.AMutableDuration;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -43,8 +42,6 @@
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
- private final static ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
return new ADurationConstructorDescriptor();
@@ -85,9 +82,7 @@
int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
- charAccessor.reset(serString, 3, stringLength);
-
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory.parseDuration(serString, 3, stringLength, aDuration);
durationSerde.serialize(aDuration, out);
} else if (serString[0] == SER_NULL_TYPE_TAG) {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
index 3ac64f3..0414874 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.AMutableInterval;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -78,8 +77,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -100,17 +97,15 @@
+ (argOut0.getByteArray()[2] & 0xff << 0);
// start date
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
- long intervalStart = ADateParserFactory.parseDatePart(charAccessor)
- / GregorianCalendarSystem.CHRONON_OF_DAY;
+ long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ stringLength) / GregorianCalendarSystem.CHRONON_OF_DAY;
// end date
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- long intervalEnd = ADateParserFactory.parseDatePart(charAccessor)
- / GregorianCalendarSystem.CHRONON_OF_DAY;
+ long intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3,
+ stringLength) / GregorianCalendarSystem.CHRONON_OF_DAY;
if (intervalEnd < intervalStart) {
throw new AlgebricksException(
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
index 35d1a02..6b3e2b6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
@@ -24,7 +24,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -78,8 +77,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -99,43 +96,39 @@
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
// get offset for time part: +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ short timeOffset = (short) ((argOut0.getByteArray()[3] == '-') ? 1 : 0);
timeOffset += 8;
- if (charAccessor.getCharAt(timeOffset) != 'T') {
+ if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
timeOffset += 2;
- if (charAccessor.getCharAt(timeOffset) != 'T') {
+ if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
throw new AlgebricksException(errorMessage + ": missing T");
}
}
- charAccessor.reset(argOut0.getByteArray(), 3, timeOffset);
- long intervalStart = ADateParserFactory.parseDatePart(charAccessor);
- charAccessor.reset(argOut0.getByteArray(), 3 + timeOffset + 1, stringLength
- - timeOffset - 1);
- intervalStart += ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ timeOffset);
+ intervalStart += ATimeParserFactory.parseTimePart(argOut0.getByteArray(),
+ 3 + timeOffset + 1, stringLength - timeOffset - 1);
// end datetime
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
// get offset for time part: +1 if it is negative (-)
- timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ timeOffset = (short) ((argOut1.getByteArray()[3] == '-') ? 1 : 0);
timeOffset += 8;
- if (charAccessor.getCharAt(timeOffset) != 'T') {
+ if (argOut1.getByteArray()[3 + timeOffset] != 'T') {
timeOffset += 2;
- if (charAccessor.getCharAt(timeOffset) != 'T') {
+ if (argOut1.getByteArray()[3 + timeOffset] != 'T') {
throw new AlgebricksException(errorMessage + ": missing T");
}
}
- charAccessor.reset(argOut1.getByteArray(), 3, timeOffset);
- long intervalEnd = ADateParserFactory.parseDatePart(charAccessor);
- charAccessor.reset(argOut1.getByteArray(), 3 + timeOffset + 1, stringLength
- - timeOffset - 1);
- intervalEnd += ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3,
+ timeOffset);
+ intervalEnd += ATimeParserFactory.parseTimePart(argOut1.getByteArray(),
+ 3 + timeOffset + 1, stringLength - timeOffset - 1);
if (intervalEnd < intervalStart) {
throw new AlgebricksException(
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
index 73080c8..042a33b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
@@ -23,7 +23,6 @@
import edu.uci.ics.asterix.om.base.AMutableInterval;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -78,8 +77,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -99,8 +96,8 @@
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
- long intervalStart = ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
+ stringLength);
if (intervalStart < 0) {
intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
}
@@ -109,8 +106,8 @@
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- long intervalEnd = ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalEnd = ATimeParserFactory.parseTimePart(argOut1.getByteArray(), 3,
+ stringLength);
if (intervalEnd < 0) {
intervalEnd += GregorianCalendarSystem.CHRONON_OF_DAY;
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
index 6429daa..d5a0db9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
@@ -25,7 +25,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -82,8 +81,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -104,15 +101,15 @@
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
- long intervalStart = ADateParserFactory.parseDatePart(charAccessor);
+ long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ stringLength);
// duration
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory
+ .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
long intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
aDuration.getMonths(), aDuration.getMilliseconds());
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
index 7366f1c..d821fc3 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
@@ -26,7 +26,6 @@
import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -82,8 +81,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -104,31 +101,29 @@
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
// get offset for time part: +1 if it is negative (-)
- short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+ short timeOffset = (short) ((argOut0.getByteArray()[3] == '-') ? 1 : 0);
timeOffset += 8;
- if (charAccessor.getCharAt(timeOffset) != 'T') {
+ if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
timeOffset += 2;
- if (charAccessor.getCharAt(timeOffset) != 'T') {
+ if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
throw new AlgebricksException(errorMessage + ": missing T");
}
}
- charAccessor.reset(argOut0.getByteArray(), 3, timeOffset);
- long intervalStart = ADateParserFactory.parseDatePart(charAccessor);
- charAccessor.reset(argOut0.getByteArray(), 3 + timeOffset + 1, stringLength
- - timeOffset - 1);
- intervalStart += ATimeParserFactory.parseTimePart(charAccessor);
+ long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ timeOffset);
+ intervalStart += ATimeParserFactory.parseTimePart(argOut0.getByteArray(),
+ 3 + timeOffset + 1, stringLength - timeOffset - 1);
// duration
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory
+ .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
long intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
aDuration.getMonths(), aDuration.getMilliseconds());
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
index e576fef..8135598 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
@@ -25,7 +25,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -82,8 +81,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -104,8 +101,8 @@
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
- int intervalStart = ATimeParserFactory.parseTimePart(charAccessor);
+ int intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
+ stringLength);
if (intervalStart < 0) {
intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -116,8 +113,8 @@
stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
- ADurationParserFactory.parseDuration(charAccessor, aDuration);
+ ADurationParserFactory
+ .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
if (aDuration.getMonths() != 0) {
throw new AlgebricksException("Cannot add a year-month duration to a time value.");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
index caff78b..f2ad400 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
@@ -22,7 +22,6 @@
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.ATime;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -73,8 +72,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -86,8 +83,7 @@
int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
- charAccessor.reset(serString, 3, stringLength);
- int chrononTimeInMs = ATimeParserFactory.parseTimePart(charAccessor);
+ int chrononTimeInMs = ATimeParserFactory.parseTimePart(serString, 3, stringLength);
if (chrononTimeInMs < 0) {
chrononTimeInMs += GregorianCalendarSystem.CHRONON_OF_DAY;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
index fb01e97..275bf47 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
@@ -21,7 +21,6 @@
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -81,8 +80,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
@Override
@@ -114,9 +111,7 @@
int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-
- int timezone = ATimeParserFactory.parseTimezonePart(charAccessor, 0);
+ int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(), 3);
if (!calInstance.validateTimeZone(timezone)) {
throw new AlgebricksException("Wrong format for a time zone string!");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
index 1323664..3f40c5c 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
@@ -21,7 +21,6 @@
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -81,8 +80,6 @@
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
- private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
@Override
@@ -114,9 +111,7 @@
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-
- int timezone = ATimeParserFactory.parseTimezonePart(charAccessor, 0);
+ int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(), 3);
if (!calInstance.validateTimeZone(timezone)) {
throw new AlgebricksException("Wrong format for a time zone string!");