added checks for field name conflicts between two closed fields and open-closed fields
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_issue_173@1211 eaa15691-b419-025a-1212-ee371bd00084
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..028be17 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
@@ -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..e1080dc 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
@@ -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..09f2ec8 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,6 @@
package edu.uci.ics.asterix.optimizer.rules.am;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -44,7 +45,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 +111,7 @@
analysisCtx.matchedFuncExprs.add(new OptimizableFuncExpr(funcExpr, fieldVar, constFilterVal));
return true;
}
-
+
public static boolean analyzeFuncExprArgsForTwoVars(AbstractFunctionCallExpression funcExpr,
AccessMethodAnalysisContext analysisCtx) {
LogicalVariable fieldVar1 = null;
@@ -180,7 +182,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 +235,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 +305,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..37af6e9 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,6 @@
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 +206,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 +239,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 +391,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 +526,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..deebdbc 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
@@ -29,6 +29,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 +90,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 +186,7 @@
}
t = dt.getDatatype();
} else {
- t = typeMap.get(typeSignature);
+ t = typeMap.get(typeSignature);
}
for (AbstractCollectionType act : incompleteItemTypes.get(typeSignature)) {
act.setItemType(t);
@@ -191,7 +196,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 +208,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 +220,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 +313,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 +326,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/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..1ea4231 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
@@ -15,6 +15,7 @@
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 +330,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..3bcce70 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,7 @@
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 +138,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 +159,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 +291,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/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-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..82f3d16 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
@@ -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..1651433 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
@@ -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..70eafb9 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
@@ -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..8719879 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
@@ -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..7805424 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
@@ -22,6 +22,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 +77,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 +95,8 @@
try {
externalRecordBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new HyracksDataException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new HyracksDataException(e);
}
}
@@ -121,8 +123,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..93ba57b 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
@@ -23,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.common.functions.FunctionSignature;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.metadata.bootstrap.MetadataRecordTypes;
@@ -160,8 +161,8 @@
try {
feedRecordBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new HyracksDataException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new HyracksDataException(e);
}
}
@@ -188,8 +189,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..fcc7d0b 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
@@ -22,6 +22,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 +147,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..a8b91ad 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
@@ -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..fd0d3bf 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
@@ -20,6 +20,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 +65,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 +78,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 +123,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..e266ff7 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
@@ -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..2fefa4e 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
@@ -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..d3c2bb0 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
@@ -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..90e81fb 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
@@ -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..fe34334 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
@@ -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..ba25eb6 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
@@ -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..555c853 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,6 @@
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 +26,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 +45,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 +65,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/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java b/asterix-om/src/main/java/edu/uci/ics/asterix/builders/IARecordBuilder.java
index cb7f902..4542d76 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
@@ -20,7 +20,6 @@
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.types.ARecordType;
-import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.data.std.api.IValueReference;
/**
@@ -51,8 +50,9 @@
* The field name.
* @param out
* The field value.
+ * @throws AsterixException
*/
- public void addField(IValueReference name, IValueReference value);
+ public void addField(IValueReference name, IValueReference value) throws AsterixException;
/**
* @param out
@@ -63,7 +63,7 @@
* @throws IOException
* @throws AsterixException
*/
- public void write(DataOutput out, boolean writeTypeTag) throws IOException, HyracksDataException;
+ 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 92c03b1..2442634 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
@@ -7,13 +7,13 @@
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.api.exceptions.HyracksDataException;
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;
@@ -141,13 +141,21 @@
}
@Override
- public void addField(IValueReference name, IValueReference value) {
+ public void addField(IValueReference name, IValueReference value) throws AsterixException {
if (numberOfOpenFields == openPartOffsets.length) {
openPartOffsets = Arrays.copyOf(openPartOffsets, openPartOffsets.length + DEFAULT_NUM_OPEN_FIELDS);
openFieldNameLengths = Arrays.copyOf(openFieldNameLengths, openFieldNameLengths.length
+ DEFAULT_NUM_OPEN_FIELDS);
}
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 has the same field name as closed field " + cFieldPos + " \""
+ + recType.getFieldNames()[cFieldPos] + "\"");
+ }
+ }
openPartOffsets[this.numberOfOpenFields] = fieldNameHashCode;
openPartOffsets[this.numberOfOpenFields] = (openPartOffsets[numberOfOpenFields] << 32);
openPartOffsets[numberOfOpenFields] += openPartOutputStream.size();
@@ -157,7 +165,7 @@
}
@Override
- public void write(DataOutput out, boolean writeTypeTag) throws HyracksDataException, IOException {
+ public void write(DataOutput out, boolean writeTypeTag) throws IOException, AsterixException {
int h = headerSize;
int recordLength;
// prepare the open part
@@ -177,7 +185,7 @@
String field = UTF8StringSerializerDeserializer.INSTANCE
.deserialize(new DataInputStream(new ByteArrayInputStream(openBytes,
(int) openPartOffsets[i], openFieldNameLengths[i])));
- throw new HyracksDataException("Open fields " + (i - 1) + " and " + i
+ throw new AsterixException("Open fields " + (i - 1) + " and " + i
+ " have the same field name \"" + field + "\"");
}
}
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..bcd71be 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
@@ -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..b372ca4 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
@@ -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..15da765 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
@@ -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..9099acc 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
@@ -3,6 +3,7 @@
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 +24,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..92fa7ca 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
@@ -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..6a594b4 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
@@ -4,6 +4,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;
@@ -58,6 +59,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..6a980cb 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,23 @@
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 +26,87 @@
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[];
+
+ 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 HyracksDataException(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();
+ }
+
+ 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 +152,15 @@
return isOpen;
}
- public int findFieldPosition(String fldName) {
- for (int i = 0; i < fieldNames.length; i++) {
- if (fieldNames[i].equals(fldName)) {
- return i;
- }
- }
- return -1;
+ 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 +192,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/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..83326fa 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
@@ -6,6 +6,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 +60,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..c97efbb 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
@@ -6,6 +6,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 +64,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/std/AvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
index 4fe5e35..ebd5a19 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
@@ -7,6 +7,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 +65,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 _recType;
+ try {
+ _recType = 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 = _recType;
return new ICopyAggregateFunctionFactory() {
private static final long serialVersionUID = 1L;
@@ -78,7 +86,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 +123,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 +137,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..3d92f13 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
@@ -6,7 +6,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 +61,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 _recType;
+ try {
+ _recType = 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 = _recType;
return new ICopyAggregateFunctionFactory() {
private static final long serialVersionUID = 1L;
@@ -114,7 +121,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..89ff3b2 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
@@ -6,7 +6,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 +72,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 _recType;
+ try {
+ _recType = 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 = _recType;
return new ICopyAggregateFunction() {
@@ -204,5 +211,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..99c3f5b 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
@@ -5,6 +5,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 +73,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..dcd70d6 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
@@ -4,6 +4,7 @@
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 +87,8 @@
}
}
recBuilder.write(out, true);
- } catch (IOException ioe) {
- throw new AlgebricksException(ioe);
+ } catch (IOException | AsterixException e) {
+ throw new AlgebricksException(e);
}
}
};