public void readFields ( DataInput in ) throws IOException { // read UGI type first String ugiType = Text . readString ( in ) ; if ( ! UGI_TECHNOLOGY . equals ( ugiType ) ) { throw new IOException ( "Expect UGI prefix: " + UGI_TECHNOLOGY + ", but receive a prefix: " + ugiType ) ; } // read this object userName = Text . readString ( in ) ; int numOfGroups = WritableUtils . readVInt ( in ) ; groupNames = new String [ numOfGroups ] ; for ( int i = 0 ; i < numOfGroups ; i ++ ) { groupNames [ i ] = Text . readString ( in ) ; } }
Deserialize this object First check if this is a UGI in the string format . If no throw an IOException ; otherwise set this object s fields by reading them from the given data input