Use non-JNI method for read(byte[])
This commit is contained in:
parent
29bfc49473
commit
00f53c49e4
|
@ -157,10 +157,27 @@ public class SnappyInputStream
|
|||
* @see java.io.InputStream#read(byte[], int, int)
|
||||
*/
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len)
|
||||
public int read(byte[] b, int byteOffset, int byteLength)
|
||||
throws IOException
|
||||
{
|
||||
return rawRead(b, off, len);
|
||||
int writtenBytes = 0;
|
||||
for (; writtenBytes < byteLength; ) {
|
||||
|
||||
if (uncompressedCursor >= uncompressedLimit) {
|
||||
if (hasNextChunk()) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
return writtenBytes == 0 ? -1 : writtenBytes;
|
||||
}
|
||||
}
|
||||
int bytesToWrite = Math.min(uncompressedLimit - uncompressedCursor, byteLength - writtenBytes);
|
||||
System.arraycopy(uncompressed, uncompressedCursor, b, byteOffset + writtenBytes, bytesToWrite);
|
||||
writtenBytes += bytesToWrite;
|
||||
uncompressedCursor += bytesToWrite;
|
||||
}
|
||||
|
||||
return writtenBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue