Class ReadAheadBufferedStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.mariadb.jdbc.client.socket.impl.ReadAheadBufferedStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Permit to buf socket data, reading not only asked bytes, but available number of bytes when
possible.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]private static final intprivate intprivate intFields inherited from class FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()private voidfillingBuffer(int minNeededBytes) Fill buf with required length, or available bytes.booleanintread()intread(byte[] externalBuf, int off, int len) Returning byte array, from cache of reading socket if needed.voidreset()longskip(long n) Methods inherited from class FilterInputStream
mark, read
-
Field Details
-
BUF_SIZE
private static final int BUF_SIZE- See Also:
-
buf
private final byte[] buf -
end
private int end -
pos
private int pos
-
-
Constructor Details
-
ReadAheadBufferedStream
ConstructorImplementation doesn't use synchronized/semaphore because all used are already locked by Statement/PreparedStatement Reentrant lock
- Parameters:
in- socket input stream
-
-
Method Details
-
read
Returning byte array, from cache of reading socket if needed.- Overrides:
readin classFilterInputStream- Parameters:
externalBuf- buf to filloff- offsetlen- length to read- Returns:
- number of added bytes
- Throws:
IOException- if exception during socket reading
-
fillingBuffer
Fill buf with required length, or available bytes.- Parameters:
minNeededBytes- asked number of bytes- Throws:
IOException- in case of failing reading stream.
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classFilterInputStream
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-
available
- Overrides:
availablein classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
reset
- Overrides:
resetin classFilterInputStream- Throws:
IOException
-