fixed importing temporal data to use construction-notation.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_temporal_functionality@1040 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/data/temporal/temporalData.json b/asterix-app/data/temporal/temporalData.json
index b866a51..520fd4b 100644
--- a/asterix-app/data/temporal/temporalData.json
+++ b/asterix-app/data/temporal/temporalData.json
@@ -1,3 +1,3 @@
-{"id": "001", "dateField": -2012-12-12, "dateFieldPlus": 0990-01-01, "timeField": 23:49:12.39Z, "timeFieldPlus": 03:23:12.2, "datetimeField": 2012-12-12T00:00:00.001, "datetimeFieldPlus": -00130810T221015398, "durationField": P20Y19DT3H74M23.34S, "durationFieldPlus": -P2MT4M300.68S, "intervalField": I(2012-12-12T00:00:00.001,20130810T221015398) }
-{"id": "002", "datetimeField": 19201220T232918478 }
-{"id": "003", "intervalPlus": I(19:23:32.328Z,23:20:20) }
\ No newline at end of file
+{"id": "001", "dateField": date("-2012-12-12"), "dateFieldPlus": date("0990-01-01"), "timeField": time("23:49:12.39Z"), "timeFieldPlus": time("03:23:12.2"), "datetimeField": datetime("2012-12-12T00:00:00.001"), "datetimeFieldPlus": datetime("-00130810T221015398"), "durationField": duration("P20Y19DT3H74M23.34S"), "durationFieldPlus": duration("-P2MT4M300.68S"), "intervalField": dtinterval("2012-12-12T00:00:00.001,20130810T221015398") }
+{"id": "002", "datetimeField": datetime("19201220T232918478") }
+{"id": "003", "intervalPlus": tinterval("19:23:32.328Z,23:20:20") }
\ No newline at end of file
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 7c87dfa..ffcf5ee 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
@@ -17,6 +17,7 @@
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
+import java.util.regex.Pattern;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.AInterval;
@@ -42,6 +43,8 @@
private static final String errorMessage = "This can not be an instance of interval";
+ private static final Pattern COMMA_PATTERN = Pattern.compile(",");
+
private AIntervalSerializerDeserializer() {
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmSchemafullRecordParserFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmSchemafullRecordParserFactory.java
index 3093c98..f343660 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmSchemafullRecordParserFactory.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/AdmSchemafullRecordParserFactory.java
@@ -73,6 +73,12 @@
protected ARecordType recType;
+ private enum IntervalType {
+ DATE_INTERVAL,
+ TIME_INTERVAL,
+ DATETIME_INTERVAL
+ }
+
public AdmSchemafullRecordParserFactory(ARecordType recType) {
this.recType = recType;
}
@@ -327,16 +333,16 @@
parseConstructor(ATypeTag.INTERVAL, objectType, out);
break;
}
- case AdmLexerConstants.TIME_INTERVAL_LITERAL: {
- parseTimeInterval(token.image.substring(2, token.image.length() - 1), out);
+ case AdmLexerConstants.TIME_INTERVAL_CONS: {
+ parseIntervalConstructor(objectType, out, IntervalType.TIME_INTERVAL);
break;
}
- case AdmLexerConstants.DATE_INTERVAL_LITERAL: {
- parseDateInterval(token.image.substring(2, token.image.length() - 1), out);
+ case AdmLexerConstants.DATE_INTERVAL_CONS: {
+ parseIntervalConstructor(objectType, out, IntervalType.DATE_INTERVAL);
break;
}
- case AdmLexerConstants.DATETIME_INTERVAL_LITERAL: {
- parseDatetimeInterval(token.image.substring(2, token.image.length() - 1), out);
+ case AdmLexerConstants.DATETIME_INTERVAL_CONS: {
+ parseIntervalConstructor(objectType, out, IntervalType.DATETIME_INTERVAL);
break;
}
case AdmLexerConstants.POINT_CONS: {
@@ -398,6 +404,35 @@
}
}
+ private void parseIntervalConstructor(IAType objectType, DataOutput out, IntervalType intervalType)
+ throws AsterixException {
+ try {
+ Token token = admLexer.next();
+ if (token.kind == AdmLexerConstants.CONSTRUCTOR_OPEN) {
+ token = admLexer.next();
+ if (token.kind == AdmLexerConstants.STRING_LITERAL) {
+ switch (intervalType) {
+ case DATE_INTERVAL:
+ parseDateInterval(token.image.substring(1, token.image.length() - 1), out);
+ break;
+ case TIME_INTERVAL:
+ parseTimeInterval(token.image.substring(1, token.image.length() - 1), out);
+ break;
+ case DATETIME_INTERVAL:
+ parseDatetimeInterval(token.image.substring(1, token.image.length() - 1), out);
+ break;
+ }
+ token = admLexer.next();
+ if (token.kind == AdmLexerConstants.CONSTRUCTOR_CLOSE)
+ return;
+ }
+ }
+ } catch (Exception e) {
+ throw new AsterixException(e);
+ }
+ throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
+ }
+
private void parseConstructor(ATypeTag typeTag, IAType objectType, DataOutput out) throws AsterixException {
try {
Token token = admLexer.next();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/NtDelimitedDataTupleParserFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/NtDelimitedDataTupleParserFactory.java
index cfe94ef..3cdf8b9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/NtDelimitedDataTupleParserFactory.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/NtDelimitedDataTupleParserFactory.java
@@ -288,6 +288,7 @@
state = State.CR;
return true;
}
+ // FIXME incorrect EOF check for temporal delimited file importing
++p;
}
}
diff --git a/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj b/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj
index b52f346..d94033d 100644
--- a/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj
+++ b/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj
@@ -202,19 +202,20 @@
<DEFAULT>
TOKEN :
-{
<DATE_INTERVAL_LITERAL : ("I") "(" <DATE_LITERAL> "," <DATE_LITERAL> ")" >
+{
+ <TIME_INTERVAL_CONS : ("tinterval")>
}
<DEFAULT>
TOKEN :
{
- <TIME_INTERVAL_LITERAL : ("I") "(" <TIME_LITERAL> "," <TIME_LITERAL> ")" >
+ <DATE_INTERVAL_CONS : ("dinterval")>
}
<DEFAULT>
TOKEN :
{
- <DATETIME_INTERVAL_LITERAL : ("I") "(" <DATETIME_LITERAL> "," <DATETIME_LITERAL> ")" >
+ <DATETIME_INTERVAL_CONS : ("dtinterval")>
}
<DEFAULT>