private StringBuffer singleFieldToPigScript ( FieldDescriptor fieldDescriptor , int numTabs , boolean isLast ) throws FrontendException { assert fieldDescriptor . getType ( ) != FieldDescriptor . Type . MESSAGE : "singleFieldToPigScript called with field of type " + fieldDescriptor . getType ( ) ; if ( fieldDescriptor . isRepeated ( ) ) { return new StringBuffer ( ) . append ( tabs ( numTabs ) ) . append ( fieldDescriptor . getName ( ) ) . append ( "_bag: bag {" ) . append ( "\n" ) . append ( tabs ( numTabs + 1 ) ) . append ( fieldDescriptor . getName ( ) ) . append ( "_tuple: tuple (" ) . append ( "\n" ) . append ( tabs ( numTabs + 2 ) ) . append ( fieldDescriptor . getName ( ) ) . append ( ": " ) . append ( getPigScriptDataType ( fieldDescriptor ) ) . append ( "\n" ) . append ( tabs ( numTabs + 1 ) ) . append ( ")" ) . append ( "\n" ) . append ( tabs ( numTabs ) ) . append ( "}" ) . append ( isLast ? "" : "," ) . append ( "\n" ) ; } else { return new StringBuffer ( ) . append ( tabs ( numTabs ) ) . append ( fieldDescriptor . getName ( ) ) . append ( ": " ) . append ( getPigScriptDataType ( fieldDescriptor ) ) . append ( isLast ? "" : "," ) . append ( "\n" ) ; } }
Turn a single field into a pig script load string . For repeated single fields it generates a string for a bag of single - item tuples . For non - repeated fields it just generates a standard single - element string .