File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
core/src/main/java/org/apache/spark/io Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -317,6 +317,11 @@ public long skip(long n) throws IOException {
317317 if (n <= 0L ) {
318318 return 0L ;
319319 }
320+ if (n <= activeBuffer .remaining ()) {
321+ // Only skipping from active buffer is sufficient
322+ activeBuffer .position (toSkip + activeBuffer .position ());
323+ return n ;
324+ }
320325 stateChangeLock .lock ();
321326 long skipped ;
322327 try {
@@ -340,13 +345,9 @@ private long skipInternal(long n) throws IOException {
340345 if (available () >= n ) {
341346 // we can skip from the internal buffers
342347 int toSkip = (int ) n ;
343- if (toSkip <= activeBuffer .remaining ()) {
344- // Only skipping from active buffer is sufficient
345- activeBuffer .position (toSkip + activeBuffer .position ());
346- return n ;
347- }
348348 // We need to skip from both active buffer and read ahead buffer
349349 toSkip -= activeBuffer .remaining ();
350+ assert (toSkip > 0 ); // skipping from activeBuffer already handled.
350351 activeBuffer .position (0 );
351352 activeBuffer .flip ();
352353 readAheadBuffer .position (toSkip + readAheadBuffer .position ());
You can’t perform that action at this time.
0 commit comments