changes as per review comments
This commit is contained in:
parent
bd26dc86d6
commit
c235a6eb92
@ -1179,14 +1179,16 @@ public long skip(final long n) throws IOException {
|
||||
checkNotClosed();
|
||||
streamStatistics.skipOperationStarted();
|
||||
|
||||
long targetPos = pos + n;
|
||||
// target pos should be less than EOF
|
||||
long targetPos = Math.min(contentLength, pos + n);
|
||||
long bytesToSkip = targetPos - pos;
|
||||
long skipped;
|
||||
|
||||
try {
|
||||
lazySeek(targetPos, 1);
|
||||
skipped = n;
|
||||
skipped = bytesToSkip;
|
||||
} catch (EOFException e) {
|
||||
LOG.debug("Lazy seek failed, attempting default skip");
|
||||
LOG.debug("Lazy seek failed, attempting default skip", e);
|
||||
|
||||
skipped = wrappedStream.skip(n);
|
||||
if (skipped > 0) {
|
||||
|
@ -493,11 +493,13 @@ public void testSkip() throws Throwable {
|
||||
|
||||
in = openTestFile(S3AInputPolicy.Random, DEFAULT_READAHEAD_RANGE);
|
||||
|
||||
in.skip(_4K);
|
||||
assertEquals("bytes skipped", _4K, in.skip(_4K));
|
||||
|
||||
// Skip within read ahead range, will not make a new get request
|
||||
in.skip(_8K);
|
||||
assertEquals("bytes skipped", _8K, in.skip(_8K));
|
||||
|
||||
// Skip outside read ahead range, should make a new get request
|
||||
in.skip(_256K);
|
||||
assertEquals("bytes skipped", _256K, in.skip(_256K));
|
||||
|
||||
IOStatistics ioStatistics = streamStatistics.getIOStatistics();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user