private DataOutputStream getIndexStream ( int keyLength ) throws IOException { // Resize array if necessary if ( indexStreams . length <= keyLength ) { indexStreams = Arrays . copyOf ( indexStreams , keyLength + 1 ) ; indexFiles = Arrays . copyOf ( indexFiles , keyLength + 1 ) ; keyCounts = Arrays . copyOf ( keyCounts , keyLength + 1 ) ; maxOffsetLengths = Arrays . copyOf ( maxOffsetLengths , keyLength + 1 ) ; lastValues = Arrays . copyOf ( lastValues , keyLength + 1 ) ; lastValuesLength = Arrays . copyOf ( lastValuesLength , keyLength + 1 ) ; dataLengths = Arrays . copyOf ( dataLengths , keyLength + 1 ) ; } // Get or create stream DataOutputStream dos = indexStreams [ keyLength ] ; if ( dos == null ) { File file = new File ( tempFolder , "temp_index" + keyLength + ".dat" ) ; file . deleteOnExit ( ) ; indexFiles [ keyLength ] = file ; dos = new DataOutputStream ( new BufferedOutputStream ( new FileOutputStream ( file ) ) ) ; indexStreams [ keyLength ] = dos ; dataLengths [ keyLength ] ++ ; } return dos ; }
Get the index stream for the specified keyLength create it if needed