use of org.apache.asterix.om.types.AbstractComplexType in project asterixdb by apache.
the class MetadataNode method confirmDatatypeIsUnusedByDatatypes.
private void confirmDatatypeIsUnusedByDatatypes(JobId jobId, String dataverseName, String datatypeName) throws MetadataException, RemoteException {
//If any datatype uses this type, throw an error
//TODO: Currently this loads all types into memory. This will need to be fixed for large numbers of types
Datatype dataTypeToBeDropped = getDatatype(jobId, dataverseName, datatypeName);
assert dataTypeToBeDropped != null;
IAType typeToBeDropped = dataTypeToBeDropped.getDatatype();
List<Datatype> datatypes = getAllDatatypes(jobId);
for (Datatype dataType : datatypes) {
//skip types in different dataverses as well as the type to be dropped itself
if (!dataType.getDataverseName().equals(dataverseName) || dataType.getDatatype().getTypeName().equals(datatypeName)) {
continue;
}
AbstractComplexType recType = (AbstractComplexType) dataType.getDatatype();
if (recType.containsType(typeToBeDropped)) {
throw new MetadataException("Cannot drop type " + dataverseName + "." + datatypeName + " being used by type " + dataverseName + "." + recType.getTypeName());
}
}
}
use of org.apache.asterix.om.types.AbstractComplexType in project asterixdb by apache.
the class TypeTranslator method computeTypes.
public static Map<TypeSignature, IAType> computeTypes(MetadataTransactionContext mdTxnCtx, TypeExpression typeExpr, String typeName, String typeDataverse, Map<TypeSignature, IAType> typeMap) throws AlgebricksException {
Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes = new HashMap<>();
Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes = new HashMap<>();
Map<TypeSignature, List<TypeSignature>> incompleteTopLevelTypeReferences = new HashMap<>();
firstPass(typeExpr, typeName, typeMap, incompleteFieldTypes, incompleteItemTypes, incompleteTopLevelTypeReferences, typeDataverse);
secondPass(mdTxnCtx, typeMap, incompleteFieldTypes, incompleteItemTypes, incompleteTopLevelTypeReferences, typeDataverse);
for (IAType type : typeMap.values()) {
if (type.getTypeTag().isDerivedType()) {
((AbstractComplexType) type).generateNestedDerivedTypeNames();
}
}
return typeMap;
}
Aggregations