Skip to content

Commit

Permalink
Fixes issue in BGZFSplitGuesser relating to incomplete copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnothaft committed Aug 25, 2017
1 parent a162405 commit 6ba366d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/org/seqdoop/hadoop_bam/util/BGZFSplitGuesser.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ public long guessNextBGZFBlockStart(long beg, long end)
byte[] arr = new byte[2*0xffff - 1];

this.seekableInFile.seek(beg);
int read = inFile.read(arr, 0, Math.min((int) (end - beg),
arr.length));
if (read == -1) {
return -1; // EOF
int totalRead = 0;
for (int left = Math.min((int)(end - beg), arr.length); left > 0;) {
final int r = inFile.read(arr, totalRead, left);
if (r < 0)
break;
totalRead += r;
left -= r;
}
arr = Arrays.copyOf(arr, read);
arr = Arrays.copyOf(arr, totalRead);

this.in = new ByteArraySeekableStream(arr);

Expand Down

0 comments on commit 6ba366d

Please sign in to comment.