exception wrapping only in the public methods
inline resulting single-line methods
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
index 848a124..1d7429b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
@@ -68,7 +68,7 @@
private int nullableFieldId = 0;
private ArrayBackedValueStorage castBuffer = new ArrayBackedValueStorage();
-
+
private Queue<ArrayBackedValueStorage> baaosPool = new ArrayDeque<ArrayBackedValueStorage>();
private Queue<IARecordBuilder> recordBuilderPool = new ArrayDeque<IARecordBuilder>();
private Queue<IAsterixListBuilder> orderedListBuilderPool = new ArrayDeque<IAsterixListBuilder>();
@@ -78,11 +78,11 @@
private String mismatchErrorMessage2 = " got a value of type ";
@Override
- public boolean parse(DataOutput out) throws HyracksDataException {
+ public boolean parse(DataOutput out) throws AsterixException {
try {
return parseAdmInstance((IAType) recordType, datasetRec, out);
- } catch (Exception e) {
- throw new HyracksDataException(e);
+ } catch (IOException | AdmLexerException e) {
+ throw new AsterixException(e);
}
}
@@ -98,13 +98,8 @@
}
protected boolean parseAdmInstance(IAType objectType, boolean datasetRec, DataOutput out) throws AsterixException,
- IOException {
- int token;
- try {
- token = admLexer.next();
- } catch (AdmLexerException e) {
- throw new AsterixException(e);
- }
+ IOException, AdmLexerException {
+ int token = admLexer.next();
if (token == AdmLexer.TOKEN_EOF) {
return false;
} else {
@@ -114,7 +109,7 @@
}
private void admFromLexerStream(int token, IAType objectType, DataOutput out, Boolean datasetRec)
- throws AsterixException, IOException {
+ throws AsterixException, IOException, AdmLexerException {
switch (token) {
case AdmLexer.TOKEN_NULL_LITERAL: {
@@ -174,7 +169,7 @@
parseConstructor(ATypeTag.INT16, objectType, out);
break;
}
- case AdmLexer.TOKEN_INT_LITERAL:{
+ case AdmLexer.TOKEN_INT_LITERAL: {
parseToNumericTarget(ATypeTag.INT32, objectType, out);
break;
}
@@ -220,56 +215,44 @@
break;
}
case AdmLexer.TOKEN_INTERVAL_DATE_CONS: {
- try {
- if (checkType(ATypeTag.INTERVAL, objectType, out)) {
- if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
- if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
- AIntervalSerializerDeserializer.parseDate(admLexer.getLastTokenImage(), out);
+ if (checkType(ATypeTag.INTERVAL, objectType, out)) {
+ if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
+ if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
+ AIntervalSerializerDeserializer.parseDate(admLexer.getLastTokenImage(), out);
- if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
- break;
- }
+ if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
+ break;
}
}
}
- } catch (AdmLexerException ex) {
- throw new AsterixException(ex);
}
throw new AsterixException("Wrong interval data parsing for date interval.");
}
case AdmLexer.TOKEN_INTERVAL_TIME_CONS: {
- try {
- if (checkType(ATypeTag.INTERVAL, objectType, out)) {
- if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
- if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
- AIntervalSerializerDeserializer.parseTime(admLexer.getLastTokenImage(), out);
+ if (checkType(ATypeTag.INTERVAL, objectType, out)) {
+ if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
+ if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
+ AIntervalSerializerDeserializer.parseTime(admLexer.getLastTokenImage(), out);
- if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
- break;
- }
+ if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
+ break;
}
}
}
- } catch (AdmLexerException ex) {
- throw new AsterixException(ex);
}
throw new AsterixException("Wrong interval data parsing for time interval.");
}
case AdmLexer.TOKEN_INTERVAL_DATETIME_CONS: {
- try {
- if (checkType(ATypeTag.INTERVAL, objectType, out)) {
- if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
- if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
- AIntervalSerializerDeserializer.parseDatetime(admLexer.getLastTokenImage(), out);
+ if (checkType(ATypeTag.INTERVAL, objectType, out)) {
+ if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
+ if (admLexer.next() == AdmLexer.TOKEN_STRING_LITERAL) {
+ AIntervalSerializerDeserializer.parseDatetime(admLexer.getLastTokenImage(), out);
- if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
- break;
- }
+ if (admLexer.next() == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
+ break;
}
}
}
- } catch (AdmLexerException ex) {
- throw new AsterixException(ex);
}
throw new AsterixException("Wrong interval data parsing for datetime interval.");
}
@@ -343,41 +326,7 @@
}
}
- private void parseDatetime(String datetime, DataOutput out) throws AsterixException, IOException {
- try {
- ADateTimeSerializerDeserializer.parse(datetime, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
- private void parseDuration(String duration, DataOutput out) throws AsterixException {
- try {
- ADurationSerializerDeserializer.parse(duration, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
-
- }
-
- private void parseYearMonthDuration(String duration, DataOutput out) throws AsterixException {
- try {
- AYearMonthDurationSerializerDeserializer.INSTANCE.parse(duration, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
- private void parseDayTimeDuration(String duration, DataOutput out) throws AsterixException {
- try {
- ADayTimeDurationSerializerDeserializer.INSTANCE.parse(duration, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
private IAType getComplexType(IAType aObjectType, ATypeTag tag) {
-
if (aObjectType == null) {
return null;
}
@@ -386,7 +335,7 @@
return aObjectType;
if (aObjectType.getTypeTag() == ATypeTag.UNION) {
- unionList = ((AUnionType) aObjectType).getUnionList();
+ List<IAType> unionList = ((AUnionType) aObjectType).getUnionList();
for (int i = 0; i < unionList.size(); i++)
if (unionList.get(i).getTypeTag() == tag) {
return unionList.get(i);
@@ -395,8 +344,6 @@
return null; // wont get here
}
- List<IAType> unionList;
-
private ATypeTag getTargetTypeTag(ATypeTag expectedTypeTag, IAType aObjectType) throws IOException {
if (aObjectType == null) {
return expectedTypeTag;
@@ -405,7 +352,7 @@
final ATypeTag typeTag = aObjectType.getTypeTag();
return ATypeHierarchy.canPromote(expectedTypeTag, typeTag) ? typeTag : null;
} else { // union
- unionList = ((AUnionType) aObjectType).getUnionList();
+ List<IAType> unionList = ((AUnionType) aObjectType).getUnionList();
for (IAType t : unionList) {
final ATypeTag typeTag = t.getTypeTag();
if (ATypeHierarchy.canPromote(expectedTypeTag, typeTag)) {
@@ -415,19 +362,18 @@
}
return null;
}
-
+
private boolean checkType(ATypeTag expectedTypeTag, IAType aObjectType, DataOutput out) throws IOException {
return getTargetTypeTag(expectedTypeTag, aObjectType) != null;
}
private void parseRecord(ARecordType recType, DataOutput out, Boolean datasetRec) throws IOException,
- AsterixException {
+ AsterixException, AdmLexerException {
ArrayBackedValueStorage fieldValueBuffer = getTempBuffer();
ArrayBackedValueStorage fieldNameBuffer = getTempBuffer();
IARecordBuilder recBuilder = getRecordBuilder();
- // Boolean[] nulls = null;
BitSet nulls = null;
if (datasetRec) {
if (recType != null) {
@@ -451,7 +397,7 @@
int fieldId = 0;
IAType fieldType = null;
do {
- token = nextToken();
+ token = admLexer.next();
switch (token) {
case AdmLexer.TOKEN_END_RECORD: {
if (expectingRecordField) {
@@ -493,13 +439,13 @@
fieldType = null;
}
- token = nextToken();
+ token = admLexer.next();
if (token != AdmLexer.TOKEN_COLON) {
throw new AsterixException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token)
+ " while expecting \":\".");
}
- token = nextToken();
+ token = admLexer.next();
this.admFromLexerStream(token, fieldType, fieldValueBuffer.getDataOutput(), false);
if (openRecordField) {
if (fieldValueBuffer.getByteArray()[0] != ATypeTag.NULL.serialize())
@@ -546,7 +492,6 @@
}
private int checkNullConstraints(ARecordType recType, BitSet nulls) {
-
boolean isNull = false;
for (int i = 0; i < recType.getFieldTypes().length; i++)
if (nulls.get(i) == false) {
@@ -555,7 +500,7 @@
return i;
if (type.getTypeTag() == ATypeTag.UNION) { // union
- unionList = ((AUnionType) type).getUnionList();
+ List<IAType> unionList = ((AUnionType) type).getUnionList();
for (int j = 0; j < unionList.size(); j++)
if (unionList.get(j).getTypeTag() == ATypeTag.NULL) {
isNull = true;
@@ -568,8 +513,8 @@
return -1;
}
- private void parseOrderedList(AOrderedListType oltype, DataOutput out) throws IOException, AsterixException {
-
+ private void parseOrderedList(AOrderedListType oltype, DataOutput out) throws IOException, AsterixException,
+ AdmLexerException {
ArrayBackedValueStorage itemBuffer = getTempBuffer();
OrderedListBuilder orderedListBuilder = (OrderedListBuilder) getOrderedListBuilder();
@@ -583,7 +528,7 @@
boolean expectingListItem = false;
boolean first = true;
do {
- token = nextToken();
+ token = admLexer.next();
if (token == AdmLexer.TOKEN_END_ORDERED_LIST) {
if (expectingListItem) {
throw new AsterixException("Found END_COLLECTION while expecting a list item.");
@@ -611,8 +556,8 @@
returnTempBuffer(itemBuffer);
}
- private void parseUnorderedList(AUnorderedListType uoltype, DataOutput out) throws IOException, AsterixException {
-
+ private void parseUnorderedList(AUnorderedListType uoltype, DataOutput out) throws IOException, AsterixException,
+ AdmLexerException {
ArrayBackedValueStorage itemBuffer = getTempBuffer();
UnorderedListBuilder unorderedListBuilder = (UnorderedListBuilder) getUnorderedListBuilder();
@@ -627,9 +572,9 @@
boolean expectingListItem = false;
boolean first = true;
do {
- token = nextToken();
+ token = admLexer.next();
if (token == AdmLexer.TOKEN_END_RECORD) {
- if (nextToken() == AdmLexer.TOKEN_END_RECORD) {
+ if (admLexer.next() == AdmLexer.TOKEN_END_RECORD) {
if (expectingListItem) {
throw new AsterixException("Found END_COLLECTION while expecting a list item.");
} else {
@@ -659,16 +604,6 @@
returnTempBuffer(itemBuffer);
}
- private int nextToken() throws AsterixException {
- try {
- return admLexer.next();
- } catch (AdmLexerException e) {
- throw new AsterixException(e);
- } catch (IOException e) {
- throw new AsterixException(e);
- }
- }
-
private IARecordBuilder getRecordBuilder() {
RecordBuilder recBuilder = (RecordBuilder) recordBuilderPool.poll();
if (recBuilder != null)
@@ -718,7 +653,6 @@
baaosPool.add(tempBaaos);
}
-
private void parseToNumericTarget(ATypeTag typeTag, IAType objectType, DataOutput out) throws AsterixException,
IOException {
final ATypeTag targetTypeTag = getTargetTypeTag(typeTag, objectType);
@@ -727,8 +661,9 @@
+ typeTag);
}
}
-
- private void parseAndCastNumeric(ATypeTag typeTag, IAType objectType, DataOutput out) throws AsterixException, IOException {
+
+ private void parseAndCastNumeric(ATypeTag typeTag, IAType objectType, DataOutput out) throws AsterixException,
+ IOException {
final ATypeTag targetTypeTag = getTargetTypeTag(typeTag, objectType);
DataOutput dataOutput = out;
if (targetTypeTag != typeTag) {
@@ -750,49 +685,47 @@
castBuffer.getLength() - 1, out);
}
}
-
- private void parseConstructor(ATypeTag typeTag, IAType objectType, DataOutput out) throws AsterixException {
- try {
- final ATypeTag targetTypeTag = getTargetTypeTag(typeTag, objectType);
- if (targetTypeTag != null) {
- DataOutput dataOutput = out;
- if (targetTypeTag != typeTag) {
- castBuffer.reset();
- dataOutput = castBuffer.getDataOutput();
- }
- int token = admLexer.next();
- if (token == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
+
+ private void parseConstructor(ATypeTag typeTag, IAType objectType, DataOutput out) throws AsterixException,
+ AdmLexerException, IOException {
+ final ATypeTag targetTypeTag = getTargetTypeTag(typeTag, objectType);
+ if (targetTypeTag != null) {
+ DataOutput dataOutput = out;
+ if (targetTypeTag != typeTag) {
+ castBuffer.reset();
+ dataOutput = castBuffer.getDataOutput();
+ }
+ int token = admLexer.next();
+ if (token == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
+ token = admLexer.next();
+ if (token == AdmLexer.TOKEN_STRING_LITERAL) {
+ final String unquoted = admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1);
+ if (!parseValue(unquoted, typeTag, dataOutput)) {
+ throw new AsterixException("Missing deserializer method for constructor: "
+ + AdmLexer.tokenKindToString(token) + ".");
+ }
token = admLexer.next();
- if (token == AdmLexer.TOKEN_STRING_LITERAL) {
- final String unquoted = admLexer.getLastTokenImage().substring(1,
- admLexer.getLastTokenImage().length() - 1);
- if (!parseValue(unquoted, typeTag, dataOutput)) {
- throw new AsterixException("Missing deserializer method for constructor: "
- + AdmLexer.tokenKindToString(token) + ".");
+ if (token == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
+ if (targetTypeTag != typeTag) {
+ ITypePromoteComputer promoteComputer = ATypeHierarchy.getTypePromoteComputer(typeTag,
+ targetTypeTag);
+ // the availability if the promote computer should be consistent with the availability of a target type
+ assert promoteComputer != null;
+ // do the promotion; note that the type tag field should be skipped
+ promoteComputer.promote(castBuffer.getByteArray(), castBuffer.getStartOffset() + 1,
+ castBuffer.getLength() - 1, out);
}
- token = admLexer.next();
- if (token == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE) {
- if (targetTypeTag != typeTag) {
- ITypePromoteComputer promoteComputer = ATypeHierarchy.getTypePromoteComputer(typeTag, targetTypeTag);
- // the availability if the promote computer should be consistent with the availability of a target type
- assert promoteComputer != null;
- // do the promotion; note that the type tag field should be skipped
- promoteComputer.promote(castBuffer.getByteArray(), castBuffer.getStartOffset() + 1,
- castBuffer.getLength() - 1, out);
- }
- return;
- }
+ return;
}
}
}
- } catch (IOException | AdmLexerException e) {
- throw new AsterixException(e);
}
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName() + ". Got " + typeTag + " instead.");
}
- private boolean parseValue(final String unquoted, ATypeTag typeTag, DataOutput out)
- throws AsterixException, HyracksDataException, IOException {
+ private boolean parseValue(final String unquoted, ATypeTag typeTag, DataOutput out) throws AsterixException,
+ HyracksDataException, IOException {
switch (typeTag) {
case BOOLEAN:
parseBoolean(unquoted, out);
@@ -822,256 +755,170 @@
stringSerde.serialize(aString, out);
return true;
case TIME:
- parseTime(unquoted, out);
+ ATimeSerializerDeserializer.parse(unquoted, out);
return true;
case DATE:
- parseDate(unquoted, out);
+ ADateSerializerDeserializer.parse(unquoted, out);
return true;
case DATETIME:
- parseDatetime(unquoted, out);
+ ADateTimeSerializerDeserializer.parse(unquoted, out);
return true;
case DURATION:
- parseDuration(unquoted, out);
+ ADurationSerializerDeserializer.parse(unquoted, out);
return true;
case DAYTIMEDURATION:
- parseDayTimeDuration(unquoted, out);
+ ADayTimeDurationSerializerDeserializer.INSTANCE.parse(unquoted, out);
return true;
case YEARMONTHDURATION:
- parseYearMonthDuration(unquoted, out);
+ AYearMonthDurationSerializerDeserializer.INSTANCE.parse(unquoted, out);
return true;
case POINT:
- parsePoint(unquoted, out);
+ APointSerializerDeserializer.parse(unquoted, out);
return true;
case POINT3D:
- parsePoint3d(unquoted, out);
+ APoint3DSerializerDeserializer.parse(unquoted, out);
return true;
case CIRCLE:
- parseCircle(unquoted, out);
+ ACircleSerializerDeserializer.parse(unquoted, out);
return true;
case RECTANGLE:
- parseRectangle(unquoted, out);
+ ARectangleSerializerDeserializer.parse(unquoted, out);
return true;
case LINE:
- parseLine(unquoted, out);
+ ALineSerializerDeserializer.parse(unquoted, out);
return true;
case POLYGON:
- parsePolygon(unquoted, out);
+ APolygonSerializerDeserializer.parse(unquoted, out);
return true;
default:
return false;
}
}
- private void parseBoolean(String bool, DataOutput out) throws AsterixException {
+ private void parseBoolean(String bool, DataOutput out) throws AsterixException, HyracksDataException {
String errorMessage = "This can not be an instance of boolean";
- try {
- if (bool.equals("true"))
- booleanSerde.serialize(ABoolean.TRUE, out);
- else if (bool.equals("false"))
- booleanSerde.serialize(ABoolean.FALSE, out);
+ if (bool.equals("true"))
+ booleanSerde.serialize(ABoolean.TRUE, out);
+ else if (bool.equals("false"))
+ booleanSerde.serialize(ABoolean.FALSE, out);
+ else
+ throw new AsterixException(errorMessage);
+ }
+
+ private void parseInt8(String int8, DataOutput out) throws AsterixException, HyracksDataException {
+ String errorMessage = "This can not be an instance of int8";
+ boolean positive = true;
+ byte value = 0;
+ int offset = 0;
+
+ if (int8.charAt(offset) == '+')
+ offset++;
+ else if (int8.charAt(offset) == '-') {
+ offset++;
+ positive = false;
+ }
+ for (; offset < int8.length(); offset++) {
+ if (int8.charAt(offset) >= '0' && int8.charAt(offset) <= '9')
+ value = (byte) (value * 10 + int8.charAt(offset) - '0');
+ else if (int8.charAt(offset) == 'i' && int8.charAt(offset + 1) == '8' && offset + 2 == int8.length())
+ break;
else
throw new AsterixException(errorMessage);
- } catch (HyracksDataException e) {
- throw new AsterixException(errorMessage);
}
+ if (value < 0)
+ throw new AsterixException(errorMessage);
+ if (value > 0 && !positive)
+ value *= -1;
+ aInt8.setValue(value);
+ int8Serde.serialize(aInt8, out);
}
- private void parseInt8(String int8, DataOutput out) throws AsterixException {
- String errorMessage = "This can not be an instance of int8";
- try {
- boolean positive = true;
- byte value = 0;
- int offset = 0;
-
- if (int8.charAt(offset) == '+')
- offset++;
- else if (int8.charAt(offset) == '-') {
- offset++;
- positive = false;
- }
- for (; offset < int8.length(); offset++) {
- if (int8.charAt(offset) >= '0' && int8.charAt(offset) <= '9')
- value = (byte) (value * 10 + int8.charAt(offset) - '0');
- else if (int8.charAt(offset) == 'i' && int8.charAt(offset + 1) == '8' && offset + 2 == int8.length())
- break;
- else
- throw new AsterixException(errorMessage);
- }
- if (value < 0)
- throw new AsterixException(errorMessage);
- if (value > 0 && !positive)
- value *= -1;
- aInt8.setValue(value);
- int8Serde.serialize(aInt8, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(errorMessage);
- }
- }
-
- private void parseInt16(String int16, DataOutput out) throws AsterixException {
+ private void parseInt16(String int16, DataOutput out) throws AsterixException, HyracksDataException {
String errorMessage = "This can not be an instance of int16";
- try {
- boolean positive = true;
- short value = 0;
- int offset = 0;
+ boolean positive = true;
+ short value = 0;
+ int offset = 0;
- if (int16.charAt(offset) == '+')
- offset++;
- else if (int16.charAt(offset) == '-') {
- offset++;
- positive = false;
- }
- for (; offset < int16.length(); offset++) {
- if (int16.charAt(offset) >= '0' && int16.charAt(offset) <= '9')
- value = (short) (value * 10 + int16.charAt(offset) - '0');
- else if (int16.charAt(offset) == 'i' && int16.charAt(offset + 1) == '1'
- && int16.charAt(offset + 2) == '6' && offset + 3 == int16.length())
- break;
- else
- throw new AsterixException(errorMessage);
- }
- if (value < 0)
- throw new AsterixException(errorMessage);
- if (value > 0 && !positive)
- value *= -1;
- aInt16.setValue(value);
- int16Serde.serialize(aInt16, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(errorMessage);
+ if (int16.charAt(offset) == '+')
+ offset++;
+ else if (int16.charAt(offset) == '-') {
+ offset++;
+ positive = false;
}
+ for (; offset < int16.length(); offset++) {
+ if (int16.charAt(offset) >= '0' && int16.charAt(offset) <= '9')
+ value = (short) (value * 10 + int16.charAt(offset) - '0');
+ else if (int16.charAt(offset) == 'i' && int16.charAt(offset + 1) == '1' && int16.charAt(offset + 2) == '6'
+ && offset + 3 == int16.length())
+ break;
+ else
+ throw new AsterixException(errorMessage);
+ }
+ if (value < 0)
+ throw new AsterixException(errorMessage);
+ if (value > 0 && !positive)
+ value *= -1;
+ aInt16.setValue(value);
+ int16Serde.serialize(aInt16, out);
}
- private void parseInt32(String int32, DataOutput out) throws AsterixException {
-
+ private void parseInt32(String int32, DataOutput out) throws AsterixException, HyracksDataException {
String errorMessage = "This can not be an instance of int32";
- try {
- boolean positive = true;
- int value = 0;
- int offset = 0;
+ boolean positive = true;
+ int value = 0;
+ int offset = 0;
- if (int32.charAt(offset) == '+')
- offset++;
- else if (int32.charAt(offset) == '-') {
- offset++;
- positive = false;
- }
- for (; offset < int32.length(); offset++) {
- if (int32.charAt(offset) >= '0' && int32.charAt(offset) <= '9')
- value = (value * 10 + int32.charAt(offset) - '0');
- else if (int32.charAt(offset) == 'i' && int32.charAt(offset + 1) == '3'
- && int32.charAt(offset + 2) == '2' && offset + 3 == int32.length())
- break;
- else
- throw new AsterixException(errorMessage);
- }
- if (value < 0)
- throw new AsterixException(errorMessage);
- if (value > 0 && !positive)
- value *= -1;
-
- aInt32.setValue(value);
- int32Serde.serialize(aInt32, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(errorMessage);
+ if (int32.charAt(offset) == '+')
+ offset++;
+ else if (int32.charAt(offset) == '-') {
+ offset++;
+ positive = false;
}
+ for (; offset < int32.length(); offset++) {
+ if (int32.charAt(offset) >= '0' && int32.charAt(offset) <= '9')
+ value = (value * 10 + int32.charAt(offset) - '0');
+ else if (int32.charAt(offset) == 'i' && int32.charAt(offset + 1) == '3' && int32.charAt(offset + 2) == '2'
+ && offset + 3 == int32.length())
+ break;
+ else
+ throw new AsterixException(errorMessage);
+ }
+ if (value < 0)
+ throw new AsterixException(errorMessage);
+ if (value > 0 && !positive)
+ value *= -1;
+
+ aInt32.setValue(value);
+ int32Serde.serialize(aInt32, out);
}
- private void parseInt64(String int64, DataOutput out) throws AsterixException {
+ private void parseInt64(String int64, DataOutput out) throws AsterixException, HyracksDataException {
String errorMessage = "This can not be an instance of int64";
- try {
- boolean positive = true;
- long value = 0;
- int offset = 0;
+ boolean positive = true;
+ long value = 0;
+ int offset = 0;
- if (int64.charAt(offset) == '+')
- offset++;
- else if (int64.charAt(offset) == '-') {
- offset++;
- positive = false;
- }
- for (; offset < int64.length(); offset++) {
- if (int64.charAt(offset) >= '0' && int64.charAt(offset) <= '9')
- value = (value * 10 + int64.charAt(offset) - '0');
- else if (int64.charAt(offset) == 'i' && int64.charAt(offset + 1) == '6'
- && int64.charAt(offset + 2) == '4' && offset + 3 == int64.length())
- break;
- else
- throw new AsterixException(errorMessage);
- }
- if (value < 0)
+ if (int64.charAt(offset) == '+')
+ offset++;
+ else if (int64.charAt(offset) == '-') {
+ offset++;
+ positive = false;
+ }
+ for (; offset < int64.length(); offset++) {
+ if (int64.charAt(offset) >= '0' && int64.charAt(offset) <= '9')
+ value = (value * 10 + int64.charAt(offset) - '0');
+ else if (int64.charAt(offset) == 'i' && int64.charAt(offset + 1) == '6' && int64.charAt(offset + 2) == '4'
+ && offset + 3 == int64.length())
+ break;
+ else
throw new AsterixException(errorMessage);
- if (value > 0 && !positive)
- value *= -1;
-
- aInt64.setValue(value);
- int64Serde.serialize(aInt64, out);
- } catch (HyracksDataException e) {
+ }
+ if (value < 0)
throw new AsterixException(errorMessage);
- }
- }
+ if (value > 0 && !positive)
+ value *= -1;
- private void parsePoint(String point, DataOutput out) throws AsterixException {
- try {
- APointSerializerDeserializer.parse(point, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
+ aInt64.setValue(value);
+ int64Serde.serialize(aInt64, out);
}
-
- private void parsePoint3d(String point3d, DataOutput out) throws AsterixException {
- try {
- APoint3DSerializerDeserializer.parse(point3d, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
- private void parseCircle(String circle, DataOutput out) throws AsterixException {
- try {
- ACircleSerializerDeserializer.parse(circle, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
- private void parseRectangle(String rectangle, DataOutput out) throws AsterixException {
- try {
- ARectangleSerializerDeserializer.parse(rectangle, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
- private void parseLine(String line, DataOutput out) throws AsterixException {
- try {
- ALineSerializerDeserializer.parse(line, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
- private void parsePolygon(String polygon, DataOutput out) throws AsterixException, IOException {
- try {
- APolygonSerializerDeserializer.parse(polygon, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
- private void parseTime(String time, DataOutput out) throws AsterixException {
- try {
- ATimeSerializerDeserializer.parse(time, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
- private void parseDate(String date, DataOutput out) throws AsterixException, IOException {
- try {
- ADateSerializerDeserializer.parse(date, out);
- } catch (HyracksDataException e) {
- throw new AsterixException(e);
- }
- }
-
}