Search in sources :

Example 6 with TypeExpression

use of org.apache.asterix.lang.common.expression.TypeExpression in project asterixdb by apache.

the class QueryPrintVisitor method visit.

@Override
public Void visit(RecordTypeDefinition r, Integer step) throws CompilationException {
    if (r.getRecordKind() == RecordKind.CLOSED) {
        out.print(skip(step) + "closed ");
    } else {
        out.print(skip(step) + "open ");
    }
    out.println("RecordType {");
    Iterator<String> nameIter = r.getFieldNames().iterator();
    Iterator<TypeExpression> typeIter = r.getFieldTypes().iterator();
    Iterator<Boolean> isOptionalIter = r.getOptionableFields().iterator();
    boolean first = true;
    while (nameIter.hasNext()) {
        if (first) {
            first = false;
        } else {
            out.println(",");
        }
        String name = nameIter.next();
        TypeExpression texp = typeIter.next();
        Boolean isNullable = isOptionalIter.next();
        out.print(skip(step + 1) + name + " : ");
        texp.accept(this, step + 2);
        if (isNullable) {
            out.print("?");
        }
    }
    out.println();
    out.println(skip(step) + "}");
    return null;
}
Also used : TypeExpression(org.apache.asterix.lang.common.expression.TypeExpression)

Aggregations

TypeExpression (org.apache.asterix.lang.common.expression.TypeExpression)6 ARecordType (org.apache.asterix.om.types.ARecordType)2 IAType (org.apache.asterix.om.types.IAType)2 TypeSignature (org.apache.asterix.om.types.TypeSignature)2 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 IRecordFieldDataGen (org.apache.asterix.common.annotations.IRecordFieldDataGen)1 RecordDataGenAnnotation (org.apache.asterix.common.annotations.RecordDataGenAnnotation)1 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1 AsterixException (org.apache.asterix.common.exceptions.AsterixException)1 CompilationException (org.apache.asterix.common.exceptions.CompilationException)1 IDataset (org.apache.asterix.common.metadata.IDataset)1 ProgressState (org.apache.asterix.common.utils.JobUtils.ProgressState)1 ExternalFile (org.apache.asterix.external.indexing.ExternalFile)1 OrderedListTypeDefinition (org.apache.asterix.lang.common.expression.OrderedListTypeDefinition)1 RecordTypeDefinition (org.apache.asterix.lang.common.expression.RecordTypeDefinition)1 TypeReferenceExpression (org.apache.asterix.lang.common.expression.TypeReferenceExpression)1