private FieldSchema messageToFieldSchema ( FieldDescriptor fieldDescriptor ) throws FrontendException { assert fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE : "messageToFieldSchema called with field of type " + fieldDescriptor . getType ( ) ; Schema innerSchema = toSchema ( fieldDescriptor . getMessageType ( ) ) ; if ( fieldDescriptor . isRepeated ( ) ) { Schema tupleSchema = new Schema ( ) ; tupleSchema . add ( new FieldSchema ( fieldDescriptor . getName ( ) + "_tuple" , innerSchema , DataType . TUPLE ) ) ; return new FieldSchema ( fieldDescriptor . getName ( ) , tupleSchema , DataType . BAG ) ; } else { return new FieldSchema ( fieldDescriptor . getName ( ) , innerSchema , DataType . TUPLE ) ; } }
Turn a nested message into a Schema object . For repeated nested messages it generates a schema for a bag of tuples . For non - repeated nested messages it just generates a schema for the tuple itself .