Addressing the comments (1, 2 and 3) on r543 from Zach.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_temporal_fixes@560 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADatePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADatePrinter.java
index cd2b8c56..24aa144 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADatePrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADatePrinter.java
@@ -10,11 +10,10 @@
public class ADatePrinter implements IPrinter {
private static final long serialVersionUID = 1L;
-
private static long CHRONON_OF_DAY = 24 * 60 * 60 * 1000;
-
public static final ADatePrinter INSTANCE = new ADatePrinter();
-
+ private static final GregorianCalendarSystem gCalInstance = GregorianCalendarSystem.getInstance();
+
@Override
public void init() {
@@ -24,14 +23,12 @@
public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
long chrononTime = AInt32SerializerDeserializer.getInt(b, s + 1) * CHRONON_OF_DAY;
- GregorianCalendarSystem calendar = GregorianCalendarSystem.getInstance();
-
- int year = calendar.getYear(chrononTime);
- int month = calendar.getMonthOfYear(chrononTime, year);
+ int year = gCalInstance.getYear(chrononTime);
+ int month = gCalInstance.getMonthOfYear(chrononTime, year);
ps.print("date(\"");
ps.append(String.format(year < 0 ? "%05d" : "%04d", year)).append("-").append(String.format("%02d", month))
- .append("-").append(String.format("%02d", calendar.getDayOfMonthYear(chrononTime, year, month)));
+ .append("-").append(String.format("%02d", gCalInstance.getDayOfMonthYear(chrononTime, year, month)));
ps.print("\")");
}
}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADateTimePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADateTimePrinter.java
index fdd6b18..d856a20 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADateTimePrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADateTimePrinter.java
@@ -11,6 +11,7 @@
private static final long serialVersionUID = 1L;
public static final ADateTimePrinter INSTANCE = new ADateTimePrinter();
+ private static final GregorianCalendarSystem gCalInstance = GregorianCalendarSystem.getInstance();
@Override
public void init() {
@@ -21,18 +22,16 @@
public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
long chrononTime = AInt64SerializerDeserializer.getLong(b, s + 1);
- GregorianCalendarSystem calendar = GregorianCalendarSystem.getInstance();
-
- int year = calendar.getYear(chrononTime);
- int month = calendar.getMonthOfYear(chrononTime, year);
+ int year = gCalInstance.getYear(chrononTime);
+ int month = gCalInstance.getMonthOfYear(chrononTime, year);
ps.print("datetime(\"");
ps.append(String.format(year < 0 ? "%05d" : "%04d", year)).append("-").append(String.format("%02d", month))
- .append("-").append(String.format("%02d", calendar.getDayOfMonthYear(chrononTime, year, month)))
- .append("T").append(String.format("%02d", calendar.getHourOfDay(chrononTime))).append(":")
- .append(String.format("%02d", calendar.getMinOfHour(chrononTime))).append(":")
- .append(String.format("%02d", calendar.getSecOfMin(chrononTime))).append(".")
- .append(String.format("%03d", calendar.getMillisOfSec(chrononTime))).append("Z");
+ .append("-").append(String.format("%02d", gCalInstance.getDayOfMonthYear(chrononTime, year, month)))
+ .append("T").append(String.format("%02d", gCalInstance.getHourOfDay(chrononTime))).append(":")
+ .append(String.format("%02d", gCalInstance.getMinOfHour(chrononTime))).append(":")
+ .append(String.format("%02d", gCalInstance.getSecOfMin(chrononTime))).append(".")
+ .append(String.format("%03d", gCalInstance.getMillisOfSec(chrononTime))).append("Z");
ps.print("\")");
}
}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADurationPrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADurationPrinter.java
index 837c3db..a59b9ac 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADurationPrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ADurationPrinter.java
@@ -60,8 +60,9 @@
WriteValueTools.writeInt(day, ps);
ps.print("D");
}
- if (hour != 0 || minute != 0 || second != 0 || millisecond != 0)
+ if (hour != 0 || minute != 0 || second != 0 || millisecond != 0) {
ps.print("T");
+ }
if (hour != 0) {
WriteValueTools.writeInt(hour, ps);
ps.print("H");
@@ -70,14 +71,16 @@
WriteValueTools.writeInt(minute, ps);
ps.print("M");
}
- if (second != 0 || millisecond != 0)
+ if (second != 0 || millisecond != 0) {
WriteValueTools.writeInt(second, ps);
+ }
if (millisecond > 0) {
ps.print(".");
WriteValueTools.writeInt(millisecond, ps);
}
- if (second != 0 || millisecond != 0)
+ if (second != 0 || millisecond != 0) {
ps.print("S");
+ }
ps.print("\")");
} catch (IOException e) {
throw new AlgebricksException(e);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ATimePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ATimePrinter.java
index bb11ae1..72a6e37 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ATimePrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ATimePrinter.java
@@ -11,7 +11,8 @@
private static final long serialVersionUID = 1L;
public static final ATimePrinter INSTANCE = new ATimePrinter();
-
+ private static final GregorianCalendarSystem gCalInstance = GregorianCalendarSystem.getInstance();
+
@Override
public void init() {
@@ -20,13 +21,12 @@
@Override
public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
int time = AInt32SerializerDeserializer.getInt(b, s + 1);
- GregorianCalendarSystem calendar = GregorianCalendarSystem.getInstance();
+
ps.print("time(\"");
-
- ps.append(String.format("%02d", calendar.getHourOfDay(time))).append(":")
- .append(String.format("%02d", calendar.getMinOfHour(time))).append(":")
- .append(String.format("%02d", calendar.getSecOfMin(time))).append(".")
- .append(String.format("%03d", calendar.getMillisOfSec(time))).append("Z");
+ ps.append(String.format("%02d", gCalInstance.getHourOfDay(time))).append(":")
+ .append(String.format("%02d", gCalInstance.getMinOfHour(time))).append(":")
+ .append(String.format("%02d", gCalInstance.getSecOfMin(time))).append(".")
+ .append(String.format("%03d", gCalInstance.getMillisOfSec(time))).append("Z");
ps.print("\")");
}
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 64d8262..1549f14 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
@@ -53,12 +53,13 @@
charAccessor.reset(date, 0);
chrononTimeInMs = ADateAndTimeParser.parseDatePart(charAccessor, true);
} catch (Exception e) {
- throw new HyracksDataException(e.getMessage());
+ throw new HyracksDataException(e);
}
short temp = 0;
- if (chrononTimeInMs < 0 && chrononTimeInMs % GregorianCalendarSystem.CHRONON_OF_DAY != 0)
+ if (chrononTimeInMs < 0 && chrononTimeInMs % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
temp = 1;
+ }
aDate.setValue((int) (chrononTimeInMs / GregorianCalendarSystem.CHRONON_OF_DAY) - temp);
dateSerde.serialize(aDate, out);
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 cf92eaa..b6af9ba 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
@@ -57,8 +57,9 @@
// +1 if it is negative (-)
short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
- if (charAccessor.getCharAt(timeOffset + 10) != 'T' && charAccessor.getCharAt(timeOffset + 8) != 'T')
+ if (charAccessor.getCharAt(timeOffset + 10) != 'T' && charAccessor.getCharAt(timeOffset + 8) != 'T') {
throw new AlgebricksException(errorMessage + ": missing T");
+ }
// if extended form 11, else 9
timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11) : (short) (9);
@@ -69,7 +70,7 @@
chrononTimeInMs += ADateAndTimeParser.parseTimePart(charAccessor);
} catch (Exception e) {
- throw new HyracksDataException(e.getMessage());
+ throw new HyracksDataException(e);
}
aDateTime.setValue(chrononTimeInMs);
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 77d6f28..c3333f0 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
@@ -53,7 +53,7 @@
durationSerde.serialize(aDuration, out);
} catch (Exception e) {
- throw new HyracksDataException(e.getMessage());
+ 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 7fe99c3..8860f2a 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
@@ -55,7 +55,7 @@
charAccessor.reset(time, 0);
chrononTimeInMs = ADateAndTimeParser.parseTimePart(charAccessor);
} catch (Exception e) {
- throw new HyracksDataException(e.getMessage());
+ throw new HyracksDataException(e);
}
aTime.setValue(chrononTimeInMs);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADate.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADate.java
index 06d2a96..347b55b 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADate.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADate.java
@@ -59,7 +59,8 @@
StringBuilder sbder = new StringBuilder();
sbder.append("ADate: { ");
GregorianCalendarSystem.getInstance().getExtendStringRepWithTimezoneUntilField(
- chrononTimeInDay * CHRONON_OF_DAY, 0, sbder, GregorianCalendarSystem.Fields.YEAR, GregorianCalendarSystem.Fields.DAY);
+ chrononTimeInDay * CHRONON_OF_DAY, 0, sbder, GregorianCalendarSystem.Fields.YEAR,
+ GregorianCalendarSystem.Fields.DAY);
sbder.append(" }");
return sbder.toString();
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADuration.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADuration.java
index 1f9044b..a9e730f 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADuration.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/ADuration.java
@@ -89,7 +89,8 @@
public String toString() {
StringBuilder sbder = new StringBuilder();
sbder.append("ADuration: {");
- GregorianCalendarSystem.getInstance().getDurationExtendStringRepWithTimezoneUntilField(chrononInMillisecond, chrononInMonth, sbder);
+ GregorianCalendarSystem.getInstance().getDurationExtendStringRepWithTimezoneUntilField(chrononInMillisecond,
+ chrononInMonth, sbder);
sbder.append(" }");
return sbder.toString();
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateAndTimeParser.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateAndTimeParser.java
index 28eb898..d2cd356 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateAndTimeParser.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateAndTimeParser.java
@@ -34,12 +34,15 @@
}
if ((isDateOnly) && charAccessor.getCharAt(offset + 4) == '-' || (!isDateOnly)
- && charAccessor.getCharAt(offset + 13) == ':')
+ && charAccessor.getCharAt(offset + 13) == ':') {
isExtendedForm = true;
+ }
- if (isExtendedForm)
- if (charAccessor.getCharAt(offset + 4) != '-' || charAccessor.getCharAt(offset + 7) != '-')
+ if (isExtendedForm) {
+ if (charAccessor.getCharAt(offset + 4) != '-' || charAccessor.getCharAt(offset + 7) != '-') {
throw new Exception(dateErrorMessage);
+ }
+ }
// year
for (int i = 0; i < 4; i++) {
@@ -88,8 +91,9 @@
offset += 2;
- if (!positive)
+ if (!positive) {
year *= -1;
+ }
if (isDateOnly && length > offset) {
throw new Exception(dateErrorMessage);
@@ -117,9 +121,9 @@
isExtendedForm = true;
}
- if (isExtendedForm && (charAccessor.getCharAt(offset + 2) != ':' || charAccessor.getCharAt(offset + 5) != ':'))
+ if (isExtendedForm && (charAccessor.getCharAt(offset + 2) != ':' || charAccessor.getCharAt(offset + 5) != ':')) {
throw new Exception(timeErrorMessage);
-
+ }
// hour
for (int i = 0; i < 2; i++) {
if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
@@ -196,18 +200,19 @@
if (length > offset) {
if (charAccessor.getCharAt(offset) != 'Z') {
if ((charAccessor.getCharAt(offset) != '+' && charAccessor.getCharAt(offset) != '-')
- || (isExtendedForm && charAccessor.getCharAt(offset + 3) != ':'))
+ || (isExtendedForm && charAccessor.getCharAt(offset + 3) != ':')) {
throw new Exception(timeErrorMessage);
+ }
short timezoneHour = 0;
short timezoneMinute = 0;
for (int i = 0; i < 2; i++) {
- if ((charAccessor.getCharAt(offset + 1 + i) >= '0' && charAccessor.getCharAt(offset + 1 + i) <= '9'))
+ if ((charAccessor.getCharAt(offset + 1 + i) >= '0' && charAccessor.getCharAt(offset + 1 + i) <= '9')) {
timezoneHour = (short) (timezoneHour * 10 + charAccessor.getCharAt(offset + 1 + i) - '0');
- else
+ } else {
throw new Exception(timeErrorMessage);
-
+ }
}
if (timezoneHour < GregorianCalendarSystem.TIMEZONE_HOUR_MIN
@@ -219,11 +224,12 @@
for (int i = 0; i < 2; i++) {
if ((charAccessor.getCharAt(offset + temp_offset + 3 + i) >= '0' && charAccessor.getCharAt(offset
- + temp_offset + 3 + i) <= '9'))
+ + temp_offset + 3 + i) <= '9')) {
timezoneMinute = (short) (timezoneMinute * 10
+ charAccessor.getCharAt(offset + temp_offset + 3 + i) - '0');
- else
+ } else {
throw new Exception(timeErrorMessage);
+ }
}
if (timezoneMinute < GregorianCalendarSystem.TIMEZONE_MIN_MIN
@@ -231,11 +237,11 @@
throw new Exception(timeErrorMessage + ": time zone minute " + timezoneMinute);
}
- if (charAccessor.getCharAt(offset) == '-')
+ if (charAccessor.getCharAt(offset) == '-') {
timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
- else
+ } else {
timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
-
+ }
}
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParser.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParser.java
index c6bed37..ef4b2db 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParser.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParser.java
@@ -30,78 +30,90 @@
positive = false;
}
- if (charAccessor.getCharAt(offset++) != 'P')
+ if (charAccessor.getCharAt(offset++) != 'P') {
throw new Exception(errorMessage);
+ }
for (; offset < charAccessor.getLength(); offset++) {
- if (charAccessor.getCharAt(offset) >= '0' && charAccessor.getCharAt(offset) <= '9')
+ if (charAccessor.getCharAt(offset) >= '0' && charAccessor.getCharAt(offset) <= '9') {
// accumulate the digit fields
value = value * 10 + charAccessor.getCharAt(offset) - '0';
- else {
+ } else {
switch (charAccessor.getCharAt(offset)) {
case 'Y':
if (state.compareTo(State.YEAR) < 0) {
year = value;
state = State.YEAR;
- } else
+ } else {
throw new Exception(errorMessage);
+ }
break;
case 'M':
if (state.compareTo(State.TIME) < 0) {
if (state.compareTo(State.MONTH) < 0) {
month = value;
state = State.MONTH;
- } else
+ } else {
throw new Exception(errorMessage);
+ }
} else if (state.compareTo(State.MIN) < 0) {
minute = value;
state = State.MIN;
- } else
+ } else {
throw new Exception(errorMessage);
+ }
break;
case 'D':
if (state.compareTo(State.DAY) < 0) {
day = value;
state = State.DAY;
- } else
+ } else {
throw new Exception(errorMessage);
+ }
break;
case 'T':
if (state.compareTo(State.TIME) < 0) {
state = State.TIME;
- } else
+ } else {
throw new Exception(errorMessage);
+ }
break;
case 'H':
if (state.compareTo(State.HOUR) < 0) {
hour = value;
state = State.HOUR;
- } else
+ } else {
throw new Exception(errorMessage);
+ }
break;
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') {
- if (i < 4)
+ if (charAccessor.getCharAt(offset + i) >= '0'
+ && charAccessor.getCharAt(offset + i) <= '9') {
+ if (i < 4) {
millisecond = millisecond * 10 + (charAccessor.getCharAt(offset + i) - '0');
- else
+ } else {
throw new Exception(errorMessage);
- } else
+ }
+ } else {
break;
+ }
}
offset += i;
state = State.MILLISEC;
- } else
+ } else {
throw new Exception(errorMessage);
+ }
case 'S':
if (state.compareTo(State.SEC) < 0) {
second = value;
state = State.SEC;
- } else
+ } else {
throw new Exception(errorMessage);
+ }
break;
default:
throw new Exception(errorMessage);
@@ -111,12 +123,14 @@
}
}
- if (state.compareTo(State.TIME) == 0)
+ if (state.compareTo(State.TIME) == 0) {
throw new Exception(errorMessage);
+ }
short temp = 1;
- if (!positive)
+ if (!positive) {
temp = -1;
+ }
aDuration.setValue(temp * (year * 12 + month), temp
* (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
index f0ca414..149a1d2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
@@ -109,30 +109,40 @@
*/
public boolean validate(int year, int month, int day, int hour, int min, int sec, int millis) {
// Check whether each field is within the value domain
- if (year < FIELD_MINS[0] || year > FIELD_MAXS[0])
+ if (year < FIELD_MINS[0] || year > FIELD_MAXS[0]) {
return false;
- if (month < FIELD_MINS[1] || month > FIELD_MAXS[1])
+ }
+ if (month < FIELD_MINS[1] || month > FIELD_MAXS[1]) {
return false;
- if (day < FIELD_MINS[2] || day > FIELD_MAXS[2])
+ }
+ if (day < FIELD_MINS[2] || day > FIELD_MAXS[2]) {
return false;
- if (hour < FIELD_MINS[3] || hour > FIELD_MAXS[3])
+ }
+ if (hour < FIELD_MINS[3] || hour > FIELD_MAXS[3]) {
return false;
- if (min < FIELD_MINS[4] || min > FIELD_MAXS[4])
+ }
+ if (min < FIELD_MINS[4] || min > FIELD_MAXS[4]) {
return false;
- if (sec < FIELD_MINS[5] || sec > FIELD_MAXS[5])
+ }
+ if (sec < FIELD_MINS[5] || sec > FIELD_MAXS[5]) {
return false;
- if (millis < FIELD_MINS[6] || millis > FIELD_MAXS[6])
+ }
+ if (millis < FIELD_MINS[6] || millis > FIELD_MAXS[6]) {
return false;
+ }
// Check whether leap month.
- if (month == 2)
+ if (month == 2) {
if (isLeapYear(year)) {
- if (month > DAYS_OF_MONTH_LEAP[1])
+ if (month > DAYS_OF_MONTH_LEAP[1]) {
return false;
+ }
} else {
- if (month > DAYS_OF_MONTH_ORDI[1])
+ if (month > DAYS_OF_MONTH_ORDI[1]) {
return false;
+ }
}
+ }
return true;
}
@@ -253,36 +263,41 @@
return;
}
case MONTH:
- if (startField != Fields.MONTH)
+ if (startField != Fields.MONTH) {
sbder.append("-");
+ }
sbder.append(String.format("%02d", month));
if (untilField == Fields.MONTH) {
return;
}
case DAY:
- if (startField != Fields.DAY)
+ if (startField != Fields.DAY) {
sbder.append("-");
+ }
sbder.append(String.format("%02d", getDayOfMonthYear(chrononTime, year, month)));
if (untilField == Fields.DAY) {
break;
}
case HOUR:
- if (startField != Fields.HOUR)
+ if (startField != Fields.HOUR) {
sbder.append("T");
+ }
sbder.append(String.format("%02d", getHourOfDay(chrononTime)));
if (untilField == Fields.HOUR) {
break;
}
case MINUTE:
- if (startField != Fields.MINUTE)
+ if (startField != Fields.MINUTE) {
sbder.append(":");
+ }
sbder.append(String.format("%02d", getMinOfHour(chrononTime)));
if (untilField == Fields.MINUTE) {
break;
}
case SECOND:
- if (startField != Fields.SECOND)
+ if (startField != Fields.SECOND) {
sbder.append(":");
+ }
sbder.append(String.format("%02d", getSecOfMin(chrononTime)));
// add millisecond as the precision fields of a second
sbder.append(".").append(String.format("%03d", getMillisOfSec(chrononTime)));
@@ -395,8 +410,9 @@
sbder.append((hour != 0) ? hour + "H" : "");
sbder.append((minute != 0) ? minute + "M" : "");
sbder.append((second != 0 || millisecond != 0) ? second : "");
- if (millisecond > 0)
+ if (millisecond > 0) {
sbder.append("." + millisecond);
+ }
sbder.append((second != 0 || millisecond != 0) ? "S" : "");
}
@@ -506,38 +522,43 @@
// There are 86400000 milliseconds per day, but divided by 1024 is
// 84375. There are 84375 (128/125)seconds per day.
- int temp = 0;
+ int leap = 0;
- if (isLeapYear(year) == true)
- temp = 1;
+ if (isLeapYear(year) == true) {
+ leap = 1; //Adding one day for the leap years
+ }
- if (i < (181 + temp) * 84375 /*Days before the end of June*/)
- if (i < (90 + temp) * 84375 /*Days before the end of March*/)
- if (i < 31 * 84375 /*Days before the end of January*/)
+ if (i < (181 + leap) * 84375) { /*Days before the end of June*/
+ if (i < (90 + leap) * 84375) { /*Days before the end of March*/
+ if (i < 31 * 84375) { /*Days before the end of January*/
return 1;
- else if (i < (59 + temp) * 84375 /*Days before the end of February of leap year*/)
+ } else if (i < (59 + leap) * 84375) { /*Days before the end of February*/
return 2;
- else
+ } else {
return 3;
- else if (i < (120 + temp) * 84375 /*Days before the end of April*/)
+ }
+ } else if (i < (120 + leap) * 84375) { /*Days before the end of April*/
return 4;
- else if (i < (151 + temp) * 84375 /*Days before the end of May*/)
+ } else if (i < (151 + leap) * 84375) { /*Days before the end of May*/
return 5;
- else
+ } else {
return 6;
- else if (i < (273 + temp) * 84375 /*Days before the end of September*/)
- if (i < (212 + temp) * 84375 /*Days before the end of July*/)
+ }
+ } else if (i < (273 + leap) * 84375) { /*Days before the end of September*/
+ if (i < (212 + leap) * 84375) { /*Days before the end of July*/
return 7;
- else if (i < (243 + temp) * 84375 /*Days before the end of August*/)
+ } else if (i < (243 + leap) * 84375) { /*Days before the end of August*/
return 8;
- else
+ } else {
return 9;
- else if (i < (304 + temp) * 84375 /*Days before the end of October*/)
+ }
+ } else if (i < (304 + leap) * 84375) { /*Days before the end of October*/
return 10;
- else if (i < (334 + temp) * 84375 /*Days before the end of November*/)
+ } else if (i < (334 + leap) * 84375) { /*Days before the end of November*/
return 11;
- else
+ } else {
return 12;
+ }
}
/**
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 8fd5698..5a7dc14 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
@@ -76,21 +76,22 @@
short temp = 0;
if (chrononTimeInMs < 0
- && chrononTimeInMs % GregorianCalendarSystem.CHRONON_OF_DAY != 0)
+ && chrononTimeInMs % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
temp = 1;
+ }
aDate.setValue((int) (chrononTimeInMs / GregorianCalendarSystem.CHRONON_OF_DAY) - temp);
dateSerde.serialize(aDate, out);
- } else if (serString[0] == SER_NULL_TYPE_TAG)
+ } else if (serString[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- else
+ } else {
throw new AlgebricksException(errorMessage);
-
+ }
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
} catch (Exception e2) {
- throw new AlgebricksException(e2.getMessage());
+ throw new AlgebricksException(e2);
}
}
};
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 8a58e36..73f2c02 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
@@ -75,8 +75,9 @@
short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
if (charAccessor.getCharAt(timeOffset + 10) != 'T'
- && charAccessor.getCharAt(timeOffset + 8) != 'T')
+ && charAccessor.getCharAt(timeOffset + 8) != 'T') {
throw new AlgebricksException(errorMessage + ": missing T");
+ }
// if extended form 11, else 9
timeOffset += (charAccessor.getCharAt(timeOffset + 13) == ':') ? (short) (11)
@@ -90,14 +91,15 @@
aDateTime.setValue(chrononTimeInMs);
datetimeSerde.serialize(aDateTime, out);
- } else if (serString[0] == SER_NULL_TYPE_TAG)
+ } else if (serString[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- else
+ } else {
throw new AlgebricksException(errorMessage);
+ }
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
- } catch (Exception e) {
- throw new AlgebricksException(e.getMessage());
+ } catch (Exception e2) {
+ throw new AlgebricksException(e2);
}
}
};
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 811bcee..8478775 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
@@ -75,13 +75,13 @@
ADurationParser.parse(charAccessor, aDuration);
durationSerde.serialize(aDuration, out);
- } else if (serString[0] == SER_NULL_TYPE_TAG)
+ } else if (serString[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- else
+ } else {
throw new AlgebricksException(errorMessage);
-
- } catch (Exception e) {
- throw new AlgebricksException(e.getMessage());
+ }
+ } catch (Exception e1) {
+ throw new AlgebricksException(e1);
}
}
};
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 35635f7..d4c4683 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
@@ -74,14 +74,15 @@
aTime.setValue(chrononTimeInMs);
timeSerde.serialize(aTime, out);
- } else if (serString[0] == SER_NULL_TYPE_TAG)
+ } else if (serString[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- else
+ } else {
throw new AlgebricksException(errorMessage);
+ }
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
- } catch (Exception e) {
- throw new AlgebricksException(e.getMessage());
+ } catch (Exception e2) {
+ throw new AlgebricksException(e2);
}
}
};