merge from asterix_stabilization r1199 through r1240
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_installer@1241 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-algebra/pom.xml b/asterix-algebra/pom.xml
index 70f8c53..b81e77f 100644
--- a/asterix-algebra/pom.xml
+++ b/asterix-algebra/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>asterix</artifactId>
@@ -14,8 +15,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
<plugin>
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
index 704ccb5..5c54a4a 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -15,6 +15,7 @@
package edu.uci.ics.asterix.optimizer.rules;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -93,40 +94,44 @@
}
IAType t = (IAType) env.getType(fce.getArguments().get(0).getValue());
- switch (t.getTypeTag()) {
- case ANY: {
- return false;
- }
- case RECORD: {
- ARecordType recType = (ARecordType) t;
- ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
- if (fai == null) {
+ try {
+ switch (t.getTypeTag()) {
+ case ANY: {
return false;
}
- expressions.get(i).setValue(fai);
- changed = true;
- break;
- }
- case UNION: {
- AUnionType unionT = (AUnionType) t;
- if (unionT.isNullableType()) {
- IAType t2 = unionT.getUnionList().get(1);
- if (t2.getTypeTag() == ATypeTag.RECORD) {
- ARecordType recType = (ARecordType) t2;
- ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
- if (fai == null) {
- return false;
- }
- expressions.get(i).setValue(fai);
- changed = true;
- break;
+ case RECORD: {
+ ARecordType recType = (ARecordType) t;
+ ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
+ if (fai == null) {
+ return false;
}
+ expressions.get(i).setValue(fai);
+ changed = true;
+ break;
}
- throw new NotImplementedException("Union " + unionT);
+ case UNION: {
+ AUnionType unionT = (AUnionType) t;
+ if (unionT.isNullableType()) {
+ IAType t2 = unionT.getUnionList().get(1);
+ if (t2.getTypeTag() == ATypeTag.RECORD) {
+ ARecordType recType = (ARecordType) t2;
+ ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
+ if (fai == null) {
+ return false;
+ }
+ expressions.get(i).setValue(fai);
+ changed = true;
+ break;
+ }
+ }
+ throw new NotImplementedException("Union " + unionT);
+ }
+ default: {
+ throw new AlgebricksException("Cannot call field-access on data of type " + t);
+ }
}
- default: {
- throw new AlgebricksException("Cannot call field-access on data of type " + t);
- }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
}
}
assign.removeAnnotation(AsterixOperatorAnnotations.PUSHED_FIELD_ACCESS);
@@ -134,7 +139,8 @@
}
@SuppressWarnings("unchecked")
- private static ILogicalExpression createFieldAccessByIndex(ARecordType recType, AbstractFunctionCallExpression fce) {
+ private static ILogicalExpression createFieldAccessByIndex(ARecordType recType, AbstractFunctionCallExpression fce)
+ throws IOException {
String s = getStringSecondArgument(fce);
if (s == null) {
return null;
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ConstantFoldingRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ConstantFoldingRule.java
index bc61c49..b0ce342 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ConstantFoldingRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ConstantFoldingRule.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -16,6 +16,7 @@
package edu.uci.ics.asterix.optimizer.rules;
import java.io.DataInputStream;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
@@ -188,7 +189,12 @@
ARecordType rt = (ARecordType) _emptyTypeEnv.getType(expr.getArguments().get(0).getValue());
String str = ((AString) ((AsterixConstantValue) ((ConstantExpression) expr.getArguments().get(1)
.getValue()).getValue()).getObject()).getStringValue();
- int k = rt.findFieldPosition(str);
+ int k;
+ try {
+ k = rt.findFieldPosition(str);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
if (k >= 0) {
// wait for the ByNameToByIndex rule to apply
return new Pair<Boolean, ILogicalExpression>(changed, expr);
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodUtils.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodUtils.java
index 6651ea3..ffd447c 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodUtils.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AccessMethodUtils.java
@@ -1,5 +1,21 @@
+/*
+ * Copyright 2009-2013 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.optimizer.rules.am;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -44,7 +60,8 @@
* Static helper functions for rewriting plans using indexes.
*/
public class AccessMethodUtils {
- public static void appendPrimaryIndexTypes(Dataset dataset, IAType itemType, List<Object> target) {
+ public static void appendPrimaryIndexTypes(Dataset dataset, IAType itemType, List<Object> target)
+ throws IOException {
ARecordType recordType = (ARecordType) itemType;
List<String> partitioningKeys = DatasetUtils.getPartitioningKeys(dataset);
for (String partitioningKey : partitioningKeys) {
@@ -109,7 +126,7 @@
analysisCtx.matchedFuncExprs.add(new OptimizableFuncExpr(funcExpr, fieldVar, constFilterVal));
return true;
}
-
+
public static boolean analyzeFuncExprArgsForTwoVars(AbstractFunctionCallExpression funcExpr,
AccessMethodAnalysisContext analysisCtx) {
LogicalVariable fieldVar1 = null;
@@ -180,7 +197,11 @@
// Primary keys.
List<String> partitioningKeys = DatasetUtils.getPartitioningKeys(dataset);
for (String partitioningKey : partitioningKeys) {
- dest.add(recordType.getFieldType(partitioningKey));
+ try {
+ dest.add(recordType.getFieldType(partitioningKey));
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
}
}
@@ -229,14 +250,14 @@
}
/**
- * Returns the first expr optimizable by this index.
+ * Returns the first expr optimizable by this index.
*/
public static IOptimizableFuncExpr chooseFirstOptFuncExpr(Index chosenIndex, AccessMethodAnalysisContext analysisCtx) {
List<Integer> indexExprs = analysisCtx.getIndexExprs(chosenIndex);
int firstExprIndex = indexExprs.get(0);
return analysisCtx.matchedFuncExprs.get(firstExprIndex);
}
-
+
public static UnnestMapOperator createSecondaryIndexUnnestMap(Dataset dataset, ARecordType recordType, Index index,
ILogicalOperator inputOp, AccessMethodJobGenParams jobGenParams, IOptimizationContext context,
boolean outputPrimaryKeysOnly, boolean retainInput) throws AlgebricksException {
@@ -299,7 +320,11 @@
List<Object> primaryIndexOutputTypes = new ArrayList<Object>();
// Append output variables/types generated by the primary-index search (not forwarded from input).
primaryIndexUnnestVars.addAll(dataSourceScan.getVariables());
- appendPrimaryIndexTypes(dataset, recordType, primaryIndexOutputTypes);
+ try {
+ appendPrimaryIndexTypes(dataset, recordType, primaryIndexOutputTypes);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
// An index search is expressed as an unnest over an index-search function.
IFunctionInfo primaryIndexSearch = FunctionUtils.getFunctionInfo(AsterixBuiltinFunctions.INDEX_SEARCH);
AbstractFunctionCallExpression primaryIndexSearchFunc = new ScalarFunctionCallExpression(primaryIndexSearch,
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/BTreeAccessMethod.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/BTreeAccessMethod.java
index 5c65299..3b547e7 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/BTreeAccessMethod.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/BTreeAccessMethod.java
@@ -1,5 +1,21 @@
+/*
+ * Copyright 2009-2013 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.optimizer.rules.am;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
@@ -205,7 +221,7 @@
if (optFuncExpr.getNumLogicalVars() > 1) {
// If we are optimizing a join, the matching field may be the second field name.
keyPos = indexOf(optFuncExpr.getFieldName(1), chosenIndex.getKeyFieldNames());
- }
+ }
}
if (keyPos < 0) {
throw new AlgebricksException(
@@ -238,7 +254,7 @@
// If high and low keys are set, we exit for now.
if (setLowKeys.cardinality() == numSecondaryKeys && setHighKeys.cardinality() == numSecondaryKeys) {
doneWithExprs = true;
- }
+ }
break;
}
case HIGH_EXCLUSIVE: {
@@ -390,7 +406,11 @@
secondaryIndexUnnestOp, context, true, retainInput, false);
} else {
List<Object> primaryIndexOutputTypes = new ArrayList<Object>();
- AccessMethodUtils.appendPrimaryIndexTypes(dataset, recordType, primaryIndexOutputTypes);
+ try {
+ AccessMethodUtils.appendPrimaryIndexTypes(dataset, recordType, primaryIndexOutputTypes);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
primaryIndexUnnestOp = new UnnestMapOperator(dataSourceScan.getVariables(),
secondaryIndexUnnestOp.getExpressionRef(), primaryIndexOutputTypes, retainInput);
primaryIndexUnnestOp.getInputs().add(new MutableObject<ILogicalOperator>(inputOp));
@@ -521,7 +541,7 @@
return (optFuncExpr.getOperatorSubTree(0) == null || optFuncExpr.getOperatorSubTree(0) == probeSubTree);
}
}
-
+
private ILogicalExpression createSelectCondition(List<Mutable<ILogicalExpression>> predList) {
if (predList.size() > 1) {
IFunctionInfo finfo = AsterixBuiltinFunctions.getAsterixFunctionInfo(AlgebricksBuiltinFunctions.AND);
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/TypeTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/TypeTranslator.java
index 4047d9a..5abbd91 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/TypeTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/TypeTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package edu.uci.ics.asterix.translator;
import java.util.ArrayList;
@@ -29,6 +30,7 @@
import edu.uci.ics.asterix.aql.expression.UnorderedListTypeDefinition;
import edu.uci.ics.asterix.common.annotations.IRecordFieldDataGen;
import edu.uci.ics.asterix.common.annotations.RecordDataGenAnnotation;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.MetadataManager;
import edu.uci.ics.asterix.metadata.MetadataTransactionContext;
@@ -89,41 +91,45 @@
throw new AlgebricksException("Cannot redefine builtin type " + tdname + " .");
}
TypeSignature typeSignature = new TypeSignature(typeDataverse, tdname);
- switch (texpr.getTypeKind()) {
- case TYPEREFERENCE: {
- TypeReferenceExpression tre = (TypeReferenceExpression) texpr;
- IAType t = solveTypeReference(typeSignature, typeMap);
- if (t != null) {
- typeMap.put(typeSignature, t);
- } else {
- addIncompleteTopLevelTypeReference(tdname, tre, incompleteTopLevelTypeReferences, typeDataverse);
+ try {
+ switch (texpr.getTypeKind()) {
+ case TYPEREFERENCE: {
+ TypeReferenceExpression tre = (TypeReferenceExpression) texpr;
+ IAType t = solveTypeReference(typeSignature, typeMap);
+ if (t != null) {
+ typeMap.put(typeSignature, t);
+ } else {
+ addIncompleteTopLevelTypeReference(tdname, tre, incompleteTopLevelTypeReferences, typeDataverse);
+ }
+ break;
}
- break;
+ case RECORD: {
+ RecordTypeDefinition rtd = (RecordTypeDefinition) texpr;
+ ARecordType recType = computeRecordType(typeSignature, rtd, typeMap, incompleteFieldTypes,
+ incompleteItemTypes, typeDataverse);
+ typeMap.put(typeSignature, recType);
+ break;
+ }
+ case ORDEREDLIST: {
+ OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) texpr;
+ AOrderedListType olType = computeOrderedListType(typeSignature, oltd, typeMap, incompleteItemTypes,
+ incompleteFieldTypes, typeDataverse);
+ typeMap.put(typeSignature, olType);
+ break;
+ }
+ case UNORDEREDLIST: {
+ UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) texpr;
+ AUnorderedListType ulType = computeUnorderedListType(typeSignature, ultd, typeMap,
+ incompleteItemTypes, incompleteFieldTypes, typeDataverse);
+ typeMap.put(typeSignature, ulType);
+ break;
+ }
+ default: {
+ throw new IllegalStateException();
+ }
}
- case RECORD: {
- RecordTypeDefinition rtd = (RecordTypeDefinition) texpr;
- ARecordType recType = computeRecordType(typeSignature, rtd, typeMap, incompleteFieldTypes,
- incompleteItemTypes, typeDataverse);
- typeMap.put(typeSignature, recType);
- break;
- }
- case ORDEREDLIST: {
- OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) texpr;
- AOrderedListType olType = computeOrderedListType(typeSignature, oltd, typeMap, incompleteItemTypes,
- incompleteFieldTypes, typeDataverse);
- typeMap.put(typeSignature, olType);
- break;
- }
- case UNORDEREDLIST: {
- UnorderedListTypeDefinition ultd = (UnorderedListTypeDefinition) texpr;
- AUnorderedListType ulType = computeUnorderedListType(typeSignature, ultd, typeMap, incompleteItemTypes,
- incompleteFieldTypes, typeDataverse);
- typeMap.put(typeSignature, ulType);
- break;
- }
- default: {
- throw new IllegalStateException();
- }
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
}
}
@@ -181,7 +187,7 @@
}
t = dt.getDatatype();
} else {
- t = typeMap.get(typeSignature);
+ t = typeMap.get(typeSignature);
}
for (AbstractCollectionType act : incompleteItemTypes.get(typeSignature)) {
act.setItemType(t);
@@ -191,7 +197,8 @@
private static AOrderedListType computeOrderedListType(TypeSignature typeSignature, OrderedListTypeDefinition oltd,
Map<TypeSignature, IAType> typeMap, Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
- Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaultDataverse) {
+ Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaultDataverse)
+ throws AsterixException {
TypeExpression tExpr = oltd.getItemTypeExpression();
String typeName = typeSignature != null ? typeSignature.getName() : null;
AOrderedListType aolt = new AOrderedListType(null, typeName);
@@ -202,7 +209,8 @@
private static AUnorderedListType computeUnorderedListType(TypeSignature typeSignature,
UnorderedListTypeDefinition ultd, Map<TypeSignature, IAType> typeMap,
Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
- Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaulDataverse) {
+ Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaulDataverse)
+ throws AsterixException {
TypeExpression tExpr = ultd.getItemTypeExpression();
String typeName = typeSignature != null ? typeSignature.getName() : null;
AUnorderedListType ault = new AUnorderedListType(null, typeName);
@@ -213,7 +221,7 @@
private static void setCollectionItemType(TypeExpression tExpr, Map<TypeSignature, IAType> typeMap,
Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, AbstractCollectionType act,
- String defaultDataverse) {
+ String defaultDataverse) throws AsterixException {
switch (tExpr.getTypeKind()) {
case ORDEREDLIST: {
OrderedListTypeDefinition oltd = (OrderedListTypeDefinition) tExpr;
@@ -306,7 +314,8 @@
private static ARecordType computeRecordType(TypeSignature typeSignature, RecordTypeDefinition rtd,
Map<TypeSignature, IAType> typeMap, Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
- Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes, String defaultDataverse) {
+ Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes, String defaultDataverse)
+ throws AsterixException {
List<String> names = rtd.getFieldNames();
int n = names.size();
String[] fldNames = new String[n];
@@ -318,14 +327,14 @@
boolean isOpen = rtd.getRecordKind() == RecordKind.OPEN;
ARecordType recType = new ARecordType(typeSignature == null ? null : typeSignature.getName(), fldNames,
fldTypes, isOpen);
-
+
List<IRecordFieldDataGen> fieldDataGen = rtd.getFieldDataGen();
if (fieldDataGen.size() == n) {
IRecordFieldDataGen[] rfdg = new IRecordFieldDataGen[n];
rfdg = fieldDataGen.toArray(rfdg);
recType.getAnnotations().add(new RecordDataGenAnnotation(rfdg, rtd.getUndeclaredFieldsDataGen()));
}
-
+
for (int j = 0; j < n; j++) {
TypeExpression texpr = rtd.getFieldTypes().get(j);
switch (texpr.getTypeKind()) {
diff --git a/asterix-app/pom.xml b/asterix-app/pom.xml
index 2f80c30..7d6e64a 100644
--- a/asterix-app/pom.xml
+++ b/asterix-app/pom.xml
@@ -17,8 +17,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
<plugin>
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
index 8d804a4..5d3ab0a 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2011 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -12,9 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package edu.uci.ics.asterix.file;
import java.io.File;
+import java.io.IOException;
import java.rmi.RemoteException;
import java.util.List;
import java.util.logging.Logger;
@@ -329,7 +331,12 @@
ISerializerDeserializer[] recordFields = new ISerializerDeserializer[1 + numKeys];
recordFields[0] = payloadSerde;
for (int i = 0; i < numKeys; i++) {
- IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+ IAType keyType;
+ try {
+ keyType = itemType.getFieldType(partitioningKeys.get(i));
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
ISerializerDeserializer keySerde = dataFormat.getSerdeProvider().getSerializerDeserializer(keyType);
recordFields[i + 1] = keySerde;
}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryIndexCreator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryIndexCreator.java
index 34ba208..87d3b08 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryIndexCreator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/SecondaryIndexCreator.java
@@ -1,6 +1,22 @@
+/*
+ * Copyright 2009-2013 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.file;
import java.io.DataOutput;
+import java.io.IOException;
import java.util.List;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
@@ -137,13 +153,12 @@
numPrimaryKeys = DatasetUtils.getPartitioningKeys(dataset).size();
numSecondaryKeys = createIndexStmt.getKeyFields().size();
Pair<IFileSplitProvider, AlgebricksPartitionConstraint> primarySplitsAndConstraint = metadataProvider
- .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(
- dataverseName, datasetName, datasetName);
+ .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(dataverseName, datasetName, datasetName);
primaryFileSplitProvider = primarySplitsAndConstraint.first;
primaryPartitionConstraint = primarySplitsAndConstraint.second;
Pair<IFileSplitProvider, AlgebricksPartitionConstraint> secondarySplitsAndConstraint = metadataProvider
- .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(
- dataverseName, datasetName, secondaryIndexName);
+ .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(dataverseName, datasetName,
+ secondaryIndexName);
secondaryFileSplitProvider = secondarySplitsAndConstraint.first;
secondaryPartitionConstraint = secondarySplitsAndConstraint.second;
// Must be called in this order.
@@ -159,7 +174,12 @@
primaryComparatorFactories = new IBinaryComparatorFactory[numPrimaryKeys];
ISerializerDeserializerProvider serdeProvider = metadataProvider.getFormat().getSerdeProvider();
for (int i = 0; i < numPrimaryKeys; i++) {
- IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+ IAType keyType;
+ try {
+ keyType = itemType.getFieldType(partitioningKeys.get(i));
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
primaryRecFields[i] = serdeProvider.getSerializerDeserializer(keyType);
primaryComparatorFactories[i] = AqlBinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(
keyType, true);
@@ -286,8 +306,8 @@
fieldPermutation[i] = i;
}
Pair<IFileSplitProvider, AlgebricksPartitionConstraint> secondarySplitsAndConstraint = metadataProvider
- .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(
- dataverseName, datasetName, secondaryIndexName);
+ .splitProviderAndPartitionConstraintsForInternalOrFeedDataset(dataverseName, datasetName,
+ secondaryIndexName);
TreeIndexBulkLoadOperatorDescriptor treeIndexBulkLoadOp = new TreeIndexBulkLoadOperatorDescriptor(spec,
AsterixStorageManagerInterface.INSTANCE, AsterixIndexRegistryProvider.INSTANCE,
secondarySplitsAndConstraint.first, secondaryRecDesc.getTypeTraits(), secondaryComparatorFactories,
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/int_01.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/int_01.aql
index 683481f..58ae18d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/int_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/int_01.aql
@@ -13,5 +13,4 @@
let $c7 := int32("-320")
let $c8 := int64("-640i64")
let $c9 := int64("-9223372036854775808")
-return {"int8": $c1,"int16": $c2,"int32": $c3, "int64": $c4, "int8": $c5,"int16": $c6,"int32": $c7, "int64": $c8, "int64_min" : $c9}
-
+return {"int8": $c1,"int16": $c2,"int32": $c3, "int64": $c4, "int8_2": $c5,"int16_2": $c6,"int32_2": $c7, "int64_2": $c8, "int64_min" : $c9}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql
index 8266c79..197baaa 100644
--- a/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/cross-dataverse/join_across_dataverses.aql
@@ -57,4 +57,4 @@
for $o in dataset('test2.Orders')
where $c.cid = $o.cid
order by $c.name, $o.total
-return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid], "orderList":{{$o.oid, $o.cid}}}
+return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/join_q_01.aql b/asterix-app/src/test/resources/runtimets/queries/custord/join_q_01.aql
index ddde56e..f5d2080 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/join_q_01.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/join_q_01.aql
@@ -47,4 +47,4 @@
for $o in dataset('Orders')
where $c.cid = $o.cid
order by $c.name, $o.total
-return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid], "orderList":{{$o.oid, $o.cid}}}
+return {"cust_name":$c.name, "cust_age": $c.age, "order_total":$o.total, "orderList":[$o.oid, $o.cid]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_03.aql b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_03.aql
index b930a10..52bc6d2 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_03.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_03.aql
@@ -26,4 +26,4 @@
let $c2 := {{ $o.orderstatus, $o.clerk}}
let $c3 := [$o.heList, $o.openlist, $o.loc, $o.line, $o.poly, $o.lastorder]
let $c4 := [$o.heList, $o.openlist, $o.loc, $o.line, $o.poly, $o.lastorder]
-return { "orderid": $o.oid, "ordertot":$o.total, "list": $c1, "item1": $c1[0], "item1": $c1[?], "item2": $c1[1], "item3": $c1[2]}
+return { "orderid": $o.oid, "ordertot":$o.total, "list": $c1, "item1": $c1[0], "item2": $c1[1], "item3": $c1[2]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_04.aql b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_04.aql
index b2d55d9..e2fd5b6 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_04.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_04.aql
@@ -26,4 +26,4 @@
let $c2 := {{ $o.orderstatus, $o.clerk}}
let $c3 := [$o.heList, $o.openlist, $o.loc, $o.line, $o.poly, $o.lastorder]
let $c4 := [$o.heList, $o.openlist, $o.loc, $o.line, $o.poly, $o.lastorder]
-return { "orderid": $o.oid, "ordertot":$o.total, "list": $c3, "item1": $c3[0], "item1": $c3[?], "item2": $c3[1], "item5": $c3[5], "item10": $c3[10]}
+return { "orderid": $o.oid, "ordertot":$o.total, "list": $c3, "item1": $c3[0], "item2": $c3[1], "item5": $c3[5], "item10": $c3[10]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_05.aql b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_05.aql
index 5693312..481c1fd 100644
--- a/asterix-app/src/test/resources/runtimets/queries/custord/order_q_05.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/custord/order_q_05.aql
@@ -24,4 +24,4 @@
for $o in dataset('Orders')
let $c1 := []
let $c2 := {{}}
-return { "orderid": $o.oid, "ordertot":$o.total, "emptyorderedlist": $c1, "emptyunorderedlist": $c2, "olist_item1": $c1[0], "olist_item1": $c1[?], "olist_item5": $c1[4], "ulist_item1": $c2[?]}
+return { "orderid": $o.oid, "ordertot":$o.total, "emptyorderedlist": $c1, "emptyunorderedlist": $c2, "olist_item1": $c1[0], "olist_item5": $c1[4], "ulist_item1": $c2[?]}
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/closed-closed-fieldname-conflict_issue173.aql b/asterix-app/src/test/resources/runtimets/queries/records/closed-closed-fieldname-conflict_issue173.aql
new file mode 100644
index 0000000..b356a56
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/records/closed-closed-fieldname-conflict_issue173.aql
@@ -0,0 +1,11 @@
+/*
+ * Description : Tests whether a conflict between two closed field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+let $x := {"name": "john", "name": "smith"}
+return $x
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/open-closed-fieldname-conflict_issue173.aql b/asterix-app/src/test/resources/runtimets/queries/records/open-closed-fieldname-conflict_issue173.aql
new file mode 100644
index 0000000..a5ac400
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/records/open-closed-fieldname-conflict_issue173.aql
@@ -0,0 +1,21 @@
+/*
+ * Description : Tests whether a conflict between an open and closed field name are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type opentype as open {
+id:int32,
+fname:string
+}
+
+create dataset testds(opentype) primary key id;
+
+insert into dataset testds({'id': 1, 'fname': "name"});
+
+for $x in dataset('testds')
+return {$x.fname: "smith", lowercase("NAME"): "john"}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/records/open-open-fieldname-conflict_issue173.aql b/asterix-app/src/test/resources/runtimets/queries/records/open-open-fieldname-conflict_issue173.aql
new file mode 100644
index 0000000..225e596
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/records/open-open-fieldname-conflict_issue173.aql
@@ -0,0 +1,21 @@
+/*
+ * Description : Tests whether a conflict between two open field names are detected
+ * Expected Result: An error reporting that there is a duplicate field name "name"
+ * Author: zheilbron
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type opentype as open {
+fname1: string,
+fname2: string
+}
+
+create dataset testds(opentype) primary key fname1;
+
+insert into dataset testds({'fname1': "name", 'fname2': "name"});
+
+for $x in dataset('testds')
+return {$x.fname1: "john", $x.fname2: "smith"}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/constructor/int_01.adm b/asterix-app/src/test/resources/runtimets/results/constructor/int_01.adm
index fb52e3b..470d1f8 100644
--- a/asterix-app/src/test/resources/runtimets/results/constructor/int_01.adm
+++ b/asterix-app/src/test/resources/runtimets/results/constructor/int_01.adm
@@ -1 +1 @@
-{ "int8": 80i8, "int16": 160i16, "int32": 320, "int64": 640i64, "int8": -80i8, "int16": -160i16, "int32": -320, "int64": -640i64, "int64_min": -9223372036854775808i64 }
\ No newline at end of file
+{ "int8": 80i8, "int16": 160i16, "int32": 320, "int64": 640i64, "int8_2": -80i8, "int16_2": -160i16, "int32_2": -320, "int64_2": -640i64, "int64_min": -9223372036854775808i64 }
diff --git a/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses.adm b/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses.adm
index 87619a8..e78ad8f 100644
--- a/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses.adm
+++ b/asterix-app/src/test/resources/runtimets/results/cross-dataverse/join_across_dataverses.adm
@@ -1,3 +1,3 @@
-{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ], "orderList": {{ 10, 5 }} }
-{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 14.2326f, "orderList": [ 10, 775 ], "orderList": {{ 10, 775 }} }
-{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 97.20656f, "orderList": [ 1000, 775 ], "orderList": {{ 1000, 775 }} }
+{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ] }
+{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 14.2326f, "orderList": [ 10, 775 ] }
+{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 97.20656f, "orderList": [ 1000, 775 ] }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/join_q_01.adm b/asterix-app/src/test/resources/runtimets/results/custord/join_q_01.adm
index 7648e4a..e78ad8f 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/join_q_01.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/join_q_01.adm
@@ -1,3 +1,3 @@
-{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ], "orderList": {{ 10, 5 }} }
-{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 14.2326f, "orderList": [ 10, 775 ], "orderList": {{ 10, 775 }} }
-{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 97.20656f, "orderList": [ 1000, 775 ], "orderList": {{ 1000, 775 }} }
\ No newline at end of file
+{ "cust_name": "Jodi Alex", "cust_age": 19, "order_total": 7.206f, "orderList": [ 10, 5 ] }
+{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 14.2326f, "orderList": [ 10, 775 ] }
+{ "cust_name": "Jodi Rotruck", "cust_age": null, "order_total": 97.20656f, "orderList": [ 1000, 775 ] }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/order_q_03.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_03.adm
index 903c00d..4e02c4b 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_03.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_03.adm
@@ -1,4 +1,4 @@
-{ "orderid": 1000, "ordertot": 97.20656f, "list": [ "ORDER_DELIVERED", "Kathryne" ], "item1": "ORDER_DELIVERED", "item1": "ORDER_DELIVERED", "item2": "Kathryne", "item3": null }
-{ "orderid": 10, "ordertot": 7.206f, "list": [ "ORDER_DELIVERED", "ALEX" ], "item1": "ORDER_DELIVERED", "item1": "ORDER_DELIVERED", "item2": "ALEX", "item3": null }
-{ "orderid": 100, "ordertot": 124.26f, "list": [ "ORDER_DELIVERED", "YASSER" ], "item1": "ORDER_DELIVERED", "item1": "ORDER_DELIVERED", "item2": "YASSER", "item3": null }
-{ "orderid": 10, "ordertot": 14.2326f, "list": [ "ORDER_DELIVERED", "MIKE" ], "item1": "ORDER_DELIVERED", "item1": "ORDER_DELIVERED", "item2": "MIKE", "item3": null }
+{ "orderid": 1000, "ordertot": 97.20656f, "list": [ "ORDER_DELIVERED", "Kathryne" ], "item1": "ORDER_DELIVERED", "item2": "Kathryne", "item3": null }
+{ "orderid": 10, "ordertot": 7.206f, "list": [ "ORDER_DELIVERED", "ALEX" ], "item1": "ORDER_DELIVERED", "item2": "ALEX", "item3": null }
+{ "orderid": 100, "ordertot": 124.26f, "list": [ "ORDER_DELIVERED", "YASSER" ], "item1": "ORDER_DELIVERED", "item2": "YASSER", "item3": null }
+{ "orderid": 10, "ordertot": 14.2326f, "list": [ "ORDER_DELIVERED", "MIKE" ], "item1": "ORDER_DELIVERED", "item2": "MIKE", "item3": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/order_q_04.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_04.adm
index f22ea7f..3992f7d 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_04.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_04.adm
@@ -1,4 +1,4 @@
-{ "orderid": 1000, "ordertot": 97.20656f, "list": [ [ "1.0f", "yassser" ], [ 11, 14, "yasir", 1.6f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ "1.0f", "yassser" ], "item1": [ "1.0f", "yassser" ], "item2": [ 11, 14, "yasir", 1.6f ], "item5": null, "item10": null }
-{ "orderid": 10, "ordertot": 7.206f, "list": [ [ 1.0f, "5.2f", "60" ], [ 13231, "foo", null, 13.25d, 13.2f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.0f, "5.2f", "60" ], "item1": [ 1.0f, "5.2f", "60" ], "item2": [ 13231, "foo", null, 13.25d, 13.2f ], "item5": null, "item10": null }
-{ "orderid": 100, "ordertot": 124.26f, "list": [ [ 1.3f, 5.2f, "60", 12.32f ], [ 10, 2.0f, 3.0d, 40 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.3f, 5.2f, "60", 12.32f ], "item1": [ 1.3f, 5.2f, "60", 12.32f ], "item2": [ 10, 2.0f, 3.0d, 40 ], "item5": null, "item10": null }
-{ "orderid": 10, "ordertot": 14.2326f, "list": [ [ 2.4f, "15" ], [ 110 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), { "oid": 75, "total": 87.61863f } ], "item1": [ 2.4f, "15" ], "item1": [ 2.4f, "15" ], "item2": [ 110 ], "item5": { "oid": 75, "total": 87.61863f }, "item10": null }
+{ "orderid": 1000, "ordertot": 97.20656f, "list": [ [ "1.0f", "yassser" ], [ 11, 14, "yasir", 1.6f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ "1.0f", "yassser" ], "item2": [ 11, 14, "yasir", 1.6f ], "item5": null, "item10": null }
+{ "orderid": 10, "ordertot": 7.206f, "list": [ [ 1.0f, "5.2f", "60" ], [ 13231, "foo", null, 13.25d, 13.2f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.0f, "5.2f", "60" ], "item2": [ 13231, "foo", null, 13.25d, 13.2f ], "item5": null, "item10": null }
+{ "orderid": 100, "ordertot": 124.26f, "list": [ [ 1.3f, 5.2f, "60", 12.32f ], [ 10, 2.0f, 3.0d, 40 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.3f, 5.2f, "60", 12.32f ], "item2": [ 10, 2.0f, 3.0d, 40 ], "item5": null, "item10": null }
+{ "orderid": 10, "ordertot": 14.2326f, "list": [ [ 2.4f, "15" ], [ 110 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), { "oid": 75, "total": 87.61863f } ], "item1": [ 2.4f, "15" ], "item2": [ 110 ], "item5": { "oid": 75, "total": 87.61863f }, "item10": null }
diff --git a/asterix-app/src/test/resources/runtimets/results/custord/order_q_05.adm b/asterix-app/src/test/resources/runtimets/results/custord/order_q_05.adm
index dd3420e..4d8b37c 100644
--- a/asterix-app/src/test/resources/runtimets/results/custord/order_q_05.adm
+++ b/asterix-app/src/test/resources/runtimets/results/custord/order_q_05.adm
@@ -1,4 +1,4 @@
-{ "orderid": 1000, "ordertot": 97.20656f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 10, "ordertot": 7.206f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 100, "ordertot": 124.26f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 10, "ordertot": 14.2326f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 1000, "ordertot": 97.20656f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 10, "ordertot": 7.206f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 100, "ordertot": 124.26f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 10, "ordertot": 14.2326f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 6956e4b..de694cd 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -2626,6 +2626,24 @@
<output-file compare="Text">open-record-constructor_02.adm</output-file>
</compilation-unit>
</test-case>
+ <test-case FilePath="records">
+ <compilation-unit name="closed-closed-fieldname-conflict_issue173">
+ <output-file compare="Text">closed-closed-fieldname-conflict_issue173.adm</output-file>
+ <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="records">
+ <compilation-unit name="open-closed-fieldname-conflict_issue173">
+ <output-file compare="Text">open-closed-fieldname-conflict_issue173.adm</output-file>
+ <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="records">
+ <compilation-unit name="open-open-fieldname-conflict_issue173">
+ <output-file compare="Text">open-open-fieldname-conflict_issue173.adm</output-file>
+ <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+ </compilation-unit>
+ </test-case>
</test-group>
<test-group name="scan">
<test-case FilePath="scan">
diff --git a/asterix-aql/pom.xml b/asterix-aql/pom.xml
index 7ac2cbb..7617582 100644
--- a/asterix-aql/pom.xml
+++ b/asterix-aql/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>asterix</artifactId>
@@ -13,8 +14,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
<plugin>
@@ -36,14 +37,15 @@
<goals>
<goal>jjdoc</goal>
</goals>
- <phase>process-sources</phase>
+ <phase>process-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
diff --git a/asterix-common/pom.xml b/asterix-common/pom.xml
index ee81e75..0994109 100644
--- a/asterix-common/pom.xml
+++ b/asterix-common/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>asterix</artifactId>
@@ -15,8 +16,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
</plugins>
diff --git a/asterix-external-data/pom.xml b/asterix-external-data/pom.xml
index 3076323..337da7f 100644
--- a/asterix-external-data/pom.xml
+++ b/asterix-external-data/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>asterix</artifactId>
@@ -14,8 +15,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
<plugin>
@@ -50,14 +51,12 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
- <!--
- doesn't work from m2eclipse, currently
- <additionalClasspathElements>
- <additionalClasspathElement>${basedir}/src/main/resources</additionalClasspathElement>
- </additionalClasspathElements>
- -->
+ <!-- doesn't work from m2eclipse, currently <additionalClasspathElements>
+ <additionalClasspathElement>${basedir}/src/main/resources</additionalClasspathElement>
+ </additionalClasspathElements> -->
<forkMode>pertest</forkMode>
- <argLine>-enableassertions -Xmx${test.heap.size}m -Dfile.encoding=UTF-8
+ <argLine>-enableassertions -Xmx${test.heap.size}m
+ -Dfile.encoding=UTF-8
-Djava.util.logging.config.file=src/test/resources/logging.properties</argLine>
<includes>
<include>**/*TestSuite.java</include>
@@ -102,39 +101,39 @@
<version>1.3.1-201002241208</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.twitter4j</groupId>
- <artifactId>twitter4j-core</artifactId>
- <version>2.2.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-core</artifactId>
- <version>0.20.2</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>net.java.dev.rome</groupId>
- <artifactId>rome-fetcher</artifactId>
- <version>1.0.0</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>rome</groupId>
- <artifactId>rome</artifactId>
- <version>1.0.1-modified-01</version>
- </dependency>
- <dependency>
- <groupId>edu.uci.ics.hyracks</groupId>
- <artifactId>hyracks-dataflow-hadoop</artifactId>
- </dependency>
-<dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>1.0</version>
- </dependency>
+ <dependency>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-core</artifactId>
+ <version>2.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-core</artifactId>
+ <version>0.20.2</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.java.dev.rome</groupId>
+ <artifactId>rome-fetcher</artifactId>
+ <version>1.0.0</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <version>1.0.1-modified-01</version>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.hyracks</groupId>
+ <artifactId>hyracks-dataflow-hadoop</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ </dependency>
</dependencies>
</project>
diff --git a/asterix-hyracks-glue/pom.xml b/asterix-hyracks-glue/pom.xml
index 5f991a4..1a18d1c 100644
--- a/asterix-hyracks-glue/pom.xml
+++ b/asterix-hyracks-glue/pom.xml
@@ -1,51 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>asterix</artifactId>
- <groupId>edu.uci.ics.asterix</groupId>
- <version>0.0.4-SNAPSHOT</version>
- </parent>
- <groupId>edu.uci.ics.asterix</groupId>
- <artifactId>asterix-hyracks-glue</artifactId>
- <version>0.0.4-SNAPSHOT</version>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <name>asterix-hyracks-glue</name>
- <url>http://maven.apache.org</url>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>edu.uci.ics.asterix</groupId>
- <artifactId>asterix-transactions</artifactId>
- <version>0.0.4-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>edu.uci.ics.asterix</groupId>
- <artifactId>asterix-common</artifactId>
- <version>0.0.4-SNAPSHOT</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>asterix</artifactId>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <version>0.0.4-SNAPSHOT</version>
+ </parent>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-hyracks-glue</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <name>asterix-hyracks-glue</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-transactions</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-common</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
</project>
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/Asterix_ADM_Parser.md b/asterix-maven-plugins/lexer-generator-maven-plugin/Asterix_ADM_Parser.md
new file mode 100644
index 0000000..eeaffc9
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/Asterix_ADM_Parser.md
@@ -0,0 +1,53 @@
+The Asterix ADM Parser
+======================
+
+The ADM parser inside Asterix is composed by two different components:
+
+* **The Parser** AdmTupleParser, which converts the adm tokens in internal objects
+* **The Lexer** AdmLexer, which scans the adm file and returns a list of adm tokens
+
+These two classes belong to the package:
+
+ edu.uci.ics.asterix.runtime.operators.file
+
+The Parser is loaded through a factory (*AdmSchemafullRecordParserFactory*) by
+
+ edu.uci.ics.asterix.external.dataset.adapter.FileSystemBasedAdapter extends AbstractDatasourceAdapter
+
+
+How to add a new datatype
+-------------------------
+The ADM format allows two different kinds of datatype:
+
+* primitive
+* with constructor
+
+A primitive datatype allows to write the actual value of the field without extra markup:
+
+ { name : "Diego", age : 23 }
+
+while the datatypes with constructor require to specify first the type of the value and then a string with the serialized value
+
+ { center : point3d("P2.1,3,8.5") }
+
+In order to add a new datatype the steps are:
+
+1. Add the new token to the **Lexer**
+ * **if the datatype is primite** is necessary to create a TOKEN able to recognize **the format of the value**
+ * **if the datatype is with constructor** is necessary to create **only** a TOKEN able to recognize **the name of the constructor**
+
+2. Change the **Parser** in order to convert correctly the new token in internal objects
+ * This will require to **add new cases to the switch-case statements** and the introduction of **a serializer/deserializer object** for that datatype.
+
+
+The Lexer
+----------
+To add new datatype or change the tokens definition you have to change ONLY the file adm.grammar located in
+ asterix-runtime/src/main/resources/adm.grammar
+The lexer will be generated from that definition file during each maven building.
+
+The maven configuration in located in asterix-runtime/pom.xml
+
+
+> Author: Diego Giorgini - diegogiorgini@gmail.com
+> 6 December 2012
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/README.md b/asterix-maven-plugins/lexer-generator-maven-plugin/README.md
new file mode 100644
index 0000000..b3632e6
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/README.md
@@ -0,0 +1,111 @@
+Lexer Generator
+===============
+
+This tool automate the creation of Hand-Coded-Like Lexers.
+It was created to address the performance issues of other (more advanced) lexer generators like JavaCC that arise when you need to scan TB of data. In particular it is *~20x faster* than javacc and typically can parse the data from a normal harddisk at *more than 70MBs*.
+
+
+Maven Plugin (to put inside pom.xml)
+-------------------------------------
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>lexer-generator-maven-plugin</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ <configuration>
+ <grammarFile>src/main/java/edu/uci/ics/asterix/runtime/operators/file/adm/adm.grammar</grammarFile>
+ <outputDir>${project.build.directory}/generated-sources</outputDir>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-lexer</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate-lexer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+Command line
+-------------
+ LexerGenerator\nusage: java LexerGenerator <configuration file>
+
+
+
+What means Hand-Coded-Like and why it is so fast
+------------------------------------------------
+The most of the Lexers use a Finite State Machine encoded in data structure called [State Transition Table](http://en.wikipedia.org/wiki/State_transition_table).
+While elegant and practical this approach require some extra controls and operations to deal with the data structure at runtime. A different approach consists in encoding the State Machine as actual code, in this way all the operations done are limited to the minumum amount needed to parse our grammar.
+A common problem with this kind of hard-hand-coded lexers is that is almost impossible to do manutency and changes, this is the reason of this Lexer Generator able to produce a Hand-Coded-Like lexer starting from a grammar specification.
+
+Another big difference with the most of the LexerGenerator (expecially the ones for Java) is that since it is optimized for performance we **don't return objects** and we **use the minimum possible of objects internally**.
+This actually is the main reason of the ~20x when compared with javacc.
+
+
+Configuration File
+------------------
+Is a simple *key: value* configuration file plus the *specification of your grammar*.
+The four configuration keys are listed below:
+
+ # LEXER GENERATOR configuration file
+ # ---------------------------------------
+ # Place *first* the generic configuration
+ # then list your grammar.
+
+ PACKAGE: edu.uci.ics.asterix.admfast.parser
+ LEXER_NAME: AdmLexer
+ OUTPUT_DIR: output/
+
+
+Specify The Grammar
+-------------------
+Your grammar has to be listed in the configuration file after the *TOKENS:* keyword.
+
+ TOKENS:
+
+ BOOLEAN_LIT = string(boolean)
+ COMMA = char(\,)
+ COLON = char(:)
+ STRING_LITERAL = char("), anythingUntil(")
+ INT_LITERAL = signOrNothing(), digitSequence()
+ INT8_LITERAL = token(INT_LITERAL), string(i8)
+ @EXPONENT = caseInsensitiveChar(e), signOrNothing(), digitSequence()
+ DOUBLE_LITERAL = signOrNothing(), digitSequence(), char(.), digitSequence(), token(@EXPONENT)
+ DOUBLE_LITERAL = signOrNothing(), digitSequence(), token(@EXPONENT)
+
+Each token is composed by a **name** and a sequence of **rules**.
+Each rule is then written with the format: **constructor(parameter)**
+the list of the rules available is coded inside *NodeChainFactory.java*
+
+You can write more than a sequence of rules just addind more another line and repeating the token name.
+
+You can reuse the rules of a token inside another one with the special rule: **token(** *TOKEN_NAME* **)**
+
+Lastly you can define *auxiliary* token definitions that will not be encoded in the final lexer (but that can be useful inside other token definitions) just **startig the token name with @**.
+
+**Attention:** please pay attention to not write rules that once merged int the state machine would lead to a *conflict between transaction* like a transaction for a generic digit and one for a the digit 0 from the same node.
+
+The result: MyLexer
+-------------------
+The result of the execution of the LexerGenerator is the creation of the Lexer inside the directory *components**.
+The lexer is extremly easy and minimal and can be used likewise an Iterator:
+
+ MyLexer myLexer = new MyLexer(new FileReader(file)));
+ while((token = MyLexer.next()) != MyLexer.TOKEN_EOF){
+ System.out.println(MyLexer.tokenKindToString(token));
+ }
+
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml b/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml
new file mode 100644
index 0000000..524727f
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml
@@ -0,0 +1,36 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>lexer-generator-maven-plugin</artifactId>
+ <version>0.1</version>
+ <packaging>maven-plugin</packaging>
+ <name>lexer-generator-maven-plugin</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGenerator.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGenerator.java
new file mode 100644
index 0000000..512f3d0
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGenerator.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.Reader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.apache.maven.plugin.logging.Log;
+
+public class LexerGenerator {
+ private LinkedHashMap<String, Token> tokens = new LinkedHashMap<String, Token>();
+ private Log logger;
+
+ public LexerGenerator() {
+ }
+
+ public LexerGenerator(Log logger) {
+ this.logger = logger;
+ }
+
+ private void log(String info) {
+ if (logger == null) {
+ System.out.println(info);
+ } else {
+ logger.info(info);
+ }
+ }
+
+ public void addToken(String rule) throws Exception {
+ Token newToken;
+ if (rule.charAt(0) == '@') {
+ newToken = new TokenAux(rule, tokens);
+ } else {
+ newToken = new Token(rule, tokens);
+ }
+ Token existingToken = tokens.get(newToken.getName());
+ if (existingToken == null) {
+ tokens.put(newToken.getName(), newToken);
+ } else {
+ existingToken.merge(newToken);
+ }
+ }
+
+ public void generateLexer(HashMap<String, String> config) throws Exception {
+ LexerNode main = this.compile();
+ config.put("TOKENS_CONSTANTS", this.tokensConstants());
+ config.put("TOKENS_IMAGES", this.tokensImages());
+ config.put("LEXER_LOGIC", main.toJava());
+ config.put("LEXER_AUXFUNCTIONS", replaceParams(this.auxiliaryFunctions(main), config));
+ String[] files = { "/Lexer.java", "/LexerException.java" };
+ String outputDir = config.get("OUTPUT_DIR");
+ (new File(outputDir)).mkdirs();
+ for (String file : files) {
+ String input = readFile(LexerGenerator.class.getResourceAsStream(file));
+ String fileOut = file.replace("Lexer", config.get("LEXER_NAME"));
+ String output = replaceParams(input, config);
+ log("Generating: " + file + "\t>>\t" + fileOut);
+ FileWriter out = new FileWriter((new File(outputDir, fileOut)).toString());
+ out.write(output);
+ out.close();
+ log(" [done]\n");
+ }
+ }
+
+ public String printParsedGrammar() {
+ StringBuilder result = new StringBuilder();
+ for (Token token : tokens.values()) {
+ result.append(token.toString()).append("\n");
+ }
+ return result.toString();
+ }
+
+ private LexerNode compile() throws Exception {
+ LexerNode main = new LexerNode();
+ for (Token token : tokens.values()) {
+ if (token instanceof TokenAux)
+ continue;
+ main.merge(token.getNode());
+ }
+ return main;
+ }
+
+ private String tokensImages() {
+ StringBuilder result = new StringBuilder();
+ Set<String> uniqueTokens = tokens.keySet();
+ for (String token : uniqueTokens) {
+ result.append(", \"<").append(token).append(">\" ");
+ }
+ return result.toString();
+ }
+
+ private String tokensConstants() {
+ StringBuilder result = new StringBuilder();
+ Set<String> uniqueTokens = tokens.keySet();
+ int i = 2;
+ for (String token : uniqueTokens) {
+ result.append(", TOKEN_").append(token).append("=").append(i).append(" ");
+ i++;
+ }
+ return result.toString();
+ }
+
+ private String auxiliaryFunctions(LexerNode main) {
+ StringBuilder result = new StringBuilder();
+ Set<String> functions = main.neededAuxFunctions();
+ for (String token : functions) {
+ result.append("private int parse_" + token
+ + "(char currentChar) throws IOException, [LEXER_NAME]Exception{\n");
+ result.append(tokens.get(token).getNode().toJavaAuxFunction());
+ result.append("\n}\n\n");
+ }
+ return result.toString();
+ }
+
+ private static String readFile(Reader input) throws FileNotFoundException, IOException {
+ StringBuffer fileData = new StringBuffer(1000);
+ BufferedReader reader = new BufferedReader(input);
+ char[] buf = new char[1024];
+ int numRead = 0;
+ while ((numRead = reader.read(buf)) != -1) {
+ String readData = String.valueOf(buf, 0, numRead);
+ fileData.append(readData);
+ buf = new char[1024];
+ }
+ reader.close();
+ return fileData.toString();
+ }
+
+ private static String readFile(InputStream input) throws FileNotFoundException, IOException {
+ if (input == null) {
+ throw new FileNotFoundException();
+ }
+ return readFile(new InputStreamReader(input));
+ }
+
+ private static String readFile(String fileName) throws FileNotFoundException, IOException {
+ return readFile(new FileReader(fileName));
+ }
+
+ private static String replaceParams(String input, HashMap<String, String> config) {
+ for (Entry<String, String> param : config.entrySet()) {
+ String key = "\\[" + param.getKey() + "\\]";
+ String value = param.getValue();
+ input = input.replaceAll(key, value);
+ }
+ return input;
+ }
+
+ public static void main(String args[]) throws Exception {
+ if (args.length == 0 || args[0] == "--help" || args[0] == "-h") {
+ System.out.println("LexerGenerator\nusage: java LexerGenerator <configuration file>");
+ return;
+ }
+
+ LexerGenerator lexer = new LexerGenerator();
+ HashMap<String, String> config = new HashMap<String, String>();
+
+ System.out.println("Config file:\t" + args[0]);
+ String input = readFile(args[0]);
+ boolean tokens = false;
+ for (String line : input.split("\r?\n")) {
+ line = line.trim();
+ if (line.length() == 0 || line.charAt(0) == '#')
+ continue;
+ if (tokens == false && !line.equals("TOKENS:")) {
+ config.put(line.split("\\s*:\\s*")[0], line.split("\\s*:\\s*")[1]);
+ } else if (line.equals("TOKENS:")) {
+ tokens = true;
+ } else {
+ lexer.addToken(line);
+ }
+ }
+
+ String parsedGrammar = lexer.printParsedGrammar();
+ lexer.generateLexer(config);
+ System.out.println("\nGenerated grammar:");
+ System.out.println(parsedGrammar);
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGeneratorMojo.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGeneratorMojo.java
new file mode 100644
index 0000000..11ee1d5
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerGeneratorMojo.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator;
+
+import edu.uci.ics.asterix.lexergenerator.LexerGenerator;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashMap;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+
+/**
+ * @goal generate-lexer
+ * @phase generate-sources
+ * @requiresDependencyResolution compile
+ */
+public class LexerGeneratorMojo extends AbstractMojo {
+ /**
+ * parameter injected from pom.xml
+ *
+ * @parameter
+ * @required
+ */
+ private File grammarFile;
+
+ /**
+ * parameter injected from pom.xml
+ *
+ * @parameter
+ * @required
+ */
+ private File outputDir;
+
+ public void execute() throws MojoExecutionException {
+ LexerGenerator lexer = new LexerGenerator(getLog());
+ HashMap<String, String> config = new HashMap<String, String>();
+ getLog().info("--- Lexer Generator Maven Plugin - started with grammarFile: " + grammarFile.toString());
+ try {
+ String input = readFile(grammarFile);
+ config.put("OUTPUT_DIR", outputDir.toString());
+ boolean tokens = false;
+ for (String line : input.split("\r?\n")) {
+ line = line.trim();
+ if (line.length() == 0 || line.charAt(0) == '#')
+ continue;
+ if (tokens == false && !line.equals("TOKENS:")) {
+ config.put(line.split("\\s*:\\s*")[0], line.split("\\s*:\\s*")[1]);
+ } else if (line.equals("TOKENS:")) {
+ tokens = true;
+ } else {
+ lexer.addToken(line);
+ }
+ }
+ lexer.generateLexer(config);
+ } catch (Throwable e) {
+ throw new MojoExecutionException("Error while generating lexer", e);
+ }
+ String parsedGrammar = lexer.printParsedGrammar();
+ getLog().info("--- Generated grammar:\n" + parsedGrammar);
+ }
+
+ private String readFile(File file) throws FileNotFoundException, IOException {
+ StringBuffer fileData = new StringBuffer(1000);
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ char[] buf = new char[1024];
+ int numRead = 0;
+ while ((numRead = reader.read(buf)) != -1) {
+ String readData = String.valueOf(buf, 0, numRead);
+ fileData.append(readData);
+ buf = new char[1024];
+ }
+ reader.close();
+ return fileData.toString();
+ }
+
+}
\ No newline at end of file
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerNode.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerNode.java
new file mode 100644
index 0000000..7b8d059
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/LexerNode.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import edu.uci.ics.asterix.lexergenerator.rules.*;
+
+public class LexerNode {
+ private static String TOKEN_PREFIX = "TOKEN_";
+ private LinkedHashMap<Rule, LexerNode> actions = new LinkedHashMap<Rule, LexerNode>();
+ private String finalTokenName;
+ private Set<String> ongoingParsing = new HashSet<String>();
+
+ public LexerNode clone() {
+ LexerNode node = new LexerNode();
+ node.finalTokenName = this.finalTokenName;
+ for (Map.Entry<Rule, LexerNode> entry : this.actions.entrySet()) {
+ node.actions.put(entry.getKey().clone(), entry.getValue().clone());
+ }
+ for (String ongoing : this.ongoingParsing) {
+ node.ongoingParsing.add(ongoing);
+ }
+ return node;
+ }
+
+ public void add(Rule newRule) {
+ if (actions.get(newRule) == null) {
+ actions.put(newRule, new LexerNode());
+ }
+ }
+
+ public void append(Rule newRule) {
+ if (actions.size() == 0) {
+ add(newRule);
+ } else {
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ action.getValue().append(newRule);
+ }
+ if (actions.containsKey(new RuleEpsilon())) {
+ actions.remove(new RuleEpsilon());
+ add(newRule);
+ }
+ }
+ }
+
+ public void merge(LexerNode newNode) throws Exception {
+ for (Map.Entry<Rule, LexerNode> action : newNode.actions.entrySet()) {
+ if (this.actions.get(action.getKey()) == null) {
+ this.actions.put(action.getKey(), action.getValue());
+ } else {
+ this.actions.get(action.getKey()).merge(action.getValue());
+ }
+ }
+ if (newNode.finalTokenName != null) {
+ if (this.finalTokenName == null) {
+ this.finalTokenName = newNode.finalTokenName;
+ } else {
+ throw new Exception("Rule conflict between: " + this.finalTokenName + " and " + newNode.finalTokenName);
+ }
+ }
+ for (String ongoing : newNode.ongoingParsing) {
+ this.ongoingParsing.add(ongoing);
+ }
+ }
+
+ public void append(LexerNode node) throws Exception {
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ if (action.getKey() instanceof RuleEpsilon)
+ continue;
+ action.getValue().append(node);
+ }
+ if (actions.containsKey(new RuleEpsilon())) {
+ actions.remove(new RuleEpsilon());
+ merge(node.clone());
+ }
+ if (actions.size() == 0 || finalTokenName != null) {
+ finalTokenName = null;
+ merge(node.clone());
+ }
+ }
+
+ public void appendTokenName(String name) {
+ if (actions.size() == 0) {
+ this.finalTokenName = name;
+ } else {
+ ongoingParsing.add(TOKEN_PREFIX + name);
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ action.getValue().appendTokenName(name);
+ }
+ }
+ }
+
+ public LexerNode removeTokensName() {
+ this.finalTokenName = null;
+ this.ongoingParsing.clear();
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ action.getValue().removeTokensName();
+ }
+ return this;
+ }
+
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+ if (finalTokenName != null)
+ result.append("! ");
+ if (actions.size() == 1)
+ result.append(actions.keySet().toArray()[0].toString() + actions.values().toArray()[0].toString());
+ if (actions.size() > 1) {
+ result.append(" ( ");
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ if (result.length() != 3) {
+ result.append(" || ");
+ }
+ result.append(action.getKey().toString());
+ result.append(action.getValue().toString());
+ }
+ result.append(" ) ");
+ }
+ return result.toString();
+ }
+
+ public String toJava() {
+ StringBuffer result = new StringBuffer();
+ if (numberOfRuleChar() > 2) {
+ result.append(toJavaSingleCharRules());
+ result.append(toJavaComplexRules(false));
+ } else {
+ result.append(toJavaComplexRules(true));
+ }
+ if (this.finalTokenName != null) {
+ result.append("return " + TOKEN_PREFIX + finalTokenName + ";\n");
+ } else if (ongoingParsing != null) {
+ String ongoingParsingArgs = collectionJoin(ongoingParsing, ',');
+ result.append("return parseError(" + ongoingParsingArgs + ");\n");
+ }
+ return result.toString();
+ }
+
+ private int numberOfRuleChar() {
+ int singleCharRules = 0;
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ if (action.getKey() instanceof RuleChar)
+ singleCharRules++;
+ }
+ return singleCharRules;
+ }
+
+ private String toJavaSingleCharRules() {
+ StringBuffer result = new StringBuffer();
+ result.append("switch(currentChar){\n");
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ if (action.getKey() instanceof RuleChar) {
+ RuleChar rule = (RuleChar) action.getKey();
+ result.append("case '" + rule.expectedChar() + "':\n");
+ result.append(rule.javaAction()).append("\n");
+ result.append(action.getValue().toJava());
+ }
+ }
+ result.append("}\n");
+ return result.toString();
+ }
+
+ private String toJavaComplexRules(boolean all) {
+ StringBuffer result = new StringBuffer();
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ if (!all && action.getKey() instanceof RuleChar)
+ continue;
+ if (action.getKey() instanceof RuleEpsilon)
+ continue;
+ String act = action.getKey().javaAction();
+ if (act.length() > 0) {
+ act = "\n" + act;
+ }
+ result.append(action.getKey().javaMatch(act + "\n" + action.getValue().toJava()));
+ }
+ return result.toString();
+ }
+
+ public void expandFirstAction(LinkedHashMap<String, Token> tokens) throws Exception {
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ Rule first = action.getKey();
+ if (first instanceof RulePartial) {
+ if (tokens.get(((RulePartial) first).getPartial()) == null) {
+ throw new Exception("Cannot find a token used as part of another definition, missing token: "
+ + ((RulePartial) first).getPartial());
+ }
+ actions.remove(first);
+ LexerNode node = tokens.get(((RulePartial) first).getPartial()).getNode().clone();
+ merge(node);
+ }
+ }
+ }
+
+ public Set<String> neededAuxFunctions() {
+ HashSet<String> partials = new HashSet<String>();
+ for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
+ Rule rule = action.getKey();
+ if (rule instanceof RulePartial) {
+ partials.add(((RulePartial) rule).getPartial());
+ }
+ partials.addAll(action.getValue().neededAuxFunctions());
+ }
+ return partials;
+ }
+
+ public String toJavaAuxFunction() {
+ String oldFinalTokenName = finalTokenName;
+ if (oldFinalTokenName == null)
+ finalTokenName = "AUX_NOT_FOUND";
+ String result = toJava();
+ finalTokenName = oldFinalTokenName;
+ return result;
+ }
+
+ private String collectionJoin(Collection<String> collection, char c) {
+ StringBuilder ongoingParsingArgs = new StringBuilder();
+ for (String token : collection) {
+ ongoingParsingArgs.append(token);
+ ongoingParsingArgs.append(c);
+ }
+ if (ongoingParsing.size() > 0) {
+ ongoingParsingArgs.deleteCharAt(ongoingParsingArgs.length() - 1);
+ }
+ return ongoingParsingArgs.toString();
+ }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/NodeChainFactory.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/NodeChainFactory.java
new file mode 100644
index 0000000..941f822
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/NodeChainFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator;
+
+import java.util.HashMap;
+
+import edu.uci.ics.asterix.lexergenerator.rulegenerators.*;
+
+public class NodeChainFactory {
+ static private HashMap<String, RuleGenerator> ruleGenerators = new HashMap<String, RuleGenerator>();
+
+ static {
+ ruleGenerators.put("char", new RuleGeneratorChar());
+ ruleGenerators.put("string", new RuleGeneratorString());
+ ruleGenerators.put("anythingUntil", new RuleGeneratorAnythingUntil());
+ ruleGenerators.put("signOrNothing", new RuleGeneratorSignOrNothing());
+ ruleGenerators.put("sign", new RuleGeneratorSign());
+ ruleGenerators.put("digitSequence", new RuleGeneratorDigitSequence());
+ ruleGenerators.put("caseInsensitiveChar", new RuleGeneratorCaseInsensitiveChar());
+ ruleGenerators.put("charOrNothing", new RuleGeneratorCharOrNothing());
+ ruleGenerators.put("token", new RuleGeneratorToken());
+ ruleGenerators.put("nothing", new RuleGeneratorNothing());
+ }
+
+ public static LexerNode create(String generator, String constructor) throws Exception {
+ constructor = constructor.replace("@", "aux_");
+ if (ruleGenerators.get(generator) == null)
+ throw new Exception("Rule Generator not found for '" + generator + "'");
+ return ruleGenerators.get(generator).generate(constructor);
+ }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/Token.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/Token.java
new file mode 100644
index 0000000..bb122c2
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/Token.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator;
+
+import java.util.LinkedHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Token {
+ private String userDescription;
+ private String name;
+ private LexerNode node;
+
+ public Token(String str, LinkedHashMap<String, Token> tokens) throws Exception {
+ userDescription = str;
+ node = new LexerNode();
+ parse(userDescription, tokens);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public LexerNode getNode() {
+ return node;
+ }
+
+ public String toString() {
+ return this.name + " => " + getNode().toString();
+ }
+
+ public void merge(Token newToken) throws Exception {
+ node.merge(newToken.getNode());
+ }
+
+ private void parse(String str, LinkedHashMap<String, Token> tokens) throws Exception {
+ Pattern p = Pattern.compile("^(@?\\w+)\\s*=\\s*(.+)");
+ Matcher m = p.matcher(str);
+ if (!m.find())
+ throw new Exception("Token definition not correct: " + str);
+ this.name = m.group(1).replaceAll("@", "aux_");
+ String[] textRules = m.group(2).split("(?<!\\\\),\\s*");
+ for (String textRule : textRules) {
+ Pattern pRule = Pattern.compile("^(\\w+)(\\((.*)\\))?");
+ Matcher mRule = pRule.matcher(textRule);
+ mRule.find();
+ String generator = mRule.group(1);
+ String constructor = mRule.group(3);
+ if (constructor == null)
+ throw new Exception("Error in rule format: " + "\n " + str + " = " + generator + " : " + constructor);
+ constructor = constructor.replace("\\", "");
+ node.append(NodeChainFactory.create(generator, constructor));
+ node.expandFirstAction(tokens);
+ }
+ node.appendTokenName(name);
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/TokenAux.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/TokenAux.java
new file mode 100644
index 0000000..a9c7ffc
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/TokenAux.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator;
+
+import java.util.LinkedHashMap;
+
+public class TokenAux extends Token {
+
+ public TokenAux(String str, LinkedHashMap<String, Token> tokens) throws Exception {
+ super(str, tokens);
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGenerator.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGenerator.java
new file mode 100644
index 0000000..3733746
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGenerator.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+
+public interface RuleGenerator {
+ public LexerNode generate(String input) throws Exception;
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorAnythingUntil.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorAnythingUntil.java
new file mode 100644
index 0000000..b14eb3e
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorAnythingUntil.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleAnythingUntil;
+
+public class RuleGeneratorAnythingUntil implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ LexerNode result = new LexerNode();
+ if (input == null || input.length() != 1)
+ throw new Exception("Wrong rule format for generator anythingExcept: " + input);
+ result.append(new RuleAnythingUntil(input.charAt(0)));
+ return result;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCaseInsensitiveChar.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCaseInsensitiveChar.java
new file mode 100644
index 0000000..b789f59
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCaseInsensitiveChar.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class RuleGeneratorCaseInsensitiveChar implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ LexerNode result = new LexerNode();
+ if (input == null || input.length() != 1)
+ throw new Exception("Wrong rule format for generator char: " + input);
+ char cl = Character.toLowerCase(input.charAt(0));
+ char cu = Character.toUpperCase(cl);
+ result.add(new RuleChar(cl));
+ result.add(new RuleChar(cu));
+ return result;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorChar.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorChar.java
new file mode 100644
index 0000000..0b830e6
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorChar.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class RuleGeneratorChar implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ LexerNode result = new LexerNode();
+ if (input == null || input.length() != 1)
+ throw new Exception("Wrong rule format for generator char: " + input);
+ result.append(new RuleChar(input.charAt(0)));
+ return result;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCharOrNothing.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCharOrNothing.java
new file mode 100644
index 0000000..d01ff7d
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorCharOrNothing.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+
+public class RuleGeneratorCharOrNothing implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ LexerNode result = new LexerNode();
+ if (input == null || input.length() != 1)
+ throw new Exception("Wrong rule format for generator charOrNothing: " + input);
+ result.add(new RuleChar(input.charAt(0)));
+ result.add(new RuleEpsilon());
+ return result;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorDigitSequence.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorDigitSequence.java
new file mode 100644
index 0000000..d067ee7
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorDigitSequence.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleDigitSequence;
+
+public class RuleGeneratorDigitSequence implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ LexerNode result = new LexerNode();
+ result.append(new RuleDigitSequence());
+ return result;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorNothing.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorNothing.java
new file mode 100644
index 0000000..fec06a1
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorNothing.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+
+public class RuleGeneratorNothing implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ LexerNode node = new LexerNode();
+ node.add(new RuleEpsilon());
+ return node;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSign.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSign.java
new file mode 100644
index 0000000..0160f09
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSign.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class RuleGeneratorSign implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ LexerNode result = new LexerNode();
+ result.add(new RuleChar('+'));
+ result.add(new RuleChar('-'));
+ return result;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSignOrNothing.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSignOrNothing.java
new file mode 100644
index 0000000..7c4297d
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorSignOrNothing.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+
+public class RuleGeneratorSignOrNothing implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ LexerNode result = new LexerNode();
+ result.add(new RuleChar('+'));
+ result.add(new RuleChar('-'));
+ result.add(new RuleEpsilon());
+ return result;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorString.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorString.java
new file mode 100644
index 0000000..eb0471b
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorString.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class RuleGeneratorString implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) {
+ LexerNode result = new LexerNode();
+ if (input == null)
+ return result;
+ for (int i = 0; i < input.length(); i++) {
+ result.append(new RuleChar(input.charAt(i)));
+ }
+ return result;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorToken.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorToken.java
new file mode 100644
index 0000000..b4c23d8
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rulegenerators/RuleGeneratorToken.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rulegenerators;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RulePartial;
+
+public class RuleGeneratorToken implements RuleGenerator {
+
+ @Override
+ public LexerNode generate(String input) throws Exception {
+ if (input == null || input.length() == 0)
+ throw new Exception("Wrong rule format for generator token : " + input);
+ LexerNode node = new LexerNode();
+ node.add(new RulePartial(input));
+ return node;
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/Rule.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/Rule.java
new file mode 100644
index 0000000..01cd1d5
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/Rule.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rules;
+
+public interface Rule {
+ public int hashCode();
+
+ public boolean equals(Object o);
+
+ public String toString();
+
+ public String javaAction();
+
+ public String javaMatch(String action);
+
+ public Rule clone();
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleAnythingUntil.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleAnythingUntil.java
new file mode 100644
index 0000000..8d45835
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleAnythingUntil.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rules;
+
+public class RuleAnythingUntil implements Rule {
+
+ private char expected;
+
+ public RuleAnythingUntil clone() {
+ return new RuleAnythingUntil(expected);
+ }
+
+ public RuleAnythingUntil(char expected) {
+ this.expected = expected;
+ }
+
+ @Override
+ public String toString() {
+ return " .* " + String.valueOf(expected);
+ }
+
+ @Override
+ public int hashCode() {
+ return 10 * (int) expected;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null)
+ return false;
+ if (o instanceof RuleAnythingUntil) {
+ if (((RuleAnythingUntil) o).expected == this.expected) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String javaAction() {
+ return "currentChar = readNextChar();";
+ }
+
+ @Override
+ public String javaMatch(String action) {
+ StringBuilder result = new StringBuilder();
+ result.append("boolean escaped = false;");
+ result.append("while (currentChar!='").append(expected).append("' || escaped)");
+ result.append("{\nif(!escaped && currentChar=='\\\\\\\\'){escaped=true;}\nelse {escaped=false;}\ncurrentChar = readNextChar();\n}");
+ result.append("\nif (currentChar=='").append(expected).append("'){");
+ result.append(action);
+ result.append("}\n");
+ return result.toString();
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleChar.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleChar.java
new file mode 100644
index 0000000..0e53374
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleChar.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rules;
+
+public class RuleChar implements Rule {
+
+ private char expected;
+
+ public RuleChar clone() {
+ return new RuleChar(expected);
+ }
+
+ public RuleChar(char expected) {
+ this.expected = expected;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(expected);
+ }
+
+ public char expectedChar() {
+ return expected;
+ }
+
+ @Override
+ public int hashCode() {
+ return (int) expected;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null)
+ return false;
+ if (o instanceof RuleChar) {
+ if (((RuleChar) o).expected == this.expected) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String javaAction() {
+ return "currentChar = readNextChar();";
+ }
+
+ @Override
+ public String javaMatch(String action) {
+ StringBuilder result = new StringBuilder();
+ result.append("if (currentChar=='");
+ result.append(expected);
+ result.append("'){");
+ result.append(action);
+ result.append("}");
+ return result.toString();
+ }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleDigitSequence.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleDigitSequence.java
new file mode 100644
index 0000000..13381e0
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleDigitSequence.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rules;
+
+public class RuleDigitSequence implements Rule {
+
+ public RuleDigitSequence clone() {
+ return new RuleDigitSequence();
+ }
+
+ @Override
+ public String toString() {
+ return " [0-9]+ ";
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null)
+ return false;
+ if (o instanceof RuleDigitSequence) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String javaAction() {
+ return "";
+ }
+
+ @Override
+ public String javaMatch(String action) {
+ StringBuilder result = new StringBuilder();
+ result.append("if(currentChar >= '0' && currentChar<='9'){" + "\ncurrentChar = readNextChar();"
+ + "\nwhile(currentChar >= '0' && currentChar<='9'){" + "\ncurrentChar = readNextChar();" + "\n}\n");
+ result.append(action);
+ result.append("\n}");
+ return result.toString();
+ }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleEpsilon.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleEpsilon.java
new file mode 100644
index 0000000..41b7535
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RuleEpsilon.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rules;
+
+public class RuleEpsilon implements Rule {
+
+ public RuleEpsilon clone() {
+ return new RuleEpsilon();
+ }
+
+ @Override
+ public String toString() {
+ return "?";
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null)
+ return false;
+ if (o instanceof RuleEpsilon) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String javaAction() {
+ return "";
+ }
+
+ @Override
+ public String javaMatch(String action) {
+ StringBuilder result = new StringBuilder();
+ result.append("{").append(action).append("}");
+ return result.toString();
+ }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RulePartial.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RulePartial.java
new file mode 100644
index 0000000..89caf4f
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/edu/uci/ics/asterix/lexergenerator/rules/RulePartial.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2009-2012 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.lexergenerator.rules;
+
+public class RulePartial implements Rule {
+
+ private String partialName;
+
+ public RulePartial clone() {
+ return new RulePartial(partialName);
+ }
+
+ public RulePartial(String expected) {
+ this.partialName = expected;
+ }
+
+ public String getPartial() {
+ return this.partialName;
+ }
+
+ @Override
+ public String toString() {
+ return partialName;
+ }
+
+ @Override
+ public int hashCode() {
+ return (int) partialName.charAt(1);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null)
+ return false;
+ if (o instanceof RulePartial) {
+ if (((RulePartial) o).partialName.equals(this.partialName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String javaAction() {
+ return "";
+ }
+
+ @Override
+ public String javaMatch(String action) {
+ StringBuilder result = new StringBuilder();
+ result.append("if (parse_" + partialName + "(currentChar)==TOKEN_" + partialName + "){");
+ result.append(action);
+ result.append("}");
+ return result.toString();
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
new file mode 100644
index 0000000..8cee79d
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
@@ -0,0 +1,219 @@
+package [PACKAGE];
+
+import java.io.IOException;
+import [PACKAGE].[LEXER_NAME]Exception;
+
+public class [LEXER_NAME] {
+
+ public static final int
+ TOKEN_EOF = 0, TOKEN_AUX_NOT_FOUND = 1 [TOKENS_CONSTANTS];
+
+ // Human representation of tokens. Useful for debug.
+ // Is possible to convert a TOKEN_CONSTANT in its image through
+ // [LEXER_NAME].tokenKindToString(TOKEN_CONSTANT);
+ private static final String[] tokenImage = {
+ "<EOF>", "<AUX_NOT_FOUND>" [TOKENS_IMAGES]
+ };
+
+ private static final char EOF_CHAR = 4;
+ protected java.io.Reader inputStream;
+ protected int column;
+ protected int line;
+ protected boolean prevCharIsCR;
+ protected boolean prevCharIsLF;
+ protected char[] buffer;
+ protected int bufsize;
+ protected int bufpos;
+ protected int tokenBegin;
+ protected int endOf_USED_Buffer;
+ protected int endOf_UNUSED_Buffer;
+ protected int maxUnusedBufferSize;
+
+// ================================================================================
+// Auxiliary functions. Can parse the tokens used in the grammar as partial/auxiliary
+// ================================================================================
+
+ [LEXER_AUXFUNCTIONS]
+
+// ================================================================================
+// Main method. Return a TOKEN_CONSTANT
+// ================================================================================
+
+ public int next() throws [LEXER_NAME]Exception, IOException{
+ char currentChar = buffer[bufpos];
+ while (currentChar == ' ' || currentChar=='\t' || currentChar == '\n' || currentChar=='\r')
+ currentChar = readNextChar();
+ tokenBegin = bufpos;
+ if (currentChar==EOF_CHAR) return TOKEN_EOF;
+
+ [LEXER_LOGIC]
+ }
+
+// ================================================================================
+// Public interface
+// ================================================================================
+
+ public [LEXER_NAME](java.io.Reader stream) throws IOException{
+ reInit(stream);
+ }
+
+ public void reInit(java.io.Reader stream) throws IOException{
+ done();
+ inputStream = stream;
+ bufsize = 4096;
+ line = 1;
+ column = 0;
+ bufpos = -1;
+ endOf_UNUSED_Buffer = bufsize;
+ endOf_USED_Buffer = 0;
+ prevCharIsCR = false;
+ prevCharIsLF = false;
+ buffer = new char[bufsize];
+ tokenBegin = -1;
+ maxUnusedBufferSize = 4096/2;
+ readNextChar();
+ }
+
+ public String getLastTokenImage() {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos);
+ }
+
+ public static String tokenKindToString(int token) {
+ return tokenImage[token];
+ }
+
+ public void done(){
+ buffer = null;
+ }
+
+// ================================================================================
+// Parse error management
+// ================================================================================
+
+ protected int parseError(String reason) throws [LEXER_NAME]Exception {
+ StringBuilder message = new StringBuilder();
+ message.append(reason).append("\n");
+ message.append("Line: ").append(line).append("\n");
+ message.append("Row: ").append(column).append("\n");
+ throw new [LEXER_NAME]Exception(message.toString());
+ }
+
+ protected int parseError(int ... tokens) throws [LEXER_NAME]Exception {
+ StringBuilder message = new StringBuilder();
+ message.append("Error while parsing. ");
+ message.append(" Line: ").append(line);
+ message.append(" Row: ").append(column);
+ message.append(" Expecting:");
+ for (int tokenId : tokens){
+ message.append(" ").append([LEXER_NAME].tokenKindToString(tokenId));
+ }
+ throw new [LEXER_NAME]Exception(message.toString());
+ }
+
+ protected void updateLineColumn(char c){
+ column++;
+
+ if (prevCharIsLF)
+ {
+ prevCharIsLF = false;
+ line += (column = 1);
+ }
+ else if (prevCharIsCR)
+ {
+ prevCharIsCR = false;
+ if (c == '\n')
+ {
+ prevCharIsLF = true;
+ }
+ else
+ {
+ line += (column = 1);
+ }
+ }
+
+ if (c=='\r') {
+ prevCharIsCR = true;
+ } else if(c == '\n') {
+ prevCharIsLF = true;
+ }
+ }
+
+// ================================================================================
+// Read data, buffer management. It uses a circular (and expandable) buffer
+// ================================================================================
+
+ protected char readNextChar() throws IOException {
+ if (++bufpos >= endOf_USED_Buffer)
+ fillBuff();
+ char c = buffer[bufpos];
+ updateLineColumn(c);
+ return c;
+ }
+
+ protected boolean fillBuff() throws IOException {
+ if (endOf_UNUSED_Buffer == endOf_USED_Buffer) // If no more unused buffer space
+ {
+ if (endOf_UNUSED_Buffer == bufsize) // -- If the previous unused space was
+ { // -- at the end of the buffer
+ if (tokenBegin > maxUnusedBufferSize) // -- -- If the first N bytes before
+ { // the current token are enough
+ bufpos = endOf_USED_Buffer = 0; // -- -- -- setup buffer to use that fragment
+ endOf_UNUSED_Buffer = tokenBegin;
+ }
+ else if (tokenBegin < 0) // -- -- If no token yet
+ bufpos = endOf_USED_Buffer = 0; // -- -- -- reuse the whole buffer
+ else
+ ExpandBuff(false); // -- -- Otherwise expand buffer after its end
+ }
+ else if (endOf_UNUSED_Buffer > tokenBegin) // If the endOf_UNUSED_Buffer is after the token
+ endOf_UNUSED_Buffer = bufsize; // -- set endOf_UNUSED_Buffer to the end of the buffer
+ else if ((tokenBegin - endOf_UNUSED_Buffer) < maxUnusedBufferSize)
+ { // If between endOf_UNUSED_Buffer and the token
+ ExpandBuff(true); // there is NOT enough space expand the buffer
+ } // reorganizing it
+ else
+ endOf_UNUSED_Buffer = tokenBegin; // Otherwise there is enough space at the start
+ } // so we set the buffer to use that fragment
+ int i;
+ if ((i = inputStream.read(buffer, endOf_USED_Buffer, endOf_UNUSED_Buffer - endOf_USED_Buffer)) == -1)
+ {
+ inputStream.close();
+ buffer[endOf_USED_Buffer]=(char)EOF_CHAR;
+ endOf_USED_Buffer++;
+ return false;
+ }
+ else
+ endOf_USED_Buffer += i;
+ return true;
+ }
+
+
+ protected void ExpandBuff(boolean wrapAround)
+ {
+ char[] newbuffer = new char[bufsize + maxUnusedBufferSize];
+
+ try {
+ if (wrapAround) {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+ endOf_USED_Buffer = (bufpos += (bufsize - tokenBegin));
+ }
+ else {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+ endOf_USED_Buffer = (bufpos -= tokenBegin);
+ }
+ } catch (Throwable t) {
+ throw new Error(t.getMessage());
+ }
+
+ bufsize += maxUnusedBufferSize;
+ endOf_UNUSED_Buffer = bufsize;
+ tokenBegin = 0;
+ }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
new file mode 100644
index 0000000..76aa8a4
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
@@ -0,0 +1,13 @@
+package [PACKAGE];
+
+public class [LEXER_NAME]Exception extends Exception {
+
+ public [LEXER_NAME]Exception(String message) {
+ super(message);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+}
+
+
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config
new file mode 100644
index 0000000..7efbeb8
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config
@@ -0,0 +1,16 @@
+# LEXER GENERATOR configuration file
+# ---------------------------------------
+# Place *first* the generic configuration
+# then list your grammar.
+
+PACKAGE: com.my.lexer
+LEXER_NAME: MyLexer
+OUTPUT_DIR: output
+
+TOKENS:
+
+BOOLEAN_LIT = string(boolean)
+FALSE_LIT = string(false)
+BOMB_LIT = string(bomb)
+BONSAI_LIT = string(bonsai)
+HELLO_LIT = string(hello)
\ No newline at end of file
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/Fixtures.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/Fixtures.java
new file mode 100644
index 0000000..2ed2eaa
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/Fixtures.java
@@ -0,0 +1,100 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import edu.uci.ics.asterix.lexergenerator.rules.Rule;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleChar;
+
+public class Fixtures {
+ static String token_name = "MYTOKEN";
+ static String token2_name = "MYTOKEN2";
+ static String token_return = "return TOKEN_MYTOKEN;\n";
+ static String token2_return = "return TOKEN_MYTOKEN2;\n";
+ static String token_parseerror = "return parseError(TOKEN_MYTOKEN);\n";
+ static String token_tostring = "! ";
+ static String rule_action = "myaction";
+ static String rule_name = "myrule";
+ static String rule_match = "matchCheck("+rule_name+")";
+ static String rule2_action = "myaction2";
+ static String rule2_name = "myrule2";
+ static String rule2_match = "matchCheck2("+rule_name+")";
+
+ static public Rule createRule(final String name){
+ return new Rule(){
+ String rule_name = name;
+ String rule_action = "myaction";
+ String rule_match = "matchCheck("+rule_name+")";
+
+ @Override
+ public Rule clone(){
+ return Fixtures.createRule(name+"_clone");
+ }
+
+ @Override
+ public String javaAction() {
+ return rule_action;
+ }
+
+ @Override
+ public String javaMatch(String action) {
+ return rule_match+"{"+action+"}";
+ }
+
+ @Override
+ public String toString(){
+ return rule_name;
+ }
+
+ };
+ }
+
+ static Rule rule = new Rule(){
+
+ public Rule clone(){
+ return null;
+ }
+
+ @Override
+ public String javaAction() {
+ return rule_action;
+ }
+
+ @Override
+ public String javaMatch(String action) {
+ return rule_match+"{"+action+"}";
+ }
+
+ @Override
+ public String toString(){
+ return rule_name;
+ }
+
+ };
+
+ static Rule rule2 = new Rule(){
+
+ public Rule clone(){
+ return null;
+ }
+
+ @Override
+ public String javaAction() {
+ return rule2_action;
+ }
+
+ @Override
+ public String javaMatch(String act) {
+ return rule2_match+"{"+act+"}";
+ }
+
+ @Override
+ public String toString(){
+ return rule2_name;
+ }
+
+ };
+
+ static RuleChar ruleA = new RuleChar('a');
+ static RuleChar ruleB = new RuleChar('b');
+ static RuleChar ruleC = new RuleChar('c');
+ static String ruleABC_action = "currentChar = readNextChar();";
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAddRuleTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAddRuleTest.java
new file mode 100644
index 0000000..7541124
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAddRuleTest.java
@@ -0,0 +1,51 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+
+public class LexerNodeAddRuleTest {
+
+ @Test
+ public void NodeRuleRuleNodeNode() {
+ LexerNode node = new LexerNode();
+ node.append(rule);
+ node.add(rule2);
+ node.appendTokenName(token_name);
+ assertEquals(" ( " + rule_name +token_tostring + " || " + rule2_name + token_tostring + " ) ", node.toString());
+ assertEquals(rule_match+"{"
+ +"\n" + rule_action
+ +"\n" +token_return
+ +"}"
+ +rule2_match+"{"
+ +"\n"+rule2_action
+ +"\n"+token_return
+ +"}"
+ +token_parseerror , node.toJava());
+ }
+
+ @Test
+ public void NodeSwitchCase() {
+ LexerNode node = new LexerNode();
+ node.append(ruleA);
+ node.add(ruleB);
+ node.add(ruleC);
+ node.appendTokenName(token_name);
+ assertEquals(" ( a" + token_tostring + " || b" + token_tostring + " || c" + token_tostring + " ) ", node.toString());
+ assertEquals("switch(currentChar){\n" +
+ "case 'a':" +
+ "\n" + ruleABC_action +
+ "\n" + token_return +
+ "case 'b':" +
+ "\n" + ruleABC_action +
+ "\n" + token_return +
+ "case 'c':" +
+ "\n" + ruleABC_action +
+ "\n" + token_return +
+ "}\n"+ token_parseerror , node.toJava());
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendNodeTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendNodeTest.java
new file mode 100644
index 0000000..5151e77
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendNodeTest.java
@@ -0,0 +1,81 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+
+public class LexerNodeAppendNodeTest {
+
+ @Test
+ public void AppendIsMergeIfNoActions() throws Exception {
+ LexerNode node = new LexerNode();
+ LexerNode node2 = new LexerNode();
+ node2.append(createRule("rule"));
+ node2.appendTokenName(token_name);
+ node.append(node2);
+ assertEquals("rule_clone! ", node.toString());
+ }
+
+ @Test
+ public void AppendIsAppend() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(createRule("A"));
+ LexerNode node2 = new LexerNode();
+ node2.append(createRule("rule"));
+ node2.appendTokenName(token_name);
+ node.append(node2);
+ assertEquals("Arule_clone! ", node.toString());
+ }
+
+ @Test
+ public void AppendedNodesAreCloned() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(createRule("A"));
+ node.appendTokenName(token_name);
+ LexerNode node2 = new LexerNode();
+ node2.append(createRule("B"));
+ node2.appendTokenName(token2_name);
+ node.append(node2);
+ // TODO
+ // assertEquals("A! B_clone! ", node.toString());
+
+ LexerNode node3 = new LexerNode();
+ node3.append(createRule("C"));
+ node3.append(createRule("D"));
+ node3.appendTokenName(token2_name);
+ node.append(node3);
+ // TODO
+ // assertEquals("A! B_clone! C_cloneD_clone! ", node.toString());
+ }
+
+ @Test
+ public void EpsilonRuleDoesNotPropagateAppended() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(new RuleEpsilon());
+ LexerNode node2 = new LexerNode();
+ node2.append(createRule("A"));
+ node2.appendTokenName(token2_name);
+ node.append(node2);
+ assertEquals("A_clone! ", node.toString());
+ }
+
+ @Test
+ public void EpsilonRuleIsRemovedAndIssueMerge() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(new RuleEpsilon());
+ LexerNode node2 = new LexerNode();
+ node2.append(createRule("A"));
+ node2.appendTokenName(token2_name);
+ node.append(node2);
+ node.add(new RuleEpsilon());
+ node.append(node2);
+ // TODO
+ // assertEquals(" ( A_clone! A_clone! || A_clone! ) ", node.toString());
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendRuleTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendRuleTest.java
new file mode 100644
index 0000000..84fd292
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAppendRuleTest.java
@@ -0,0 +1,47 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+
+public class LexerNodeAppendRuleTest {
+ @Test
+ public void SingleNode() {
+ LexerNode node = new LexerNode();
+ node.appendTokenName(token_name);
+ assertEquals(token_tostring, node.toString());
+ assertEquals(token_return, node.toJava());
+ }
+
+ @Test
+ public void NodeRuleNode() {
+ LexerNode node = new LexerNode();
+ node.append(rule);
+ node.appendTokenName(token_name);
+ assertEquals(rule_name+token_tostring, node.toString());
+ assertEquals(rule_match+"{"
+ +"\n"+rule_action
+ +"\n"+token_return
+ +"}"+token_parseerror, node.toJava());
+ }
+
+ @Test
+ public void NodeRuleNodeRuleNode() {
+ LexerNode node = new LexerNode();
+ node.append(rule);
+ node.append(rule2);
+ node.appendTokenName(token_name);
+ assertEquals(rule_name+rule2_name+token_tostring, node.toString());
+ assertEquals(rule_match+"{"
+ +"\n"+rule_action
+ +"\n"+rule2_match+"{"
+ +"\n"+rule2_action
+ +"\n"+token_return
+ +"}"
+ +token_parseerror
+ +"}"+token_parseerror, node.toJava());
+ }
+}
\ No newline at end of file
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java
new file mode 100644
index 0000000..9f12c00
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeAuxFunctionsTest.java
@@ -0,0 +1,111 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Set;
+
+import org.junit.Test;
+
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+import edu.uci.ics.asterix.lexergenerator.Token;
+import edu.uci.ics.asterix.lexergenerator.rules.RuleEpsilon;
+import edu.uci.ics.asterix.lexergenerator.rules.RulePartial;
+
+public class LexerNodeAuxFunctionsTest {
+ String expectedDifferentReturn = "return TOKEN_AUX_NOT_FOUND;\n";
+
+ @Test
+ public void NodeRuleRuleNodeNode() {
+ LexerNode node = new LexerNode();
+ node.append(rule);
+ node.add(rule2);
+ node.appendTokenName(token_name);
+ assertEquals(" ( " + rule_name +token_tostring + " || " + rule2_name + token_tostring + " ) ", node.toString());
+ assertEquals(rule_match+"{"
+ +"\n" + rule_action
+ +"\n" +token_return
+ +"}"
+ +rule2_match+"{"
+ +"\n"+rule2_action
+ +"\n"+token_return
+ +"}"
+ +expectedDifferentReturn , node.toJavaAuxFunction());
+ }
+
+ @Test
+ public void NodeSwitchCase() {
+ LexerNode node = new LexerNode();
+ node.append(ruleA);
+ node.add(ruleB);
+ node.add(ruleC);
+ node.appendTokenName(token_name);
+ assertEquals(" ( a" + token_tostring + " || b" + token_tostring + " || c" + token_tostring + " ) ", node.toString());
+ assertEquals("switch(currentChar){\n" +
+ "case 'a':" +
+ "\n" + ruleABC_action +
+ "\n" + token_return +
+ "case 'b':" +
+ "\n" + ruleABC_action +
+ "\n" + token_return +
+ "case 'c':" +
+ "\n" + ruleABC_action +
+ "\n" + token_return +
+ "}\n"+ expectedDifferentReturn , node.toJavaAuxFunction());
+ }
+
+ @Test
+ public void NodeNeededAuxFunctions() {
+ LexerNode node = new LexerNode();
+ node.append(ruleA);
+ node.add(new RulePartial("token1"));
+ node.append(ruleC);
+ node.append(new RulePartial("token2"));
+ node.appendTokenName(token_name);
+ assertEquals(" ( actoken2! || token1ctoken2! ) ", node.toString());
+ Set<String> expectedNeededAuxFunctions = new HashSet<String>();
+ expectedNeededAuxFunctions.add("token1");
+ expectedNeededAuxFunctions.add("token2");
+ assertEquals(expectedNeededAuxFunctions, node.neededAuxFunctions());
+ }
+
+ @Test(expected=Exception.class)
+ public void NodeExpandFirstActionError() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(ruleA);
+ node.add(new RulePartial("token1"));
+ node.append(ruleC);
+ node.add(new RuleEpsilon());
+ node.append(new RulePartial("token2"));
+ node.appendTokenName(token_name);
+ assertEquals(" ( actoken2! || token1ctoken2! || token2! ) ", node.toString());
+ LinkedHashMap<String, Token> tokens = new LinkedHashMap<String, Token>();
+ try {
+ node.expandFirstAction(tokens);
+ } catch (Exception e) {
+ assertEquals("Cannot find a token used as part of another definition, missing token: token1", e.getMessage());
+ throw e;
+ }
+ }
+
+ public void NodeExpandFirstAction() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(ruleA);
+ node.add(new RulePartial("token1"));
+ node.append(ruleC);
+ node.add(new RuleEpsilon());
+ node.append(new RulePartial("token2"));
+ node.appendTokenName(token_name);
+ assertEquals(" ( actoken2! || token1ctoken2! || token2! ) ", node.toString());
+ LinkedHashMap<String, Token> tokens = new LinkedHashMap<String, Token>();
+ Token a = new Token("token1 = string(T1-blabla)", tokens);
+ Token b = new Token("token1 = string(T1-blabla)", tokens);
+ tokens.put("token1", a);
+ tokens.put("token2", b);
+ node.expandFirstAction(tokens);
+ assertEquals(" ( actoken2! || T1-blablactoken2! || T2-blabla! ) ", node.toString());
+ }
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeCloneTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeCloneTest.java
new file mode 100644
index 0000000..87e3ff4
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeCloneTest.java
@@ -0,0 +1,56 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+
+public class LexerNodeCloneTest {
+
+ @Test
+ public void Depth1() throws Exception {
+ LexerNode node = new LexerNode();
+ LexerNode newNode = node.clone();
+ assertFalse(node == newNode);
+ }
+
+
+ @Test
+ public void Depth2() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(createRule("my1"));
+ node.add(createRule("my2"));
+ node.add(ruleA);
+ node.appendTokenName(token_name);
+ LexerNode newNode = node.clone();
+
+ assertEquals(" ( my1! || my2! || a! ) ", node.toString());
+ assertEquals(" ( my1_clone! || my2_clone! || a! ) ", newNode.toString());
+ }
+
+ @Test
+ public void Depth3() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(createRule("my1"));
+ node.add(createRule("my2"));
+ node.add(ruleA);
+ node.appendTokenName(token_name);
+ LexerNode node2 = new LexerNode();
+ node2.append(createRule("my3"));
+ node2.add(createRule("my4"));
+ node2.add(ruleB);
+ node2.appendTokenName(token2_name);
+ node.append(node2);
+ LexerNode newNode = node.clone();
+ // TODO
+ // assertEquals(" ( my1! ( || my3_clone! || my4_clone! || b! ) " +
+ // " || my2! ( || my3_clone! || my4_clone! || b! ) " +
+ // " || a! ( || my3_clone! || my4_clone! || b! ) ) ", node.toString());
+ // assertEquals(" ( my1_clone! ( || my3_clone_clone! || my4_clone_clone! || b! ) " +
+ // " || my2_clone! ( || my3_clone_clone! || my4_clone_clone! || b! ) " +
+ // " || a! ( || my3_clone_clone! || my4_clone_clone! || b! ) ) ", newNode.toString());
+ }
+
+}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeMergeNodeTest.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeMergeNodeTest.java
new file mode 100644
index 0000000..4b22d99
--- /dev/null
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/test/java/edu/uci/ics/asterix/lexergenerator/LexerNodeMergeNodeTest.java
@@ -0,0 +1,83 @@
+package edu.uci.ics.asterix.lexergenerator;
+
+import static edu.uci.ics.asterix.lexergenerator.Fixtures.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import edu.uci.ics.asterix.lexergenerator.LexerNode;
+
+public class LexerNodeMergeNodeTest {
+
+ @Test
+ public void MergeIsAdd() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(rule);
+ LexerNode node2 = new LexerNode();
+ node2.append(rule2);
+ node2.append(rule);
+ node2.merge(node);
+ node2.appendTokenName(token_name);
+
+ LexerNode expected = new LexerNode();
+ expected.append(rule2);
+ expected.append(rule);
+ expected.add(rule);
+ expected.appendTokenName(token_name);
+
+ assertEquals(expected.toString(), node2.toString());
+ assertEquals(expected.toJava(), node2.toJava());
+ }
+
+ @Test
+ public void MergeTwoToken() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(rule);
+ node.appendTokenName(token_name);
+ LexerNode node2 = new LexerNode();
+ node2.append(rule2);
+ node2.appendTokenName(token2_name);
+ node.merge(node2);
+
+ assertEquals(" ( "+rule_name+token_tostring+" || "+rule2_name+token_tostring+" ) ", node.toString());
+ assertEquals(rule_match + "{"
+ + "\n" + rule_action
+ + "\n" + token_return
+ +"}"+rule2_match+"{"
+ + "\n" + rule2_action
+ + "\n" + token2_return
+ +"}return parseError(TOKEN_MYTOKEN,TOKEN_MYTOKEN2);\n"
+, node.toJava());
+ }
+
+ @Test(expected=Exception.class)
+ public void MergeConflict() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(rule);
+ node.appendTokenName(token_name);
+ LexerNode node2 = new LexerNode();
+ node2.append(rule);
+ node2.appendTokenName(token2_name);
+ try {
+ node.merge(node2);
+ } catch (Exception e) {
+ assertEquals("Rule conflict between: "+token_name +" and "+token2_name, e.getMessage());
+ throw e;
+ }
+ }
+
+ @Test
+ public void MergeWithoutConflictWithRemoveTokensName() throws Exception {
+ LexerNode node = new LexerNode();
+ node.append(rule);
+ node.append(rule);
+ node.appendTokenName(token_name);
+ LexerNode node2 = new LexerNode();
+ node2.append(rule);
+ node2.append(rule);
+ node2.appendTokenName(token2_name);
+ node2.removeTokensName();
+ node.merge(node2);
+ assertEquals(rule_name+rule_name+token_tostring, node.toString());
+ }
+}
diff --git a/asterix-maven-plugins/pom.xml b/asterix-maven-plugins/pom.xml
new file mode 100644
index 0000000..0677ffb
--- /dev/null
+++ b/asterix-maven-plugins/pom.xml
@@ -0,0 +1,21 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>asterix-maven-plugins</artifactId>
+ <version>0.1</version>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.2.1</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <modules>
+ <module>lexer-generator-maven-plugin</module>
+ </modules>
+</project>
diff --git a/asterix-metadata/pom.xml b/asterix-metadata/pom.xml
index 58566f8..3e8e0f9 100644
--- a/asterix-metadata/pom.xml
+++ b/asterix-metadata/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>asterix</artifactId>
@@ -14,8 +15,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
</plugins>
@@ -54,12 +55,12 @@
<version>0.0.4-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-core</artifactId>
- <version>0.20.2</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-core</artifactId>
+ <version>0.20.2</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataEntityTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataEntityTupleTranslator.java
index df61cd9..9c9d02b 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataEntityTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataEntityTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -50,5 +50,5 @@
* Metadata entity to be written into a tuple.
* @throws IOException
*/
- public ITupleReference getTupleFromMetadataEntity(T metadataEntity) throws IOException;
+ public ITupleReference getTupleFromMetadataEntity(T metadataEntity) throws MetadataException, IOException;
}
\ No newline at end of file
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataRecordTypes.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataRecordTypes.java
index 01c849b..679c2db 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataRecordTypes.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataRecordTypes.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -18,6 +18,8 @@
import java.util.ArrayList;
import java.util.List;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.om.types.AOrderedListType;
import edu.uci.ics.asterix.om.types.ARecordType;
import edu.uci.ics.asterix.om.types.AUnionType;
@@ -49,31 +51,34 @@
/**
* Create all metadata record types.
*/
- public static void init() {
+ public static void init() throws MetadataException {
// Attention: The order of these calls is important because some types
// depend on other types being created first.
// These calls are one "dependency chain".
- DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE = createPropertiesRecordType();
- INTERNAL_DETAILS_RECORDTYPE = createInternalDetailsRecordType();
- EXTERNAL_DETAILS_RECORDTYPE = createExternalDetailsRecordType();
- FEED_DETAILS_RECORDTYPE = createFeedDetailsRecordType();
- DATASET_HINTS_RECORDTYPE = createPropertiesRecordType();
- DATASET_RECORDTYPE = createDatasetRecordType();
+ try {
+ DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE = createPropertiesRecordType();
+ INTERNAL_DETAILS_RECORDTYPE = createInternalDetailsRecordType();
+ EXTERNAL_DETAILS_RECORDTYPE = createExternalDetailsRecordType();
+ FEED_DETAILS_RECORDTYPE = createFeedDetailsRecordType();
+ DATASET_HINTS_RECORDTYPE = createPropertiesRecordType();
+ DATASET_RECORDTYPE = createDatasetRecordType();
- // Starting another dependency chain.
- FIELD_RECORDTYPE = createFieldRecordType();
- RECORD_RECORDTYPE = createRecordTypeRecordType();
- DERIVEDTYPE_RECORDTYPE = createDerivedTypeRecordType();
- DATATYPE_RECORDTYPE = createDatatypeRecordType();
+ // Starting another dependency chain.
+ FIELD_RECORDTYPE = createFieldRecordType();
+ RECORD_RECORDTYPE = createRecordTypeRecordType();
+ DERIVEDTYPE_RECORDTYPE = createDerivedTypeRecordType();
+ DATATYPE_RECORDTYPE = createDatatypeRecordType();
- // Independent of any other types.
- DATAVERSE_RECORDTYPE = createDataverseRecordType();
- INDEX_RECORDTYPE = createIndexRecordType();
- NODE_RECORDTYPE = createNodeRecordType();
- NODEGROUP_RECORDTYPE = createNodeGroupRecordType();
- FUNCTION_RECORDTYPE = createFunctionRecordType();
- DATASOURCE_ADAPTER_RECORDTYPE = createDatasourceAdapterRecordType();
-
+ // Independent of any other types.
+ DATAVERSE_RECORDTYPE = createDataverseRecordType();
+ INDEX_RECORDTYPE = createIndexRecordType();
+ NODE_RECORDTYPE = createNodeRecordType();
+ NODEGROUP_RECORDTYPE = createNodeGroupRecordType();
+ FUNCTION_RECORDTYPE = createFunctionRecordType();
+ DATASOURCE_ADAPTER_RECORDTYPE = createDatasourceAdapterRecordType();
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
}
// Helper constants for accessing fields in an ARecord of type
@@ -82,7 +87,7 @@
public static final int DATAVERSE_ARECORD_FORMAT_FIELD_INDEX = 1;
public static final int DATAVERSE_ARECORD_TIMESTAMP_FIELD_INDEX = 2;
- private static final ARecordType createDataverseRecordType() {
+ private static final ARecordType createDataverseRecordType() throws AsterixException {
return new ARecordType("DataverseRecordType", new String[] { "DataverseName", "DataFormat", "Timestamp" },
new IAType[] { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING }, true);
}
@@ -93,7 +98,7 @@
public static final int DATASOURCE_PROPERTIES_NAME_FIELD_INDEX = 0;
public static final int DATASOURCE_PROPERTIES_VALUE_FIELD_INDEX = 1;
- private static final ARecordType createPropertiesRecordType() {
+ private static final ARecordType createPropertiesRecordType() throws AsterixException {
String[] fieldNames = { "Name", "Value" };
IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING };
return new ARecordType(null, fieldNames, fieldTypes, true);
@@ -107,7 +112,7 @@
public static final int INTERNAL_DETAILS_ARECORD_PRIMARYKEY_FIELD_INDEX = 3;
public static final int INTERNAL_DETAILS_ARECORD_GROUPNAME_FIELD_INDEX = 4;
- private static final ARecordType createInternalDetailsRecordType() {
+ private static final ARecordType createInternalDetailsRecordType() throws AsterixException {
AOrderedListType olType = new AOrderedListType(BuiltinType.ASTRING, null);
String[] fieldNames = { "FileStructure", "PartitioningStrategy", "PartitioningKey", "PrimaryKey", "GroupName" };
IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, olType, olType, BuiltinType.ASTRING };
@@ -119,7 +124,7 @@
public static final int EXTERNAL_DETAILS_ARECORD_DATASOURCE_ADAPTER_FIELD_INDEX = 0;
public static final int EXTERNAL_DETAILS_ARECORD_PROPERTIES_FIELD_INDEX = 1;
- private static final ARecordType createExternalDetailsRecordType() {
+ private static final ARecordType createExternalDetailsRecordType() throws AsterixException {
AOrderedListType orderedPropertyListType = new AOrderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE, null);
String[] fieldNames = { "DatasourceAdapter", "Properties" };
@@ -137,7 +142,7 @@
public static final int FEED_DETAILS_ARECORD_FUNCTION_FIELD_INDEX = 7;
public static final int FEED_DETAILS_ARECORD_STATE_FIELD_INDEX = 8;
- private static final ARecordType createFeedDetailsRecordType() {
+ private static final ARecordType createFeedDetailsRecordType() throws AsterixException {
AOrderedListType orderedListType = new AOrderedListType(BuiltinType.ASTRING, null);
AOrderedListType orderedListOfPropertiesType = new AOrderedListType(DATASOURCE_ADAPTER_PROPERTIES_RECORDTYPE,
null);
@@ -168,7 +173,7 @@
public static final int DATASET_ARECORD_HINTS_FIELD_INDEX = 7;
public static final int DATASET_ARECORD_TIMESTAMP_FIELD_INDEX = 8;
- private static final ARecordType createDatasetRecordType() {
+ private static final ARecordType createDatasetRecordType() throws AsterixException {
String[] fieldNames = { "DataverseName", "DatasetName", "DataTypeName", "DatasetType", "InternalDetails",
"ExternalDetails", "FeedDetails", "Hints", "Timestamp" };
@@ -200,7 +205,7 @@
public static final int FIELD_ARECORD_FIELDNAME_FIELD_INDEX = 0;
public static final int FIELD_ARECORD_FIELDTYPE_FIELD_INDEX = 1;
- private static final ARecordType createFieldRecordType() {
+ private static final ARecordType createFieldRecordType() throws AsterixException {
String[] fieldNames = { "FieldName", "FieldType" };
IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING };
return new ARecordType(null, fieldNames, fieldTypes, true);
@@ -211,7 +216,7 @@
public static final int RECORDTYPE_ARECORD_ISOPEN_FIELD_INDEX = 0;
public static final int RECORDTYPE_ARECORD_FIELDS_FIELD_INDEX = 1;
- private static final ARecordType createRecordTypeRecordType() {
+ private static final ARecordType createRecordTypeRecordType() throws AsterixException {
AOrderedListType olType = new AOrderedListType(FIELD_RECORDTYPE, null);
String[] fieldNames = { "IsOpen", "Fields" };
IAType[] fieldTypes = { BuiltinType.ABOOLEAN, olType };
@@ -228,7 +233,7 @@
public static final int DERIVEDTYPE_ARECORD_UNORDEREDLIST_FIELD_INDEX = 5;
public static final int DERIVEDTYPE_ARECORD_ORDEREDLIST_FIELD_INDEX = 6;
- private static final ARecordType createDerivedTypeRecordType() {
+ private static final ARecordType createDerivedTypeRecordType() throws AsterixException {
String[] fieldNames = { "Tag", "IsAnonymous", "EnumValues", "Record", "Union", "UnorderedList", "OrderedList" };
List<IAType> recordUnionList = new ArrayList<IAType>();
recordUnionList.add(BuiltinType.ANULL);
@@ -257,7 +262,7 @@
public static final int DATATYPE_ARECORD_DERIVED_FIELD_INDEX = 2;
public static final int DATATYPE_ARECORD_TIMESTAMP_FIELD_INDEX = 3;
- private static final ARecordType createDatatypeRecordType() {
+ private static final ARecordType createDatatypeRecordType() throws AsterixException {
String[] fieldNames = { "DataverseName", "DatatypeName", "Derived", "Timestamp" };
List<IAType> recordUnionList = new ArrayList<IAType>();
recordUnionList.add(BuiltinType.ANULL);
@@ -277,7 +282,7 @@
public static final int INDEX_ARECORD_ISPRIMARY_FIELD_INDEX = 5;
public static final int INDEX_ARECORD_TIMESTAMP_FIELD_INDEX = 6;
- private static final ARecordType createIndexRecordType() {
+ private static final ARecordType createIndexRecordType() throws AsterixException {
AOrderedListType olType = new AOrderedListType(BuiltinType.ASTRING, null);
String[] fieldNames = { "DataverseName", "DatasetName", "IndexName", "IndexStructure", "SearchKey",
"IsPrimary", "Timestamp" };
@@ -292,7 +297,7 @@
public static final int NODE_ARECORD_NUMBEROFCORES_FIELD_INDEX = 1;
public static final int NODE_ARECORD_WORKINGMEMORYSIZE_FIELD_INDEX = 2;
- private static final ARecordType createNodeRecordType() {
+ private static final ARecordType createNodeRecordType() throws AsterixException {
String[] fieldNames = { "NodeName", "NumberOfCores", "WorkingMemorySize" };
IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.AINT32, BuiltinType.AINT32 };
return new ARecordType("NodeRecordType", fieldNames, fieldTypes, true);
@@ -304,7 +309,7 @@
public static final int NODEGROUP_ARECORD_NODENAMES_FIELD_INDEX = 1;
public static final int NODEGROUP_ARECORD_TIMESTAMP_FIELD_INDEX = 2;
- private static final ARecordType createNodeGroupRecordType() {
+ private static final ARecordType createNodeGroupRecordType() throws AsterixException {
AUnorderedListType ulType = new AUnorderedListType(BuiltinType.ASTRING, null);
String[] fieldNames = { "GroupName", "NodeNames", "Timestamp" };
IAType[] fieldTypes = { BuiltinType.ASTRING, ulType, BuiltinType.ASTRING };
@@ -326,7 +331,7 @@
public static final int FUNCTION_ARECORD_FUNCTION_LANGUAGE_FIELD_INDEX = 6;
public static final int FUNCTION_ARECORD_FUNCTION_KIND_FIELD_INDEX = 7;
- private static final ARecordType createFunctionRecordType() {
+ private static final ARecordType createFunctionRecordType() throws AsterixException {
String[] fieldNames = { "DataverseName", "Name", "Arity", "Params", "ReturnType", "Definition", "Language",
"Kind" };
@@ -342,7 +347,7 @@
public static final int DATASOURCE_ADAPTER_ARECORD_TYPE_FIELD_INDEX = 3;
public static final int DATASOURCE_ADAPTER_ARECORD_TIMESTAMP_FIELD_INDEX = 4;
- private static ARecordType createDatasourceAdapterRecordType() {
+ private static ARecordType createDatasourceAdapterRecordType() throws AsterixException {
String[] fieldNames = { "DataverseName", "Name", "Classname", "Type", "Timestamp" };
IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING, BuiltinType.ASTRING,
BuiltinType.ASTRING };
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlDataSource.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlDataSource.java
index b7ba1a1..e4c7ba2 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlDataSource.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlDataSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -15,6 +15,7 @@
package edu.uci.ics.asterix.metadata.declared;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -63,46 +64,54 @@
this.id = id;
this.dataset = dataset;
this.datasourceType = datasourceType;
- switch (datasourceType) {
- case FEED:
- initFeedDataset(itemType, dataset);
- case INTERNAL: {
- initInternalDataset(itemType);
- break;
+ try {
+ switch (datasourceType) {
+ case FEED:
+ initFeedDataset(itemType, dataset);
+ case INTERNAL: {
+ initInternalDataset(itemType);
+ break;
+ }
+ case EXTERNAL_FEED:
+ case EXTERNAL: {
+ initExternalDataset(itemType);
+ break;
+ }
+ default: {
+ throw new IllegalArgumentException();
+ }
}
- case EXTERNAL_FEED:
- case EXTERNAL: {
- initExternalDataset(itemType);
- break;
- }
- default: {
- throw new IllegalArgumentException();
- }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
}
}
public AqlDataSource(AqlSourceId id, Dataset dataset, IAType itemType) throws AlgebricksException {
this.id = id;
this.dataset = dataset;
- switch (dataset.getDatasetType()) {
- case FEED:
- initFeedDataset(itemType, dataset);
- break;
- case INTERNAL:
- initInternalDataset(itemType);
- break;
- case EXTERNAL: {
- initExternalDataset(itemType);
- break;
+ try {
+ switch (dataset.getDatasetType()) {
+ case FEED:
+ initFeedDataset(itemType, dataset);
+ break;
+ case INTERNAL:
+ initInternalDataset(itemType);
+ break;
+ case EXTERNAL: {
+ initExternalDataset(itemType);
+ break;
+ }
+ default: {
+ throw new IllegalArgumentException();
+ }
}
- default: {
- throw new IllegalArgumentException();
- }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
}
}
// TODO: Seems like initFeedDataset() could simply call this method.
- private void initInternalDataset(IAType itemType) {
+ private void initInternalDataset(IAType itemType) throws IOException {
List<String> partitioningKeys = DatasetUtils.getPartitioningKeys(dataset);
ARecordType recordType = (ARecordType) itemType;
int n = partitioningKeys.size();
@@ -114,7 +123,7 @@
domain = new AsterixNodeGroupDomain(DatasetUtils.getNodegroupName(dataset));
}
- private void initFeedDataset(IAType itemType, Dataset dataset) {
+ private void initFeedDataset(IAType itemType, Dataset dataset) throws IOException {
if (dataset.getDatasetDetails() instanceof ExternalDatasetDetails) {
initExternalDataset(itemType);
} else {
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
index d92c76d..321a73c 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -16,6 +16,7 @@
package edu.uci.ics.asterix.metadata.declared;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -851,7 +852,7 @@
splitsAndConstraint.first, typeTraits, comparatorFactories, fieldPermutation, indexOp,
new BTreeDataflowHelperFactory(), filterFactory, NoOpOperationCallbackProvider.INSTANCE, jobTxnId);
return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(btreeInsert, splitsAndConstraint.second);
- } catch (MetadataException e) {
+ } catch (MetadataException | IOException e) {
throw new AlgebricksException(e);
}
}
@@ -918,8 +919,8 @@
new RTreeDataflowHelperFactory(valueProviderFactories), filterFactory,
NoOpOperationCallbackProvider.INSTANCE, jobTxnId);
return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(rtreeUpdate, splitsAndConstraint.second);
- } catch (MetadataException me) {
- throw new AlgebricksException(me);
+ } catch (MetadataException | IOException e) {
+ throw new AlgebricksException(e);
}
}
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/ExternalDatasetDetails.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/ExternalDatasetDetails.java
index 07da617..18cef340 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/ExternalDatasetDetails.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/ExternalDatasetDetails.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2011 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package edu.uci.ics.asterix.metadata.entities;
import java.io.DataOutput;
@@ -22,6 +23,7 @@
import edu.uci.ics.asterix.builders.OrderedListBuilder;
import edu.uci.ics.asterix.builders.RecordBuilder;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.metadata.IDatasetDetails;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
@@ -76,7 +78,8 @@
fieldValue.reset();
aString.setValue(this.getAdapter());
stringSerde.serialize(aString, fieldValue.getDataOutput());
- externalRecordBuilder.addField(MetadataRecordTypes.EXTERNAL_DETAILS_ARECORD_DATASOURCE_ADAPTER_FIELD_INDEX, fieldValue);
+ externalRecordBuilder.addField(MetadataRecordTypes.EXTERNAL_DETAILS_ARECORD_DATASOURCE_ADAPTER_FIELD_INDEX,
+ fieldValue);
// write field 1
listBuilder.reset((AOrderedListType) externalRecordType.getFieldTypes()[1]);
@@ -93,8 +96,8 @@
try {
externalRecordBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new HyracksDataException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new HyracksDataException(e);
}
}
@@ -121,8 +124,8 @@
try {
propertyRecordBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new HyracksDataException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new HyracksDataException(e);
}
}
}
\ No newline at end of file
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/FeedDatasetDetails.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/FeedDatasetDetails.java
index 367066b..22de3d3 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/FeedDatasetDetails.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/FeedDatasetDetails.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2011 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package edu.uci.ics.asterix.metadata.entities;
import java.io.DataOutput;
@@ -23,6 +24,7 @@
import edu.uci.ics.asterix.builders.OrderedListBuilder;
import edu.uci.ics.asterix.builders.RecordBuilder;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.common.functions.FunctionSignature;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
@@ -160,8 +162,8 @@
try {
feedRecordBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new HyracksDataException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new HyracksDataException(e);
}
}
@@ -188,8 +190,8 @@
try {
propertyRecordBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new HyracksDataException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new HyracksDataException(e);
}
}
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/InternalDatasetDetails.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/InternalDatasetDetails.java
index 51d154a..4267af2 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/InternalDatasetDetails.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/InternalDatasetDetails.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2011 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package edu.uci.ics.asterix.metadata.entities;
import java.io.DataOutput;
@@ -22,6 +23,7 @@
import edu.uci.ics.asterix.builders.OrderedListBuilder;
import edu.uci.ics.asterix.builders.RecordBuilder;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.metadata.IDatasetDetails;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
@@ -146,8 +148,8 @@
try {
internalRecordBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new HyracksDataException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new HyracksDataException(e);
}
}
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
index 483bb70..a0aa36e 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasetTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2012 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -30,9 +30,11 @@
import edu.uci.ics.asterix.builders.RecordBuilder;
import edu.uci.ics.asterix.builders.UnorderedListBuilder;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.common.functions.FunctionSignature;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.metadata.IDatasetDetails;
+import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
import edu.uci.ics.asterix.metadata.entities.Dataset;
@@ -212,7 +214,7 @@
}
@Override
- public ITupleReference getTupleFromMetadataEntity(Dataset dataset) throws IOException {
+ public ITupleReference getTupleFromMetadataEntity(Dataset dataset) throws IOException, MetadataException {
// write the key in the first 2 fields of the tuple
tupleBuilder.reset();
aString.setValue(dataset.getDataverseName());
@@ -277,7 +279,11 @@
recordBuilder.addField(MetadataRecordTypes.DATASET_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
// write record
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ try {
+ recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
tupleBuilder.addFieldEndOffset();
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
@@ -342,7 +348,7 @@
try {
propertyRecordBuilder.write(out, true);
- } catch (IOException ioe) {
+ } catch (IOException | AsterixException ioe) {
throw new HyracksDataException(ioe);
}
}
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
index 6353e99..4a5e4dcf 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatasourceAdapterTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2012 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package edu.uci.ics.asterix.metadata.entitytupletranslators;
import java.io.ByteArrayInputStream;
@@ -20,6 +21,7 @@
import java.io.IOException;
import java.util.Calendar;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.external.dataset.adapter.AdapterIdentifier;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.metadata.MetadataException;
@@ -64,7 +66,8 @@
private DatasourceAdapter createAdapterFromARecord(ARecord adapterRecord) {
String dataverseName = ((AString) adapterRecord
- .getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_DATAVERSENAME_FIELD_INDEX)).getStringValue();
+ .getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_DATAVERSENAME_FIELD_INDEX))
+ .getStringValue();
String adapterName = ((AString) adapterRecord
.getValueByPos(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_NAME_FIELD_INDEX)).getStringValue();
String classname = ((AString) adapterRecord
@@ -76,7 +79,7 @@
}
@Override
- public ITupleReference getTupleFromMetadataEntity(DatasourceAdapter adapter) throws IOException {
+ public ITupleReference getTupleFromMetadataEntity(DatasourceAdapter adapter) throws IOException, MetadataException {
// write the key in the first 2 fields of the tuple
tupleBuilder.reset();
aString.setValue(adapter.getAdapterIdentifier().getNamespace());
@@ -121,7 +124,11 @@
recordBuilder.addField(MetadataRecordTypes.DATASOURCE_ADAPTER_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
// write record
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ try {
+ recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
tupleBuilder.addFieldEndOffset();
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
index d37fbc6..185f35b 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -28,6 +28,7 @@
import edu.uci.ics.asterix.builders.IARecordBuilder;
import edu.uci.ics.asterix.builders.OrderedListBuilder;
import edu.uci.ics.asterix.builders.RecordBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.MetadataNode;
@@ -140,8 +141,12 @@
fieldTypes[fieldId] = getTypeFromTypeName(dataverseName, fieldTypeName);
fieldId++;
}
- return new Datatype(dataverseName, datatypeName, new ARecordType(datatypeName, fieldNames,
- fieldTypes, isOpen), isAnonymous);
+ try {
+ return new Datatype(dataverseName, datatypeName, new ARecordType(datatypeName, fieldNames,
+ fieldTypes, isOpen), isAnonymous);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
}
case UNION: {
IACursor cursor = ((AOrderedList) derivedTypeRecord
@@ -189,7 +194,7 @@
}
@Override
- public ITupleReference getTupleFromMetadataEntity(Datatype dataType) throws IOException {
+ public ITupleReference getTupleFromMetadataEntity(Datatype dataType) throws IOException, MetadataException {
// write the key in the first two fields of the tuple
tupleBuilder.reset();
aString.setValue(dataType.getDataverseName());
@@ -218,7 +223,11 @@
ATypeTag tag = dataType.getDatatype().getTypeTag();
if (isDerivedType(tag)) {
fieldValue.reset();
- writeDerivedTypeRecord(dataType, fieldValue.getDataOutput());
+ try {
+ writeDerivedTypeRecord(dataType, fieldValue.getDataOutput());
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
recordBuilder.addField(MetadataRecordTypes.DATATYPE_ARECORD_DERIVED_FIELD_INDEX, fieldValue);
}
@@ -229,14 +238,18 @@
recordBuilder.addField(MetadataRecordTypes.DATATYPE_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
// write record
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ try {
+ recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
tupleBuilder.addFieldEndOffset();
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
return tuple;
}
- public void writeDerivedTypeRecord(Datatype type, DataOutput out) throws IOException {
+ private void writeDerivedTypeRecord(Datatype type, DataOutput out) throws IOException, AsterixException {
DerivedTypeTag tag;
IARecordBuilder derivedRecordBuilder = new RecordBuilder();
ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
@@ -348,7 +361,7 @@
listBuilder.write(dataOutput, true);
}
- public void writeRecordType(Datatype instance, DataOutput out) throws IOException {
+ private void writeRecordType(Datatype instance, DataOutput out) throws IOException, AsterixException {
ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
ArrayBackedValueStorage itemValue = new ArrayBackedValueStorage();
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
index 271bf90..1e32004 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/DataverseTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -21,7 +21,9 @@
import java.io.IOException;
import java.util.Calendar;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
import edu.uci.ics.asterix.metadata.entities.Dataverse;
@@ -61,7 +63,7 @@
}
@Override
- public ITupleReference getTupleFromMetadataEntity(Dataverse instance) throws IOException {
+ public ITupleReference getTupleFromMetadataEntity(Dataverse instance) throws IOException, MetadataException {
// write the key in the first field of the tuple
tupleBuilder.reset();
aString.setValue(instance.getDataverseName());
@@ -88,7 +90,11 @@
stringSerde.serialize(aString, fieldValue.getDataOutput());
recordBuilder.addField(MetadataRecordTypes.DATAVERSE_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ try {
+ recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
tupleBuilder.addFieldEndOffset();
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
index 8296a22..c34bc72 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/FunctionTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -23,7 +23,9 @@
import java.util.List;
import edu.uci.ics.asterix.builders.OrderedListBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
import edu.uci.ics.asterix.metadata.entities.Function;
@@ -48,7 +50,6 @@
// Third key field.
public static final int FUNCTION_FUNCTIONARITY_TUPLE_FIELD_INDEX = 2;
-
// Payload field containing serialized Function.
public static final int FUNCTION_PAYLOAD_TUPLE_FIELD_INDEX = 3;
@@ -103,7 +104,7 @@
}
@Override
- public ITupleReference getTupleFromMetadataEntity(Function function) throws IOException {
+ public ITupleReference getTupleFromMetadataEntity(Function function) throws IOException, MetadataException {
// write the key in the first 2 fields of the tuple
tupleBuilder.reset();
aString.setValue(function.getDataverseName());
@@ -178,7 +179,11 @@
recordBuilder.addField(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_KIND_FIELD_INDEX, fieldValue);
// write record
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ try {
+ recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
tupleBuilder.addFieldEndOffset();
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/IndexTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/IndexTupleTranslator.java
index d71480f..07d7cc9 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/IndexTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/IndexTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -25,7 +25,9 @@
import edu.uci.ics.asterix.builders.OrderedListBuilder;
import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
import edu.uci.ics.asterix.metadata.entities.Index;
@@ -106,7 +108,7 @@
}
@Override
- public ITupleReference getTupleFromMetadataEntity(Index instance) throws IOException {
+ public ITupleReference getTupleFromMetadataEntity(Index instance) throws IOException, MetadataException {
// write the key in the first 3 fields of the tuple
tupleBuilder.reset();
aString.setValue(instance.getDataverseName());
@@ -181,11 +183,19 @@
aString.setValue(GRAM_LENGTH_FIELD_NAME);
stringSerde.serialize(aString, nameValue.getDataOutput());
intSerde.serialize(new AInt32(instance.getGramLength()), fieldValue.getDataOutput());
- recordBuilder.addField(nameValue, fieldValue);
+ try {
+ recordBuilder.addField(nameValue, fieldValue);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
}
// write record
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ try {
+ recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
tupleBuilder.addFieldEndOffset();
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeGroupTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeGroupTupleTranslator.java
index da66d4b..ce72322 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeGroupTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeGroupTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -24,7 +24,9 @@
import java.util.List;
import edu.uci.ics.asterix.builders.UnorderedListBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
import edu.uci.ics.asterix.metadata.entities.NodeGroup;
@@ -79,7 +81,7 @@
}
@Override
- public ITupleReference getTupleFromMetadataEntity(NodeGroup instance) throws IOException {
+ public ITupleReference getTupleFromMetadataEntity(NodeGroup instance) throws IOException, MetadataException {
// write the key in the first field of the tuple
tupleBuilder.reset();
aString.setValue(instance.getNodeGroupName());
@@ -114,7 +116,11 @@
stringSerde.serialize(aString, fieldValue.getDataOutput());
recordBuilder.addField(MetadataRecordTypes.NODEGROUP_ARECORD_TIMESTAMP_FIELD_INDEX, fieldValue);
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ try {
+ recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
tupleBuilder.addFieldEndOffset();
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeTupleTranslator.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeTupleTranslator.java
index 8d324b4..9e276cc 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeTupleTranslator.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entitytupletranslators/NodeTupleTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -17,7 +17,9 @@
import java.io.IOException;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.metadata.MetadataException;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataPrimaryIndexes;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
import edu.uci.ics.asterix.metadata.entities.Node;
@@ -80,7 +82,7 @@
}
@Override
- public ITupleReference getTupleFromMetadataEntity(Node instance) throws IOException {
+ public ITupleReference getTupleFromMetadataEntity(Node instance) throws IOException, MetadataException {
// write the key in the first field of the tuple
tupleBuilder.reset();
aString.setValue(instance.getNodeName());
@@ -121,7 +123,11 @@
// listBuilder.write(fieldValue.getDataOutput());
// recordBuilder.addField(3, fieldValue);
- recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ try {
+ recordBuilder.write(tupleBuilder.getDataOutput(), true);
+ } catch (AsterixException e) {
+ throw new MetadataException(e);
+ }
tupleBuilder.addFieldEndOffset();
tuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray());
return tuple;
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/utils/DatasetUtils.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/utils/DatasetUtils.java
index cead5f2..df41c6e 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/utils/DatasetUtils.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/utils/DatasetUtils.java
@@ -1,5 +1,21 @@
+/*
+ * Copyright 2009-2013 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.metadata.utils;
+import java.io.IOException;
import java.util.List;
import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
@@ -25,7 +41,12 @@
List<String> partitioningKeys = getPartitioningKeys(dataset);
IBinaryComparatorFactory[] bcfs = new IBinaryComparatorFactory[partitioningKeys.size()];
for (int i = 0; i < partitioningKeys.size(); i++) {
- IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+ IAType keyType;
+ try {
+ keyType = itemType.getFieldType(partitioningKeys.get(i));
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
bcfs[i] = comparatorFactoryProvider.getBinaryComparatorFactory(keyType, true);
}
return bcfs;
@@ -39,7 +60,12 @@
List<String> partitioningKeys = getPartitioningKeys(dataset);
IBinaryHashFunctionFactory[] bhffs = new IBinaryHashFunctionFactory[partitioningKeys.size()];
for (int i = 0; i < partitioningKeys.size(); i++) {
- IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+ IAType keyType;
+ try {
+ keyType = itemType.getFieldType(partitioningKeys.get(i));
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
bhffs[i] = hashFunProvider.getBinaryHashFunctionFactory(keyType);
}
return bhffs;
@@ -54,7 +80,12 @@
int numKeys = partitioningKeys.size();
ITypeTraits[] typeTraits = new ITypeTraits[numKeys + 1];
for (int i = 0; i < numKeys; i++) {
- IAType keyType = itemType.getFieldType(partitioningKeys.get(i));
+ IAType keyType;
+ try {
+ keyType = itemType.getFieldType(partitioningKeys.get(i));
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
typeTraits[i] = AqlTypeTraitProvider.INSTANCE.getTypeTrait(keyType);
}
typeTraits[numKeys] = AqlTypeTraitProvider.INSTANCE.getTypeTrait(itemType);
diff --git a/asterix-om/pom.xml b/asterix-om/pom.xml
index 8cceaa0..8ff3f84 100644
--- a/asterix-om/pom.xml
+++ b/asterix-om/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>asterix</artifactId>
@@ -14,8 +15,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
</plugins>
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java
index 544b532..7cdb9a9 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -18,6 +18,7 @@
import java.io.DataOutput;
import java.io.IOException;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.types.ARecordType;
import edu.uci.ics.hyracks.data.std.api.IValueReference;
@@ -49,8 +50,10 @@
* The field name.
* @param out
* The field value.
+ * @throws AsterixException
+ * if the field name conflicts with a closed field name
*/
- public void addField(IValueReference name, IValueReference value);
+ public void addField(IValueReference name, IValueReference value) throws AsterixException;
/**
* @param out
@@ -59,8 +62,10 @@
* Whether to write a typetag as part of the record's serialized
* representation.
* @throws IOException
+ * @throws AsterixException
+ * if any open field names conflict with each other
*/
- public void write(DataOutput out, boolean writeTypeTag) throws IOException;
+ public void write(DataOutput out, boolean writeTypeTag) throws IOException, AsterixException;
public int getFieldId(String fieldName);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/builders/RecordBuilder.java b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/RecordBuilder.java
index 03f0e20..f5d07ae 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/builders/RecordBuilder.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/RecordBuilder.java
@@ -1,40 +1,46 @@
+/*
+ * Copyright 2009-2013 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.builders;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Arrays;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.SerializerDeserializerUtil;
import edu.uci.ics.asterix.om.types.ARecordType;
import edu.uci.ics.asterix.om.types.ATypeTag;
import edu.uci.ics.asterix.om.util.NonTaggedFormatUtil;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
+import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryHashFunctionFactory;
import edu.uci.ics.hyracks.data.std.api.IValueReference;
import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
public class RecordBuilder implements IARecordBuilder {
- private int openPartOffset;
+ private final static int DEFAULT_NUM_OPEN_FIELDS = 10;
+ private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private final static byte RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
- private ARecordType recType;
-
- private ByteArrayOutputStream closedPartOutputStream;
- private int[] closedPartOffsets;
- private int numberOfClosedFields;
- private byte[] nullBitMap;
- private int nullBitMapSize;
-
- private ByteArrayOutputStream openPartOutputStream;
- private long[] openPartOffsets;
- private long[] tempOpenPartOffsets;
-
- private int numberOfOpenFields;
-
- private int fieldNameHashCode;
- private final IBinaryHashFunction utf8HashFunction;
-
- // for write()
private int openPartOffsetArraySize;
private byte[] openPartOffsetArray;
private int offsetPosition;
@@ -42,25 +48,40 @@
private boolean isOpen;
private boolean isNullable;
private int numberOfSchemaFields;
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
- private final static byte RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
+
+ private int openPartOffset;
+ private ARecordType recType;
+
+ private final IBinaryHashFunction utf8HashFunction;
+ private final IBinaryComparator utf8Comparator;
+
+ private final ByteArrayOutputStream closedPartOutputStream;
+ private int[] closedPartOffsets;
+ private int numberOfClosedFields;
+ private byte[] nullBitMap;
+ private int nullBitMapSize;
+
+ private final ByteArrayAccessibleOutputStream openPartOutputStream;
+ private long[] openPartOffsets;
+ private int[] openFieldNameLengths;
+
+ private int numberOfOpenFields;
public RecordBuilder() {
this.closedPartOutputStream = new ByteArrayOutputStream();
this.numberOfClosedFields = 0;
- this.openPartOutputStream = new ByteArrayOutputStream();
- this.openPartOffsets = new long[20];
- this.tempOpenPartOffsets = new long[20];
-
+ this.openPartOutputStream = new ByteArrayAccessibleOutputStream();
+ this.openPartOffsets = new long[DEFAULT_NUM_OPEN_FIELDS];
+ this.openFieldNameLengths = new int[DEFAULT_NUM_OPEN_FIELDS];
this.numberOfOpenFields = 0;
- this.fieldNameHashCode = 0;
this.utf8HashFunction = new PointableBinaryHashFunctionFactory(UTF8StringPointable.FACTORY)
.createBinaryHashFunction();
+ this.utf8Comparator = new PointableBinaryComparatorFactory(UTF8StringPointable.FACTORY)
+ .createBinaryComparator();
- // for write()
this.openPartOffsetArray = null;
this.openPartOffsetArraySize = 0;
this.offsetPosition = 0;
@@ -135,23 +156,31 @@
}
@Override
- public void addField(IValueReference name, IValueReference value) {
+ public void addField(IValueReference name, IValueReference value) throws AsterixException {
if (numberOfOpenFields == openPartOffsets.length) {
- tempOpenPartOffsets = openPartOffsets;
- openPartOffsets = new long[numberOfOpenFields + 20];
- for (int i = 0; i < tempOpenPartOffsets.length; i++)
- openPartOffsets[i] = tempOpenPartOffsets[i];
+ openPartOffsets = Arrays.copyOf(openPartOffsets, openPartOffsets.length + DEFAULT_NUM_OPEN_FIELDS);
+ openFieldNameLengths = Arrays.copyOf(openFieldNameLengths, openFieldNameLengths.length
+ + DEFAULT_NUM_OPEN_FIELDS);
}
- fieldNameHashCode = utf8HashFunction.hash(name.getByteArray(), name.getStartOffset() + 1, name.getLength());
+ int fieldNameHashCode = utf8HashFunction.hash(name.getByteArray(), name.getStartOffset() + 1, name.getLength());
+ if (recType != null) {
+ int cFieldPos = recType.findFieldPosition(name.getByteArray(), name.getStartOffset() + 1,
+ name.getLength() - 1);
+ if (cFieldPos >= 0) {
+ throw new AsterixException("Open field \"" + recType.getFieldNames()[cFieldPos]
+ + "\" has the same field name as closed field at index " + cFieldPos);
+ }
+ }
openPartOffsets[this.numberOfOpenFields] = fieldNameHashCode;
openPartOffsets[this.numberOfOpenFields] = (openPartOffsets[numberOfOpenFields] << 32);
- openPartOffsets[numberOfOpenFields++] += openPartOutputStream.size();
+ openPartOffsets[numberOfOpenFields] += openPartOutputStream.size();
+ openFieldNameLengths[numberOfOpenFields++] = name.getLength() - 1;
openPartOutputStream.write(name.getByteArray(), name.getStartOffset() + 1, name.getLength() - 1);
openPartOutputStream.write(value.getByteArray(), value.getStartOffset(), value.getLength());
}
@Override
- public void write(DataOutput out, boolean writeTypeTag) throws IOException {
+ public void write(DataOutput out, boolean writeTypeTag) throws IOException, AsterixException {
int h = headerSize;
int recordLength;
// prepare the open part
@@ -163,13 +192,27 @@
openPartOffsetArray = new byte[openPartOffsetArraySize];
Arrays.sort(this.openPartOffsets, 0, numberOfOpenFields);
+ if (numberOfOpenFields > 1) {
+ byte[] openBytes = openPartOutputStream.getByteArray();
+ for (int i = 1; i < numberOfOpenFields; i++) {
+ if (utf8Comparator.compare(openBytes, (int) openPartOffsets[i - 1], openFieldNameLengths[i - 1],
+ openBytes, (int) openPartOffsets[i], openFieldNameLengths[i]) == 0) {
+ String field = UTF8StringSerializerDeserializer.INSTANCE
+ .deserialize(new DataInputStream(new ByteArrayInputStream(openBytes,
+ (int) openPartOffsets[i], openFieldNameLengths[i])));
+ throw new AsterixException("Open fields " + (i - 1) + " and " + i
+ + " have the same field name \"" + field + "\"");
+ }
+ }
+ }
openPartOffset = h + numberOfSchemaFields * 4 + closedPartOutputStream.size();
+ int fieldNameHashCode;
for (int i = 0; i < numberOfOpenFields; i++) {
fieldNameHashCode = (int) (openPartOffsets[i] >> 32);
SerializerDeserializerUtil.writeIntToByteArray(openPartOffsetArray, (int) fieldNameHashCode,
offsetPosition);
- int fieldOffset = (int) ((openPartOffsets[i] << 64) >> 64);
+ int fieldOffset = (int) openPartOffsets[i];
SerializerDeserializerUtil.writeIntToByteArray(openPartOffsetArray, fieldOffset + openPartOffset + 4
+ openPartOffsetArraySize, offsetPosition + 4);
offsetPosition += 8;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
index 393f634..a450f27 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -21,6 +21,7 @@
import edu.uci.ics.asterix.builders.IARecordBuilder;
import edu.uci.ics.asterix.builders.RecordBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
import edu.uci.ics.asterix.formats.nontagged.AqlBinaryHashFunctionFactoryProvider;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
@@ -149,7 +150,7 @@
} else {
return new ARecord(this.recordType, closedFields);
}
- } catch (IOException e) {
+ } catch (IOException | AsterixException e) {
throw new HyracksDataException(e);
}
}
@@ -166,7 +167,7 @@
return fields;
}
- private ARecordType mergeRecordTypes(ARecordType recType1, ARecordType recType2) {
+ private ARecordType mergeRecordTypes(ARecordType recType1, ARecordType recType2) throws AsterixException {
String[] fieldNames = new String[recType1.getFieldNames().length + recType2.getFieldNames().length];
IAType[] fieldTypes = new IAType[recType1.getFieldTypes().length + recType2.getFieldTypes().length];
@@ -199,7 +200,7 @@
}
try {
recordBuilder.write(out, false);
- } catch (IOException e) {
+ } catch (IOException | AsterixException e) {
throw new HyracksDataException(e);
}
} else {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/base/DefaultOpenFieldType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/base/DefaultOpenFieldType.java
index 9184616..45ae5c5 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/base/DefaultOpenFieldType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/pointables/base/DefaultOpenFieldType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -15,6 +15,8 @@
package edu.uci.ics.asterix.om.pointables.base;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
+import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
import edu.uci.ics.asterix.om.types.AOrderedListType;
import edu.uci.ics.asterix.om.types.ARecordType;
import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -27,13 +29,19 @@
* fields in the open part, e.g., a "record" (nested) field in the open part is
* always a fully open one, and a "list" field in the open part is always a list
* of "ANY".
- *
*/
public class DefaultOpenFieldType {
// nested open field rec type
- public static ARecordType NESTED_OPEN_RECORD_TYPE = new ARecordType("nested-open", new String[] {},
- new IAType[] {}, true);
+ public static ARecordType NESTED_OPEN_RECORD_TYPE;
+
+ static {
+ try {
+ NESTED_OPEN_RECORD_TYPE = new ARecordType("nested-open", new String[] {}, new IAType[] {}, true);
+ } catch (AsterixException e) {
+ throw new AsterixRuntimeException();
+ }
+ }
// nested open list type
public static AOrderedListType NESTED_OPEN_AORDERED_LIST_TYPE = new AOrderedListType(BuiltinType.ANY,
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
index daf7164..8ed2084 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -19,6 +19,7 @@
import org.apache.commons.lang3.mutable.Mutable;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.base.AString;
import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
@@ -49,7 +50,7 @@
ARecordType type = (ARecordType) TypeComputerUtilities.getRequiredType(f);
if (type != null)
return type;
-
+
int n = f.getArguments().size() / 2;
String[] fieldNames = new String[n];
IAType[] fieldTypes = new IAType[n];
@@ -68,6 +69,10 @@
fieldTypes[i] = (IAType) env.getType(e2);
i++;
}
- return new ARecordType(null, fieldNames, fieldTypes, false);
+ try {
+ return new ARecordType(null, fieldNames, fieldTypes, false);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
}
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
index 8b54197..ee52425 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
@@ -1,8 +1,24 @@
+/*
+ * Copyright 2009-2013 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.typecomputer.impl;
import java.util.ArrayList;
import java.util.List;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
import edu.uci.ics.asterix.om.types.ARecordType;
import edu.uci.ics.asterix.om.types.AUnionType;
@@ -23,7 +39,11 @@
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADOUBLE);
- return new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+ try {
+ return new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
}
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
index c46c59b..0c6fc55 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 by The Regents of the University of California
+ * Copyright 2009-2013 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
@@ -21,6 +21,7 @@
import org.apache.commons.lang3.mutable.Mutable;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.base.AString;
import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
@@ -72,6 +73,10 @@
IAType[] fieldTypes = new IAType[n];
fieldNames = namesList.toArray(fieldNames);
fieldTypes = typesList.toArray(fieldTypes);
- return new ARecordType(null, fieldNames, fieldTypes, true);
+ try {
+ return new ARecordType(null, fieldNames, fieldTypes, true);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
}
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/RecordConstructorResultType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/RecordConstructorResultType.java
index d20f43b..1f072f0 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/RecordConstructorResultType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/RecordConstructorResultType.java
@@ -1,9 +1,25 @@
+/*
+ * Copyright 2009-2013 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.typecomputer.impl;
import java.util.Iterator;
import org.apache.commons.lang3.mutable.Mutable;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.base.AString;
import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
@@ -58,6 +74,10 @@
}
i++;
}
- return new ARecordType(null, fieldNames, fieldTypes, isOpen);
+ try {
+ return new ARecordType(null, fieldNames, fieldTypes, isOpen);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
}
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
index 1cf6ba7..ac1facc 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
@@ -1,15 +1,38 @@
+/*
+ * Copyright 2009-2013 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.types;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import edu.uci.ics.asterix.common.annotations.IRecordTypeAnnotation;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.base.IAObject;
import edu.uci.ics.asterix.om.visitors.IOMVisitor;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
+import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
+import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryHashFunctionFactory;
+import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
public class ARecordType extends AbstractComplexType {
@@ -18,16 +41,110 @@
private IAType[] fieldTypes;
private boolean isOpen;
private final List<IRecordTypeAnnotation> annotations = new ArrayList<IRecordTypeAnnotation>();
- private final Map<String, Integer> typeMap = new HashMap<String, Integer>();
- public ARecordType(String typeName, String[] fieldNames, IAType[] fieldTypes, boolean isOpen) {
+ private transient IBinaryHashFunction fieldNameHashFunction;
+ private transient IBinaryComparator fieldNameComparator;
+ private final byte serializedFieldNames[];
+ private final int serializedFieldNameOffsets[];
+ private final long hashCodeIndexPairs[];
+
+ /**
+ * @param typeName
+ * the name of the type
+ * @param fieldNames
+ * the names of the closed fields
+ * @param fieldTypes
+ * the types of the closed fields
+ * @param isOpen
+ * whether the record is open
+ * @throws AsterixException
+ * if there are duplicate field names or if there is an error serializing the field names
+ */
+ public ARecordType(String typeName, String[] fieldNames, IAType[] fieldTypes, boolean isOpen)
+ throws AsterixException {
super(typeName);
this.fieldNames = fieldNames;
this.fieldTypes = fieldTypes;
this.isOpen = isOpen;
+
+ fieldNameComparator = new PointableBinaryComparatorFactory(UTF8StringPointable.FACTORY)
+ .createBinaryComparator();
+ fieldNameHashFunction = new PointableBinaryHashFunctionFactory(UTF8StringPointable.FACTORY)
+ .createBinaryHashFunction();
+ ByteArrayAccessibleOutputStream baaos = new ByteArrayAccessibleOutputStream();
+ DataOutputStream dos = new DataOutputStream(baaos);
+ serializedFieldNameOffsets = new int[fieldNames.length];
+ hashCodeIndexPairs = new long[fieldNames.length];
+
+ int length = 0;
for (int i = 0; i < fieldNames.length; i++) {
- typeMap.put(fieldNames[i], i);
+ serializedFieldNameOffsets[i] = baaos.size();
+ try {
+ dos.writeUTF(fieldNames[i]);
+ } catch (IOException e) {
+ throw new AsterixException(e);
+ }
+ length = baaos.size() - serializedFieldNameOffsets[i];
+ hashCodeIndexPairs[i] = fieldNameHashFunction.hash(baaos.getByteArray(), serializedFieldNameOffsets[i],
+ length);
+ hashCodeIndexPairs[i] = hashCodeIndexPairs[i] << 32;
+ hashCodeIndexPairs[i] = hashCodeIndexPairs[i] | i;
}
+ serializedFieldNames = baaos.getByteArray();
+
+ Arrays.sort(hashCodeIndexPairs);
+ int j;
+ for (int i = 0; i < fieldNames.length; i++) {
+ j = findFieldPosition(serializedFieldNames, serializedFieldNameOffsets[i],
+ UTF8StringPointable.getStringLength(serializedFieldNames, serializedFieldNameOffsets[i]));
+ if (j != i) {
+ throw new AsterixException("Closed fields " + j + " and " + i + " have the same field name \""
+ + fieldNames[i] + "\"");
+ }
+ }
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ois.defaultReadObject();
+ fieldNameComparator = new PointableBinaryComparatorFactory(UTF8StringPointable.FACTORY)
+ .createBinaryComparator();
+ fieldNameHashFunction = new PointableBinaryHashFunctionFactory(UTF8StringPointable.FACTORY)
+ .createBinaryHashFunction();
+ }
+
+ /**
+ * Returns the position of the field in the closed schema or -1 if the field does not exist.
+ *
+ * @param bytes
+ * the serialized bytes of the field name
+ * @param start
+ * the starting offset of the field name in bytes
+ * @param length
+ * the length of the field name in bytes
+ * @return the position of the field in the closed schema or -1 if the field does not exist.
+ */
+ public int findFieldPosition(byte[] bytes, int start, int length) {
+ if (hashCodeIndexPairs.length == 0) {
+ return -1;
+ }
+
+ int fIndex;
+ int probeFieldHash = fieldNameHashFunction.hash(bytes, start, length);
+ int i = Arrays.binarySearch(hashCodeIndexPairs, ((long) probeFieldHash) << 32);
+ i = (i < 0) ? (i = -1 * (i + 1)) : i;
+
+ while (i < hashCodeIndexPairs.length && (int) (hashCodeIndexPairs[i] >>> 32) == probeFieldHash) {
+ fIndex = (int) hashCodeIndexPairs[i];
+ int cFieldLength = UTF8StringPointable.getStringLength(serializedFieldNames,
+ serializedFieldNameOffsets[fIndex]);
+ if (fieldNameComparator.compare(serializedFieldNames, serializedFieldNameOffsets[fIndex], cFieldLength,
+ bytes, start, length) == 0) {
+ return fIndex;
+ }
+ i++;
+ }
+
+ return -1;
}
public final String[] getFieldNames() {
@@ -73,17 +190,22 @@
return isOpen;
}
- public int findFieldPosition(String fldName) {
- for (int i = 0; i < fieldNames.length; i++) {
- if (fieldNames[i].equals(fldName)) {
- return i;
- }
- }
- return -1;
+ /**
+ * Returns the position of the field in the closed schema or -1 if the field does not exist.
+ *
+ * @param fieldName
+ * the name of the field whose position is sought
+ * @return the position of the field in the closed schema or -1 if the field does not exist.
+ */
+ public int findFieldPosition(String fieldName) throws IOException {
+ ByteArrayAccessibleOutputStream baaos = new ByteArrayAccessibleOutputStream();
+ DataOutputStream dos = new DataOutputStream(baaos);
+ UTF8StringSerializerDeserializer.INSTANCE.serialize(fieldName, dos);
+ return findFieldPosition(baaos.getByteArray(), 0, baaos.getByteArray().length);
}
- public IAType getFieldType(String fieldName) {
- return fieldTypes[typeMap.get(fieldName)];
+ public IAType getFieldType(String fieldName) throws IOException {
+ return fieldTypes[findFieldPosition(fieldName)];
}
@Override
@@ -115,12 +237,11 @@
public int hash() {
int h = 0;
for (int i = 0; i < fieldNames.length; i++) {
- h += 31 * h + fieldNames[i].hashCode();
+ h += 31 * h + (int) (hashCodeIndexPairs[i] >> 32);
}
for (int i = 0; i < fieldTypes.length; i++) {
h += 31 * h + fieldTypes[i].hashCode();
}
return h;
}
-
}
diff --git a/asterix-runtime/pom.xml b/asterix-runtime/pom.xml
index 93b38df..be64661 100644
--- a/asterix-runtime/pom.xml
+++ b/asterix-runtime/pom.xml
@@ -16,27 +16,84 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>javacc-maven-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>javacc</id>
- <goals>
- <goal>javacc</goal>
- </goals>
- <configuration>
- <isStatic>false</isStatic>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ <plugin>
+ <groupId>edu.uci.ics.asterix</groupId>
+ <artifactId>lexer-generator-maven-plugin</artifactId>
+ <version>0.1</version>
+ <configuration>
+ <grammarFile>src/main/resources/adm.grammar</grammarFile>
+ <outputDir>${project.build.directory}/generated-sources/edu/uci/ics/asterix/runtime/operators/file/adm</outputDir>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-lexer</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate-lexer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources/</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ edu.uci.ics.asterix
+ </groupId>
+ <artifactId>
+ lexer-generator-maven-plugin
+ </artifactId>
+ <versionRange>
+ [0.1,)
+ </versionRange>
+ <goals>
+ <goal>generate-lexer</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <execute>
+ <runOnIncremental>false</runOnIncremental>
+ </execute>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
<dependencies>
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
index 89081ab..f720434 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 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.runtime.aggregates.serializable.std;
import java.io.DataOutput;
@@ -6,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
@@ -59,8 +75,15 @@
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADOUBLE);
- final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
+ ARecordType _recType;
+ try {
+ _recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
+
+ final ARecordType recType = _recType;
return new ICopySerializableAggregateFunctionFactory() {
private static final long serialVersionUID = 1L;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
index 41047f7..219204b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 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.runtime.aggregates.serializable.std;
import java.io.DataOutput;
@@ -6,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -63,8 +79,15 @@
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADOUBLE);
- final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
+ ARecordType tmpRecType;
+ try {
+ tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
+
+ final ARecordType recType = tmpRecType;
return new ICopySerializableAggregateFunctionFactory() {
private static final long serialVersionUID = 1L;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
index 4fe5e35..93c7026 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 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.runtime.aggregates.std;
import java.io.DataOutput;
@@ -7,6 +22,7 @@
import java.util.List;
import edu.uci.ics.asterix.common.config.GlobalConfig;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -64,8 +80,15 @@
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADOUBLE);
- final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, true);
+ ARecordType tmpRecType;
+ try {
+ tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, true);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
+
+ final ARecordType recType = tmpRecType;
return new ICopyAggregateFunctionFactory() {
private static final long serialVersionUID = 1L;
@@ -78,7 +101,7 @@
private DataOutput out = provider.getDataOutput();
private ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(inputVal);
+ private ICopyEvaluator eval = args[0].createEvaluator(inputVal);
private double sum;
private int count;
private ATypeTag aggType;
@@ -115,13 +138,13 @@
@Override
public void step(IFrameTupleReference tuple) throws AlgebricksException {
inputVal.reset();
- eval.evaluate(tuple);
+ eval.evaluate(tuple);
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
.deserialize(inputVal.getByteArray()[0]);
if (typeTag == ATypeTag.NULL || aggType == ATypeTag.NULL) {
aggType = ATypeTag.NULL;
return;
- } else if (aggType == ATypeTag.SYSTEM_NULL) {
+ } else if (aggType == ATypeTag.SYSTEM_NULL) {
aggType = typeTag;
} else if (typeTag != ATypeTag.SYSTEM_NULL && typeTag != aggType) {
throw new AlgebricksException("Unexpected type " + typeTag
@@ -129,7 +152,7 @@
}
if (typeTag != ATypeTag.SYSTEM_NULL) {
++count;
- }
+ }
switch (typeTag) {
case INT8: {
byte val = AInt8SerializerDeserializer.getByte(inputVal.getByteArray(), 1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
index 347f5e7..d262ef4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 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.runtime.aggregates.std;
import java.io.DataOutput;
@@ -6,7 +21,7 @@
import java.util.ArrayList;
import java.util.List;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
@@ -61,8 +76,15 @@
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADOUBLE);
- final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+ ARecordType tmpRecType;
+ try {
+ tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
+
+ final ARecordType recType = tmpRecType;
return new ICopyAggregateFunctionFactory() {
private static final long serialVersionUID = 1L;
@@ -114,7 +136,7 @@
inputVal.reset();
eval.evaluate(tuple);
byte[] serBytes = inputVal.getByteArray();
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serBytes[0]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serBytes[0]);
switch (typeTag) {
case NULL: {
metNull = true;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
index de02246..5400d78 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 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.runtime.aggregates.std;
import java.io.DataOutput;
@@ -6,7 +21,7 @@
import java.util.ArrayList;
import java.util.List;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -72,8 +87,15 @@
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADOUBLE);
- final ARecordType recType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+ ARecordType tmpRecType;
+ try {
+ tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
+
+ final ARecordType recType = tmpRecType;
return new ICopyAggregateFunction() {
@@ -204,5 +226,4 @@
}
};
}
-
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
index 38983e2..db3bc40 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.common;
import java.io.DataOutput;
@@ -5,6 +20,7 @@
import edu.uci.ics.asterix.builders.IARecordBuilder;
import edu.uci.ics.asterix.builders.RecordBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.types.ARecordType;
import edu.uci.ics.asterix.om.types.ATypeTag;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -72,8 +88,8 @@
}
}
recBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new AlgebricksException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new AlgebricksException(e);
}
}
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
index 77869ba..81ae62b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/OpenRecordConstructorDescriptor.java
@@ -1,9 +1,25 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.functions;
import java.io.DataOutput;
import java.io.IOException;
import edu.uci.ics.asterix.builders.RecordBuilder;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -86,8 +102,8 @@
}
}
recBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new AlgebricksException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new AlgebricksException(e);
}
}
};
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 8606088..2e64ad4 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
@@ -22,10 +22,8 @@
import java.util.List;
import java.util.Queue;
-import edu.uci.ics.asterix.adm.parser.nontagged.AdmLexer;
-import edu.uci.ics.asterix.adm.parser.nontagged.AdmLexerConstants;
-import edu.uci.ics.asterix.adm.parser.nontagged.ParseException;
-import edu.uci.ics.asterix.adm.parser.nontagged.Token;
+import edu.uci.ics.asterix.runtime.operators.file.adm.AdmLexer;
+import edu.uci.ics.asterix.runtime.operators.file.adm.AdmLexerException;
import edu.uci.ics.asterix.builders.IARecordBuilder;
import edu.uci.ics.asterix.builders.IAsterixListBuilder;
import edu.uci.ics.asterix.builders.OrderedListBuilder;
@@ -36,6 +34,7 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ALineSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APoint3DSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APointSerializerDeserializer;
@@ -55,7 +54,7 @@
import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
/**
- * Parser for ADM formatted data.
+ * Parser for ADM formatted data.
*/
public class ADMDataParser extends AbstractDataParser implements IDataParser {
@@ -82,21 +81,25 @@
}
@Override
- public void initialize(InputStream in, ARecordType recordType, boolean datasetRec) {
- admLexer = new AdmLexer(in);
+ public void initialize(InputStream in, ARecordType recordType, boolean datasetRec) throws AsterixException {
this.recordType = recordType;
this.datasetRec = datasetRec;
+ try {
+ admLexer = new AdmLexer(new java.io.InputStreamReader(in));
+ } catch (IOException e) {
+ throw new AsterixException(e);
+ }
}
protected boolean parseAdmInstance(IAType objectType, boolean datasetRec, DataOutput out) throws AsterixException,
IOException {
- Token token;
+ int token;
try {
token = admLexer.next();
- } catch (ParseException pe) {
- throw new AsterixException(pe);
+ } catch (AdmLexerException e) {
+ throw new AsterixException(e);
}
- if (token.kind == AdmLexerConstants.EOF) {
+ if (token == AdmLexer.TOKEN_EOF) {
return false;
} else {
admFromLexerStream(token, objectType, out, datasetRec);
@@ -104,157 +107,212 @@
}
}
- private void admFromLexerStream(Token token, IAType objectType, DataOutput out, Boolean datasetRec)
+ private void admFromLexerStream(int token, IAType objectType, DataOutput out, Boolean datasetRec)
throws AsterixException, IOException {
- switch (token.kind) {
- case AdmLexerConstants.NULL_LITERAL: {
+ switch (token) {
+ case AdmLexer.TOKEN_NULL_LITERAL: {
if (checkType(ATypeTag.NULL, objectType, out)) {
nullSerde.serialize(ANull.NULL, out);
} else
throw new AsterixException(" This field can not be null ");
break;
}
- case AdmLexerConstants.TRUE_LITERAL: {
+ case AdmLexer.TOKEN_TRUE_LITERAL: {
if (checkType(ATypeTag.BOOLEAN, objectType, out)) {
booleanSerde.serialize(ABoolean.TRUE, out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.BOOLEAN_CONS: {
+ case AdmLexer.TOKEN_BOOLEAN_CONS: {
parseConstructor(ATypeTag.BOOLEAN, objectType, out);
break;
}
- case AdmLexerConstants.FALSE_LITERAL: {
+ case AdmLexer.TOKEN_FALSE_LITERAL: {
if (checkType(ATypeTag.BOOLEAN, objectType, out)) {
booleanSerde.serialize(ABoolean.FALSE, out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.DOUBLE_LITERAL: {
+ case AdmLexer.TOKEN_DOUBLE_LITERAL: {
if (checkType(ATypeTag.DOUBLE, objectType, out)) {
- aDouble.setValue(Double.parseDouble(token.image));
+ aDouble.setValue(Double.parseDouble(admLexer.getLastTokenImage()));
doubleSerde.serialize(aDouble, out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.DOUBLE_CONS: {
+ case AdmLexer.TOKEN_DOUBLE_CONS: {
parseConstructor(ATypeTag.DOUBLE, objectType, out);
break;
}
- case AdmLexerConstants.FLOAT_LITERAL: {
+ case AdmLexer.TOKEN_FLOAT_LITERAL: {
if (checkType(ATypeTag.FLOAT, objectType, out)) {
- aFloat.setValue(Float.parseFloat(token.image));
+ aFloat.setValue(Float.parseFloat(admLexer.getLastTokenImage()));
floatSerde.serialize(aFloat, out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.FLOAT_CONS: {
+ case AdmLexer.TOKEN_FLOAT_CONS: {
parseConstructor(ATypeTag.FLOAT, objectType, out);
break;
}
- case AdmLexerConstants.INT8_LITERAL: {
+ case AdmLexer.TOKEN_INT8_LITERAL: {
if (checkType(ATypeTag.INT8, objectType, out)) {
- parseInt8(token.image, out);
+ parseInt8(admLexer.getLastTokenImage(), out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.INT8_CONS: {
+ case AdmLexer.TOKEN_INT8_CONS: {
parseConstructor(ATypeTag.INT8, objectType, out);
break;
}
- case AdmLexerConstants.INT16_LITERAL: {
+ case AdmLexer.TOKEN_INT16_LITERAL: {
if (checkType(ATypeTag.INT16, objectType, out)) {
- parseInt16(token.image, out);
+ parseInt16(admLexer.getLastTokenImage(), out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.INT16_CONS: {
+ case AdmLexer.TOKEN_INT16_CONS: {
parseConstructor(ATypeTag.INT16, objectType, out);
break;
}
- case AdmLexerConstants.INT_LITERAL:
- case AdmLexerConstants.INT32_LITERAL: {
+ case AdmLexer.TOKEN_INT_LITERAL:
+ case AdmLexer.TOKEN_INT32_LITERAL: {
if (checkType(ATypeTag.INT32, objectType, out)) {
- parseInt32(token.image, out);
+ parseInt32(admLexer.getLastTokenImage(), out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.INT32_CONS: {
+ case AdmLexer.TOKEN_INT32_CONS: {
parseConstructor(ATypeTag.INT32, objectType, out);
break;
}
- case AdmLexerConstants.INT64_LITERAL: {
+ case AdmLexer.TOKEN_INT64_LITERAL: {
if (checkType(ATypeTag.INT64, objectType, out)) {
- parseInt64(token.image, out);
+ parseInt64(admLexer.getLastTokenImage(), out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.INT64_CONS: {
+ case AdmLexer.TOKEN_INT64_CONS: {
parseConstructor(ATypeTag.INT64, objectType, out);
break;
}
- case AdmLexerConstants.STRING_LITERAL: {
+ case AdmLexer.TOKEN_STRING_LITERAL: {
if (checkType(ATypeTag.STRING, objectType, out)) {
- aString.setValue(token.image.substring(1, token.image.length() - 1));
+ aString.setValue(admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1));
stringSerde.serialize(aString, out);
} else
throw new AsterixException(mismatchErrorMessage + objectType.getTypeName());
break;
}
- case AdmLexerConstants.STRING_CONS: {
+ case AdmLexer.TOKEN_STRING_CONS: {
parseConstructor(ATypeTag.STRING, objectType, out);
break;
}
- case AdmLexerConstants.DATE_CONS: {
+ case AdmLexer.TOKEN_DATE_CONS: {
parseConstructor(ATypeTag.DATE, objectType, out);
break;
}
- case AdmLexerConstants.TIME_CONS: {
+ case AdmLexer.TOKEN_TIME_CONS: {
parseConstructor(ATypeTag.TIME, objectType, out);
break;
}
- case AdmLexerConstants.DATETIME_CONS: {
+ case AdmLexer.TOKEN_DATETIME_CONS: {
parseConstructor(ATypeTag.DATETIME, objectType, out);
break;
}
- case AdmLexerConstants.DURATION_CONS: {
+ 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_CONS) {
+ AIntervalSerializerDeserializer.parseDate(admLexer.getLastTokenImage(), out);
+
+ 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_CONS) {
+ AIntervalSerializerDeserializer.parseTime(admLexer.getLastTokenImage(), out);
+
+ 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_CONS) {
+ AIntervalSerializerDeserializer.parseDatetime(admLexer.getLastTokenImage(), out);
+
+ 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.");
+ }
+ case AdmLexer.TOKEN_DURATION_CONS: {
parseConstructor(ATypeTag.DURATION, objectType, out);
break;
}
- case AdmLexerConstants.POINT_CONS: {
+ case AdmLexer.TOKEN_POINT_CONS: {
parseConstructor(ATypeTag.POINT, objectType, out);
break;
}
- case AdmLexerConstants.POINT3D_CONS: {
+ case AdmLexer.TOKEN_POINT3D_CONS: {
parseConstructor(ATypeTag.POINT3D, objectType, out);
break;
}
- case AdmLexerConstants.CIRCLE_CONS: {
+ case AdmLexer.TOKEN_CIRCLE_CONS: {
parseConstructor(ATypeTag.CIRCLE, objectType, out);
break;
}
- case AdmLexerConstants.RECTANGLE_CONS: {
+ case AdmLexer.TOKEN_RECTANGLE_CONS: {
parseConstructor(ATypeTag.RECTANGLE, objectType, out);
break;
}
- case AdmLexerConstants.LINE_CONS: {
+ case AdmLexer.TOKEN_LINE_CONS: {
parseConstructor(ATypeTag.LINE, objectType, out);
break;
}
- case AdmLexerConstants.POLYGON_CONS: {
+ case AdmLexer.TOKEN_POLYGON_CONS: {
parseConstructor(ATypeTag.POLYGON, objectType, out);
break;
}
- case AdmLexerConstants.START_UNORDERED_LIST: {
+ case AdmLexer.TOKEN_START_UNORDERED_LIST: {
if (checkType(ATypeTag.UNORDEREDLIST, objectType, out)) {
objectType = getComplexType(objectType, ATypeTag.UNORDEREDLIST);
parseUnorderedList((AUnorderedListType) objectType, out);
@@ -263,7 +321,7 @@
break;
}
- case AdmLexerConstants.START_ORDERED_LIST: {
+ case AdmLexer.TOKEN_START_ORDERED_LIST: {
if (checkType(ATypeTag.ORDEREDLIST, objectType, out)) {
objectType = getComplexType(objectType, ATypeTag.ORDEREDLIST);
parseOrderedList((AOrderedListType) objectType, out);
@@ -271,7 +329,7 @@
throw new AsterixException(mismatchErrorMessage + objectType.getTypeTag());
break;
}
- case AdmLexerConstants.START_RECORD: {
+ case AdmLexer.TOKEN_START_RECORD: {
if (checkType(ATypeTag.RECORD, objectType, out)) {
objectType = getComplexType(objectType, ATypeTag.RECORD);
parseRecord((ARecordType) objectType, out, datasetRec);
@@ -279,11 +337,11 @@
throw new AsterixException(mismatchErrorMessage + objectType.getTypeTag());
break;
}
- case AdmLexerConstants.EOF: {
+ case AdmLexer.TOKEN_EOF: {
break;
}
default: {
- throw new AsterixException("Unexpected ADM token kind: " + admLexer.tokenKindToString(token.kind) + ".");
+ throw new AsterixException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token) + ".");
}
}
}
@@ -365,7 +423,7 @@
recBuilder.reset(null);
recBuilder.init();
- Token token = null;
+ int token;
boolean inRecord = true;
boolean expectingRecordField = false;
boolean first = true;
@@ -375,15 +433,15 @@
IAType fieldType = null;
do {
token = nextToken();
- switch (token.kind) {
- case AdmLexerConstants.END_RECORD: {
+ switch (token) {
+ case AdmLexer.TOKEN_END_RECORD: {
if (expectingRecordField) {
throw new AsterixException("Found END_RECORD while expecting a record field.");
}
inRecord = false;
break;
}
- case AdmLexerConstants.STRING_LITERAL: {
+ case AdmLexer.TOKEN_STRING_LITERAL: {
// we've read the name of the field
// now read the content
fieldNameBuffer.reset();
@@ -391,12 +449,14 @@
expectingRecordField = false;
if (recType != null) {
- String fldName = token.image.substring(1, token.image.length() - 1);
+ String fldName = admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1);
fieldId = recBuilder.getFieldId(fldName);
if (fieldId < 0 && !recType.isOpen()) {
throw new AsterixException("This record is closed, you can not add extra fields !!");
} else if (fieldId < 0 && recType.isOpen()) {
- aStringFieldName.setValue(token.image.substring(1, token.image.length() - 1));
+ aStringFieldName.setValue(admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1));
stringSerde.serialize(aStringFieldName, fieldNameBuffer.getDataOutput());
openRecordField = true;
fieldType = null;
@@ -407,16 +467,17 @@
openRecordField = false;
}
} else {
- aStringFieldName.setValue(token.image.substring(1, token.image.length() - 1));
+ aStringFieldName.setValue(admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1));
stringSerde.serialize(aStringFieldName, fieldNameBuffer.getDataOutput());
openRecordField = true;
fieldType = null;
}
token = nextToken();
- if (token.kind != AdmLexerConstants.COLON) {
- throw new AsterixException("Unexpected ADM token kind: "
- + admLexer.tokenKindToString(token.kind) + " while expecting \":\".");
+ if (token != AdmLexer.TOKEN_COLON) {
+ throw new AsterixException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token)
+ + " while expecting \":\".");
}
token = nextToken();
@@ -436,7 +497,7 @@
break;
}
- case AdmLexerConstants.COMMA: {
+ case AdmLexer.TOKEN_COMMA: {
if (first) {
throw new AsterixException("Found COMMA before any record field.");
}
@@ -447,7 +508,7 @@
break;
}
default: {
- throw new AsterixException("Unexpected ADM token kind: " + admLexer.tokenKindToString(token.kind)
+ throw new AsterixException("Unexpected ADM token kind: " + AdmLexer.tokenKindToString(token)
+ " while parsing record fields.");
}
}
@@ -498,18 +559,18 @@
itemType = oltype.getItemType();
orderedListBuilder.reset(oltype);
- Token token = null;
+ int token;
boolean inList = true;
boolean expectingListItem = false;
boolean first = true;
do {
token = nextToken();
- if (token.kind == AdmLexerConstants.END_ORDERED_LIST) {
+ if (token == AdmLexer.TOKEN_END_ORDERED_LIST) {
if (expectingListItem) {
throw new AsterixException("Found END_COLLECTION while expecting a list item.");
}
inList = false;
- } else if (token.kind == AdmLexerConstants.COMMA) {
+ } else if (token == AdmLexer.TOKEN_COMMA) {
if (first) {
throw new AsterixException("Found COMMA before any list item.");
}
@@ -542,18 +603,18 @@
itemType = uoltype.getItemType();
unorderedListBuilder.reset(uoltype);
- Token token = null;
+ int token;
boolean inList = true;
boolean expectingListItem = false;
boolean first = true;
do {
token = nextToken();
- if (token.kind == AdmLexerConstants.END_UNORDERED_LIST) {
+ if (token == AdmLexer.TOKEN_END_UNORDERED_LIST) {
if (expectingListItem) {
throw new AsterixException("Found END_COLLECTION while expecting a list item.");
}
inList = false;
- } else if (token.kind == AdmLexerConstants.COMMA) {
+ } else if (token == AdmLexer.TOKEN_COMMA) {
if (first) {
throw new AsterixException("Found COMMA before any list item.");
}
@@ -574,11 +635,13 @@
returnTempBuffer(itemBuffer);
}
- private Token nextToken() throws AsterixException {
+ private int nextToken() throws AsterixException {
try {
return admLexer.next();
- } catch (ParseException pe) {
- throw new AsterixException(pe);
+ } catch (AdmLexerException e) {
+ throw new AsterixException(e);
+ } catch (IOException e) {
+ throw new AsterixException(e);
}
}
@@ -633,73 +696,109 @@
private void parseConstructor(ATypeTag typeTag, IAType objectType, DataOutput out) throws AsterixException {
try {
- Token token = admLexer.next();
- if (token.kind == AdmLexerConstants.CONSTRUCTOR_OPEN) {
+ int token = admLexer.next();
+ if (token == AdmLexer.TOKEN_CONSTRUCTOR_OPEN) {
if (checkType(typeTag, objectType, out)) {
token = admLexer.next();
- if (token.kind == AdmLexerConstants.STRING_LITERAL) {
+ if (token == AdmLexer.TOKEN_STRING_LITERAL) {
switch (typeTag) {
case BOOLEAN:
- parseBoolean(token.image.substring(1, token.image.length() - 1), out);
+ parseBoolean(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case INT8:
- parseInt8(token.image.substring(1, token.image.length() - 1), out);
+ parseInt8(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case INT16:
- parseInt16(token.image.substring(1, token.image.length() - 1), out);
+ parseInt16(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case INT32:
- parseInt32(token.image.substring(1, token.image.length() - 1), out);
+ parseInt32(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case INT64:
- parseInt64(token.image.substring(1, token.image.length() - 1), out);
+ parseInt64(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case FLOAT:
- aFloat.setValue(Float.parseFloat(token.image.substring(1, token.image.length() - 1)));
+ aFloat.setValue(Float.parseFloat(admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1)));
floatSerde.serialize(aFloat, out);
break;
case DOUBLE:
- aDouble.setValue(Double.parseDouble(token.image.substring(1, token.image.length() - 1)));
+ aDouble.setValue(Double.parseDouble(admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1)));
doubleSerde.serialize(aDouble, out);
break;
case STRING:
- aString.setValue(token.image.substring(1, token.image.length() - 1));
+ aString.setValue(admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1));
stringSerde.serialize(aString, out);
break;
case TIME:
- parseTime(token.image.substring(1, token.image.length() - 1), out);
+ parseTime(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case DATE:
- parseDate(token.image.substring(1, token.image.length() - 1), out);
+ parseDate(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case DATETIME:
- parseDatetime(token.image.substring(1, token.image.length() - 1), out);
+ parseDatetime(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case DURATION:
- parseDuration(token.image.substring(1, token.image.length() - 1), out);
+ parseDuration(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case POINT:
- parsePoint(token.image.substring(1, token.image.length() - 1), out);
+ parsePoint(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case POINT3D:
- parsePoint3d(token.image.substring(1, token.image.length() - 1), out);
+ parsePoint3d(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case CIRCLE:
- parseCircle(token.image.substring(1, token.image.length() - 1), out);
+ parseCircle(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case RECTANGLE:
- parseRectangle(token.image.substring(1, token.image.length() - 1), out);
+ parseRectangle(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case LINE:
- parseLine(token.image.substring(1, token.image.length() - 1), out);
+ parseLine(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
case POLYGON:
- parsePolygon(token.image.substring(1, token.image.length() - 1), out);
+ parsePolygon(
+ admLexer.getLastTokenImage().substring(1,
+ admLexer.getLastTokenImage().length() - 1), out);
break;
+ default:
+ throw new AsterixException("Missing deserializer method for constructor: "
+ + AdmLexer.tokenKindToString(token) + ".");
}
token = admLexer.next();
- if (token.kind == AdmLexerConstants.CONSTRUCTOR_CLOSE)
+ if (token == AdmLexer.TOKEN_CONSTRUCTOR_CLOSE)
return;
}
}
diff --git a/asterix-runtime/src/main/javacc/AdmLexer.jj b/asterix-runtime/src/main/javacc/AdmLexer.jj
deleted file mode 100644
index fbab62f..0000000
--- a/asterix-runtime/src/main/javacc/AdmLexer.jj
+++ /dev/null
@@ -1,150 +0,0 @@
-options {
-
-
- STATIC = false;
-
-}
-
-PARSER_BEGIN(AdmLexer)
-
-package edu.uci.ics.asterix.adm.parser;
-
-import java.io.*;
-
-public class AdmLexer {
-
- public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException {
- File file = new File(args[0]);
- Reader freader = new BufferedReader(new InputStreamReader
- (new FileInputStream(file), "UTF-8"));
- AdmLexer flexer = new AdmLexer(freader);
- Token t = null;
- do {
- t = flexer.next();
- System.out.println(AdmLexerConstants.tokenImage[t.kind]);
- } while (t.kind != EOF);
- freader.close();
- }
-
- public Token next() throws ParseException {
- return getNextToken();
- }
-
- public String tokenKindToString(int tokenKind) {
- return AdmLexerConstants.tokenImage[tokenKind];
- }
-}
-
-PARSER_END(AdmLexer)
-
-<DEFAULT>
-TOKEN :
-{
- <NULL_LITERAL : "null">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <TRUE_LITERAL : "true">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <FALSE_LITERAL : "false">
-}
-
-
-<DEFAULT>
-TOKEN :
-{
- <INTEGER_LITERAL : ("-")? (<DIGIT>)+ >
-}
-
-
-<DEFAULT>
-TOKEN :
-{
- <#DIGIT : ["0" - "9"]>
-}
-
-
-TOKEN:
-{
- < DOUBLE_LITERAL:
- ("-")? <INTEGER> ( "." <INTEGER> )? (<EXPONENT>)?
- | ("-")? "." <INTEGER>
- >
- | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
- | <INTEGER : (<DIGIT>)+ >
- | <FLOAT_LITERAL: <DOUBLE_LITERAL>("f"|"F")>
- }
-
-<DEFAULT>
-TOKEN :
-{
- <STRING_LITERAL : ("\"" (<EscapeQuot> | ~["\""])* "\"") >
- |
- < #EscapeQuot: "\\\"" >
-}
-
-<DEFAULT>
-TOKEN :
-{
- <START_RECORD : "{">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <END_RECORD : "}">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <COMMA : ",">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <COLON : ":">
-}
-
-
-<DEFAULT>
-TOKEN :
-{
- <START_ORDERED_LIST : "[">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <END_ORDERED_LIST : "]">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <START_UNORDERED_LIST : "{{">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <END_UNORDERED_LIST : "}}">
-}
-
-
-
-
-SKIP:
-{
- " "
-| "\t"
-| "\r"
-| "\n"
-}
diff --git a/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj b/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj
deleted file mode 100644
index d94033d..0000000
--- a/asterix-runtime/src/main/javacc/nontagged/AdmLexer.jj
+++ /dev/null
@@ -1,385 +0,0 @@
-options {
-
-
- STATIC = false;
-
-}
-
-PARSER_BEGIN(AdmLexer)
-
-package edu.uci.ics.asterix.adm.parser.nontagged;
-
-import java.io.*;
-
-public class AdmLexer {
-
- public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException {
- File file = new File(args[0]);
- Reader freader = new BufferedReader(new InputStreamReader
- (new FileInputStream(file), "UTF-8"));
- AdmLexer flexer = new AdmLexer(freader);
- Token t = null;
- do {
- t = flexer.next();
- System.out.println(AdmLexerConstants.tokenImage[t.kind]);
- } while (t.kind != EOF);
- freader.close();
- }
-
- public Token next() throws ParseException {
- return getNextToken();
- }
-
- public String tokenKindToString(int tokenKind) {
- return AdmLexerConstants.tokenImage[tokenKind];
- }
-}
-
-PARSER_END(AdmLexer)
-
-<DEFAULT>
-TOKEN :
-{
- <NULL_LITERAL : "null">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <TRUE_LITERAL : "true">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <FALSE_LITERAL : "false">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <BOOLEAN_CONS : ("boolean") >
-}
-
-<DEFAULT>
-TOKEN :
-{
- <CONSTRUCTOR_OPEN : ("(")>
-}
-
-
-<DEFAULT>
-TOKEN :
-{
- <CONSTRUCTOR_CLOSE : (")")>
-}
-
-<DEFAULT>
-TOKEN:
-{
- <INT8_LITERAL : ("-" | "+")? (<DIGIT>)+ ("i8")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <INT8_CONS : ("int8") >
-}
-
-<DEFAULT>
-TOKEN:
-{
- <INT16_LITERAL : ("-" | "+")? (<DIGIT>)+ ("i16")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <INT16_CONS : ("int16") >
-}
-
-<DEFAULT>
-TOKEN :
-{
- <INT32_LITERAL : ("-" | "+")? (<DIGIT>)+ ("i32")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <INT32_CONS : ("int32")>
-}
-
-<DEFAULT>
-TOKEN:
-{
- <INT64_LITERAL : ("-" | "+")? (<DIGIT>)+ ("i64")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <INT64_CONS : ("int64") >
-}
-
-<DEFAULT>
-TOKEN:
-{
- <INT_LITERAL : ("-" | "+")? (<DIGIT>)+>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <CIRCLE_LITERAL : "P"<DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> ("R") <DOUBLE_LITERAL> >
-}
-
-<DEFAULT>
-TOKEN :
-{
- <CIRCLE_CONS : ("circle") >
-}
-
-
-<DEFAULT>
-TOKEN :
-{
- <TIMEZONE_LITERAL : (("+"|"-")<DIGIT><DIGIT>(":")<DIGIT><DIGIT>) | (("+"|"-")<DIGIT><DIGIT><DIGIT><DIGIT>) | ("Z") >
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DATE_LITERAL : (("-")?<DIGIT><DIGIT><DIGIT><DIGIT>("-")<DIGIT><DIGIT>("-")<DIGIT><DIGIT>) | (("-")?<DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT>) >
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DATE_CONS : ("date")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <TIME_LITERAL : (<DIGIT><DIGIT>(":")<DIGIT><DIGIT>(":")<DIGIT><DIGIT> ( (".")<DIGIT>(<DIGIT>((<DIGIT>)?))?)? ((("+"|"-")<DIGIT><DIGIT>(":")<DIGIT><DIGIT>) | ("Z"))?) | (<DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT> (<DIGIT>(<DIGIT>((<DIGIT>)?))?)? ((("+"|"-")<DIGIT><DIGIT><DIGIT><DIGIT>) | ("Z"))?) >
-}
-
-<DEFAULT>
-TOKEN :
-{
- <TIME_CONS : ("time")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DATETIME_LITERAL : (("-")?<DIGIT><DIGIT><DIGIT><DIGIT>("-")<DIGIT><DIGIT>("-")<DIGIT><DIGIT>("T")<DIGIT><DIGIT>(":")<DIGIT><DIGIT>(":")<DIGIT><DIGIT> ( (".")<DIGIT>(<DIGIT>((<DIGIT>)?))?)? ((("+"|"-")<DIGIT><DIGIT>(":")<DIGIT><DIGIT>) | ("Z"))?) | (("-")?<DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT>("T")<DIGIT><DIGIT><DIGIT><DIGIT><DIGIT><DIGIT> (<DIGIT>(<DIGIT>((<DIGIT>)?))?)? ((("+"|"-")<DIGIT><DIGIT><DIGIT><DIGIT>) | ("Z"))?)>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DATETIME_CONS : ("datetime")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DURATION_LITERAL : ("-")? ("P")(<INTEGER>("Y"))?(<INTEGER>("M"))?(<INTEGER>("D"))?(("T")(((<INTEGER>("H"))(<INTEGER>("M"))?(<INTEGER>((".")<DIGIT>(<DIGIT>(<DIGIT>)?)?)?("S"))?) | ((<INTEGER>("M"))(<INTEGER>((".")<DIGIT>(<DIGIT>(<DIGIT>)?)?)?("S"))?) | ((<INTEGER>((".")<DIGIT>(<DIGIT>(<DIGIT>)?)?)?("S")))))?>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DURATION_CONS : ("duration")>
-}
-
-<DEFAULT>
-TOKEN :
-{
<INTERVAL_CONS : ("interval")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <TIME_INTERVAL_CONS : ("tinterval")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DATE_INTERVAL_CONS : ("dinterval")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DATETIME_INTERVAL_CONS : ("dtinterval")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <#DIGIT : ["0" - "9"]>
-}
-
-TOKEN:
-{
- < DOUBLE_LITERAL:
- ("-" | "+")? <INTEGER> ( "." <INTEGER> )? (<EXPONENT>)?
- | ("-" | "+")? "." <INTEGER>
- >
- | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
- | <INTEGER : (<DIGIT>)+ >
- | <FLOAT_LITERAL: <DOUBLE_LITERAL>("f"|"F")>
- }
-
-
-<DEFAULT>
-TOKEN :
-{
- <FLOAT_CONS : ("float")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <DOUBLE_CONS : ("double")>
-}
-
-
-<DEFAULT>
-TOKEN :
-{
- <STRING_LITERAL : ("\"" (<EscapeQuot> | ~["\""])* "\"") >
- |
- < #EscapeQuot: "\\\"" >
-}
-
-<DEFAULT>
-TOKEN :
-{
- <STRING_CONS : ("string")>
-}
-
-
-<DEFAULT>
-TOKEN :
-{
- <POINT_LITERAL : "P"<DOUBLE_LITERAL>(",")<DOUBLE_LITERAL>>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <POINT_CONS : ("point")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <POINT3D_LITERAL : "P" <DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL>>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <POINT3D_CONS : ("point3d")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <LINE_LITERAL : "P"<DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> ("P") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL>>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <LINE_CONS : ("line")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <POLYGON_LITERAL : "P"<DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> ("P") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL> (("P") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL>)+>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <POLYGON_CONS : ("polygon")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <RECTANGLE_CONS : ("rectangle")>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <RECTANGLE_LITERAL : "P"<DOUBLE_LITERAL>(",") <DOUBLE_LITERAL> ("P") <DOUBLE_LITERAL> (",") <DOUBLE_LITERAL>>
-}
-
-<DEFAULT>
-TOKEN :
-{
- <START_RECORD : "{">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <END_RECORD : "}">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <COMMA : ",">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <COLON : ":">
-}
-
-
-<DEFAULT>
-TOKEN :
-{
- <START_ORDERED_LIST : "[">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <END_ORDERED_LIST : "]">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <START_UNORDERED_LIST : "{{">
-}
-
-<DEFAULT>
-TOKEN :
-{
- <END_UNORDERED_LIST : "}}">
-}
-
-
-
-
-SKIP:
-{
- " "
-| "\t"
-| "\r"
-| "\n"
-}
diff --git a/asterix-runtime/src/main/resources/adm.grammar b/asterix-runtime/src/main/resources/adm.grammar
new file mode 100644
index 0000000..56c7212
--- /dev/null
+++ b/asterix-runtime/src/main/resources/adm.grammar
@@ -0,0 +1,63 @@
+# LEXER GENERATOR configuration file
+# ---------------------------------------
+# Place *first* the generic configuration
+# then list your grammar.
+
+PACKAGE: edu.uci.ics.asterix.runtime.operators.file.adm
+LEXER_NAME: AdmLexer
+
+TOKENS:
+
+BOOLEAN_CONS = string(boolean)
+INT8_CONS = string(int8)
+INT16_CONS = string(int16)
+INT32_CONS = string(int32)
+INT64_CONS = string(int64)
+FLOAT_CONS = string(float)
+DOUBLE_CONS = string(double)
+DATE_CONS = string(date)
+DATETIME_CONS = string(datetime)
+DURATION_CONS = string(duration)
+STRING_CONS = string(string)
+POINT_CONS = string(point)
+POINT3D_CONS = string(point3d)
+LINE_CONS = string(line)
+POLYGON_CONS = string(polygon)
+RECTANGLE_CONS = string(rectangle)
+CIRCLE_CONS = string(circle)
+TIME_CONS = string(time)
+INTERVAL_TIME_CONS = string(interval_time)
+INTERVAL_DATE_CONS = string(interval_date)
+INTERVAL_DATETIME_CONS = string(interval_datetime)
+
+NULL_LITERAL = string(null)
+TRUE_LITERAL = string(true)
+FALSE_LITERAL = string(false)
+
+CONSTRUCTOR_OPEN = char(()
+CONSTRUCTOR_CLOSE = char())
+START_RECORD = char({)
+END_RECORD = char(})
+COMMA = char(\,)
+COLON = char(:)
+START_ORDERED_LIST = char([)
+END_ORDERED_LIST = char(])
+START_UNORDERED_LIST = string({{)
+END_UNORDERED_LIST = string(}})
+
+STRING_LITERAL = char("), anythingUntil(")
+
+INT_LITERAL = signOrNothing(), digitSequence()
+INT8_LITERAL = token(INT_LITERAL), string(i8)
+INT16_LITERAL = token(INT_LITERAL), string(i16)
+INT32_LITERAL = token(INT_LITERAL), string(i32)
+INT64_LITERAL = token(INT_LITERAL), string(i64)
+
+@EXPONENT = caseInsensitiveChar(e), signOrNothing(), digitSequence()
+
+DOUBLE_LITERAL = signOrNothing(), char(.), digitSequence()
+DOUBLE_LITERAL = signOrNothing(), digitSequence(), char(.), digitSequence()
+DOUBLE_LITERAL = signOrNothing(), digitSequence(), char(.), digitSequence(), token(@EXPONENT)
+DOUBLE_LITERAL = signOrNothing(), digitSequence(), token(@EXPONENT)
+
+FLOAT_LITERAL = token(DOUBLE_LITERAL), caseInsensitiveChar(f)
diff --git a/asterix-test-framework/pom.xml b/asterix-test-framework/pom.xml
index 2f0142e..9462b5d 100755
--- a/asterix-test-framework/pom.xml
+++ b/asterix-test-framework/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>asterix</artifactId>
@@ -13,21 +14,21 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
- <plugin>
- <groupId>org.jvnet.jaxb2.maven2</groupId>
- <artifactId>maven-jaxb2-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/asterix-tools/pom.xml b/asterix-tools/pom.xml
index 62176d9..0440618 100644
--- a/asterix-tools/pom.xml
+++ b/asterix-tools/pom.xml
@@ -15,8 +15,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
<plugin>
diff --git a/asterix-transactions/pom.xml b/asterix-transactions/pom.xml
index 7db5cd9..a402077 100644
--- a/asterix-transactions/pom.xml
+++ b/asterix-transactions/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>asterix</artifactId>
@@ -16,8 +17,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
</plugins>
@@ -25,9 +26,9 @@
</build>
<dependencies>
- <dependency>
- <groupId>edu.uci.ics.hyracks</groupId>
- <artifactId>hyracks-storage-am-common</artifactId>
- </dependency>
+ <dependency>
+ <groupId>edu.uci.ics.hyracks</groupId>
+ <artifactId>hyracks-storage-am-common</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/pom.xml b/pom.xml
index ef66149..e13d3c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,7 @@
<module>asterix-events</module>
<module>asterix-dist</module>
<module>asterix-test-framework</module>
+ <module>asterix-maven-plugins</module>
</modules>
<repositories>