private void copyObjectAndUpdateStats ( int id , IndexInput in , Long inRef , IndexOutput out ) throws IOException { int mtasId ; int objectFlags ; // read in . seek ( inRef ) ; mtasId = in . readVInt ( ) ; assert id == mtasId : "wrong id detected while copying object" ; objectFlags = in . readVInt ( ) ; out . writeVInt ( mtasId ) ; out . writeVInt ( objectFlags ) ; if ( ( objectFlags & MtasCodecPostingsFormat . MTAS_OBJECT_HAS_PARENT ) == MtasCodecPostingsFormat . MTAS_OBJECT_HAS_PARENT ) { out . writeVInt ( in . readVInt ( ) ) ; } if ( ( objectFlags & MtasCodecPostingsFormat . MTAS_OBJECT_HAS_POSITION_RANGE ) == MtasCodecPostingsFormat . MTAS_OBJECT_HAS_POSITION_RANGE ) { int minPos = in . readVInt ( ) ; int maxPos = in . readVInt ( ) ; out . writeVInt ( minPos ) ; out . writeVInt ( maxPos ) ; tokenStatsAdd ( minPos , maxPos ) ; } else if ( ( objectFlags & MtasCodecPostingsFormat . MTAS_OBJECT_HAS_POSITION_SET ) == MtasCodecPostingsFormat . MTAS_OBJECT_HAS_POSITION_SET ) { int size = in . readVInt ( ) ; out . writeVInt ( size ) ; SortedSet < Integer > list = new TreeSet <> ( ) ; int previousPosition = 0 ; for ( int t = 0 ; t < size ; t ++ ) { int pos = in . readVInt ( ) ; out . writeVInt ( pos ) ; previousPosition = ( pos + previousPosition ) ; list . add ( previousPosition ) ; } assert list . size ( ) == size : "duplicate positions in set are not allowed" ; tokenStatsAdd ( list . first ( ) , list . last ( ) ) ; } else { int pos = in . readVInt ( ) ; out . writeVInt ( pos ) ; tokenStatsAdd ( pos , pos ) ; } if ( ( objectFlags & MtasCodecPostingsFormat . MTAS_OBJECT_HAS_OFFSET ) == MtasCodecPostingsFormat . MTAS_OBJECT_HAS_OFFSET ) { out . writeVInt ( in . readVInt ( ) ) ; out . writeVInt ( in . readVInt ( ) ) ; } if ( ( objectFlags & MtasCodecPostingsFormat . MTAS_OBJECT_HAS_REALOFFSET ) == MtasCodecPostingsFormat . MTAS_OBJECT_HAS_REALOFFSET ) { out . writeVInt ( in . readVInt ( ) ) ; out . writeVInt ( in . readVInt ( ) ) ; } if ( ( objectFlags & MtasCodecPostingsFormat . MTAS_OBJECT_HAS_PAYLOAD ) == MtasCodecPostingsFormat . MTAS_OBJECT_HAS_PAYLOAD ) { int length = in . readVInt ( ) ; out . writeVInt ( length ) ; byte [ ] payload = new byte [ length ] ; in . readBytes ( payload , 0 , length ) ; out . writeBytes ( payload , payload . length ) ; } out . writeVLong ( in . readVLong ( ) ) ; }
Copy object and update stats .