public static void parseJsonToSingleRowBlock ( JsonParser parser , SingleRowBlockWriter singleRowBlockWriter , BlockBuilderAppender [ ] fieldAppenders , Optional < Map < String , Integer > > fieldNameToIndex ) throws IOException { if ( parser . getCurrentToken ( ) == START_ARRAY ) { for ( int i = 0 ; i < fieldAppenders . length ; i ++ ) { parser . nextToken ( ) ; fieldAppenders [ i ] . append ( parser , singleRowBlockWriter ) ; } if ( parser . nextToken ( ) != JsonToken . END_ARRAY ) { throw new JsonCastException ( format ( "Expected json array ending, but got %s" , parser . getText ( ) ) ) ; } } else { verify ( parser . getCurrentToken ( ) == START_OBJECT ) ; if ( ! fieldNameToIndex . isPresent ( ) ) { throw new JsonCastException ( "Cannot cast a JSON object to anonymous row type. Input must be a JSON array." ) ; } boolean [ ] fieldWritten = new boolean [ fieldAppenders . length ] ; int numFieldsWritten = 0 ; while ( parser . nextToken ( ) != JsonToken . END_OBJECT ) { if ( parser . currentToken ( ) != FIELD_NAME ) { throw new JsonCastException ( format ( "Expected a json field name, but got %s" , parser . getText ( ) ) ) ; } String fieldName = parser . getText ( ) . toLowerCase ( Locale . ENGLISH ) ; Integer fieldIndex = fieldNameToIndex . get ( ) . get ( fieldName ) ; parser . nextToken ( ) ; if ( fieldIndex != null ) { if ( fieldWritten [ fieldIndex ] ) { throw new JsonCastException ( "Duplicate field: " + fieldName ) ; } fieldWritten [ fieldIndex ] = true ; numFieldsWritten ++ ; fieldAppenders [ fieldIndex ] . append ( parser , singleRowBlockWriter . getFieldBlockBuilder ( fieldIndex ) ) ; } else { parser . skipChildren ( ) ; } } if ( numFieldsWritten != fieldAppenders . length ) { for ( int i = 0 ; i < fieldWritten . length ; i ++ ) { if ( ! fieldWritten [ i ] ) { singleRowBlockWriter . getFieldBlockBuilder ( i ) . appendNull ( ) ; } } } } }
Thus there will be single call to this method so this method can be inlined .