private static Pair<Long,Long> load(ByteArray a,InputStream stream,long memoryOffset,long count,CommonIndex positions,CRC32 checksum,ByteArray checksums,PrereadHashFunction hf,boolean checksumsLoaded,long currentSeq) throws IOException {
  long tmpCurrentSeq=currentSeq;
  final byte[] buffer=new byte[1024 * 1024];
  long totalRead=0;
  int bytesRead;
  long pos=memoryOffset;
  while (totalRead < count && (bytesRead=stream.read(buffer,0,(int)Math.min(count - totalRead,buffer.length))) != -1) {
    a.set(pos,buffer,bytesRead);
    pos+=bytesRead;
    int j=0;
    while (j < bytesRead) {
      if (positions.get(tmpCurrentSeq + 1) == positions.get(tmpCurrentSeq)) {
        hf.irvineHash(0L);
        tmpCurrentSeq++;
        continue;
      }
      final int len=(int)(positions.get(tmpCurrentSeq + 1) - (memoryOffset + totalRead + j));
      if (j + len <= bytesRead) {
        checksum.update(buffer,j,len);
        hf.irvineHash(buffer,j,len);
        hf.irvineHash(positions.get(tmpCurrentSeq + 1) - positions.get(tmpCurrentSeq));
        if (checksumsLoaded) {
          if ((byte)checksum.getValue() != checksums.get(tmpCurrentSeq)) {
            throw new CorruptSdfException("Sequence: " + tmpCurrentSeq + " failed checksum");
          }
        }
 else {
          checksums.set(tmpCurrentSeq,(byte)checksum.getValue());
        }
        tmpCurrentSeq++;
        checksum.reset();
      }
 else {
        hf.irvineHash(buffer,j,bytesRead - j);
        checksum.update(buffer,j,bytesRead - j);
      }
      j+=len;
    }
    totalRead+=bytesRead;
  }
  return new Pair<>(totalRead,tmpCurrentSeq);
}

private static Pair < Long , Long > load ( ByteArray a , InputStream stream , long memoryOffset , long count , CommonIndex positions , CRC32 checksum , ByteArray checksums , PrereadHashFunction hf , boolean checksumsLoaded , long currentSeq ) throws IOException { long tmpCurrentSeq = currentSeq ; final byte [ ] buffer = new byte [ 1024 * 1024 ] ; long totalRead = 0 ; int bytesRead ; long pos = memoryOffset ; while ( totalRead < count && ( bytesRead = stream . read ( buffer , 0 , ( int ) Math . min ( count - totalRead , buffer . length ) ) ) != - 1 ) { a . set ( pos , buffer , bytesRead ) ; pos += bytesRead ; int j = 0 ; while ( j < bytesRead ) { if ( positions . get ( tmpCurrentSeq + 1 ) == positions . get ( tmpCurrentSeq ) ) { hf . irvineHash ( 0L ) ; tmpCurrentSeq ++ ; continue ; } final int len = ( int ) ( positions . get ( tmpCurrentSeq + 1 ) - ( memoryOffset + totalRead + j ) ) ; if ( j + len <= bytesRead ) { checksum . update ( buffer , j , len ) ; hf . irvineHash ( buffer , j , len ) ; hf . irvineHash ( positions . get ( tmpCurrentSeq + 1 ) - positions . get ( tmpCurrentSeq ) ) ; if ( checksumsLoaded ) { if ( ( byte ) checksum . getValue ( ) != checksums . get ( tmpCurrentSeq ) ) { throw new CorruptSdfException ( "Sequence: " + tmpCurrentSeq + " failed checksum" ) ; } } else { checksums . set ( tmpCurrentSeq , ( byte ) checksum . getValue ( ) ) ; } tmpCurrentSeq ++ ; checksum . reset ( ) ; } else { hf . irvineHash ( buffer , j , bytesRead - j ) ; checksum . update ( buffer , j , bytesRead - j ) ; } j += len ; } totalRead += bytesRead ; } return new Pair < > ( totalRead , tmpCurrentSeq ) ; }
a private method for loading from a file , then compressing and calculating checksums
