@ Override public Object deserialize ( Writable blob ) throws SerDeException { Text t = ( Text ) blob ; JsonParser p ; List < Object > r = new ArrayList < Object > ( Collections . nCopies ( columnNames . size ( ) , null ) ) ; try { p = jsonFactory . createJsonParser ( new ByteArrayInputStream ( ( t . getBytes ( ) ) ) ) ; if ( p . nextToken ( ) != JsonToken . START_OBJECT ) { throw new IOException ( "Start token not found where expected" ) ; } JsonToken token ; while ( ( ( token = p . nextToken ( ) ) != JsonToken . END_OBJECT ) && ( token != null ) ) { // iterate through each token, and create appropriate object here. populateRecord ( r , token , p , schema ) ; } } catch ( JsonParseException e ) { LOG . warn ( "Error [{}] parsing json text [{}]." , e , t ) ; LOG . debug ( null , e ) ; throw new SerDeException ( e ) ; } catch ( IOException e ) { LOG . warn ( "Error [{}] parsing json text [{}]." , e , t ) ; LOG . debug ( null , e ) ; throw new SerDeException ( e ) ; } return new DefaultHCatRecord ( r ) ; }
Takes JSON string in Text form and has to return an object representation above it that s readable by the corresponding object inspector .