File tree 1 file changed +20
-3
lines changed
src/main/java/com/github/shyiko/mysql/binlog/io
1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -242,8 +242,25 @@ public synchronized void reset() throws IOException {
242
242
inputStream .reset ();
243
243
}
244
244
245
+ /**
246
+ * This method implements fast-forward skipping in the stream.
247
+ * It can be used if and only if the underlying stream is fully available till its end.
248
+ * In other cases the regular {@link #skip(long)} method must be used.
249
+ *
250
+ * @param n - number of bytes to skip
251
+ * @return number of bytes skipped
252
+ * @throws IOException
253
+ */
245
254
public synchronized long fastSkip (long n ) throws IOException {
246
- pos += (int ) n ;
247
- return inputStream .skip (n );
248
- }
255
+ long skipOf = n ;
256
+ if (blockLength != -1 ) {
257
+ skipOf = Math .min (blockLength , skipOf );
258
+ blockLength -= skipOf ;
259
+ if (blockLength == 0 ) {
260
+ blockLength = -1 ;
261
+ }
262
+ }
263
+ pos += (int ) skipOf ;
264
+ return inputStream .skip (skipOf );
265
+ }
249
266
}
You can’t perform that action at this time.
0 commit comments