Package com.illumon.iris.binarystore
Class BinaryStoreSocketReaderV2
java.lang.Object
com.illumon.iris.binarystore.AbstractBinaryStoreReader
com.illumon.iris.binarystore.AbstractBinaryStoreReaderV2
com.illumon.iris.binarystore.BinaryStoreSocketReaderV2
- All Implemented Interfaces:
BinaryStoreReader
,TableReader
Extend AbstractBinaryStoreReaderV2 implementation to add a socket channel source.
The source channel is not rewindable or seekable.
The internal data buffer will be allocated from a pool rather than statically allocated.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.illumon.iris.binarystore.AbstractBinaryStoreReaderV2
AbstractBinaryStoreReaderV2.BinaryStoreRowGetter<T>
Nested classes/interfaces inherited from class com.illumon.iris.binarystore.AbstractBinaryStoreReader
AbstractBinaryStoreReader.MissingGetterException
Nested classes/interfaces inherited from interface com.illumon.iris.binarystore.TableReader
TableReader.MissingPropertyGetterException
-
Field Summary
Fields inherited from class com.illumon.iris.binarystore.AbstractBinaryStoreReaderV2
ROW_SIZE_PROP
Fields inherited from class com.illumon.iris.binarystore.AbstractBinaryStoreReader
columnNames, columnTypes, dataBuffer, mask, rowGetters, typeMetadata
-
Constructor Summary
ConstructorsConstructorDescriptionBinaryStoreSocketReaderV2
(ReadableByteChannel channel, ByteBuffer headerBuffer, com.fishlib.io.sched.PooledMessage.Pool pool) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the input source for this TableReader.Return the cached header buffer.protected void
readData
(int minAmount, ByteBuffer theBuffer) Override the default implementation to read exactly the required bytes.protected void
readDataBuffer
(int minAmount, ByteBuffer theBuffer) Called byAbstractBinaryStoreReader.readIntoByteBuffer(int, ByteBuffer)
.
Convenience method to manage ByteBuffer pointers as more bytes are added to the buffer.
The byte buffer will be switched from read mode to write mode and back again.static void
readDataExact
(int numBytes, ByteBuffer theBuffer, ReadableByteChannel channel) Read exactly numBytes bytes from channel into the given buffer.boolean
Read data into the internal dataBuffer in order to populate the entire row.void
This implementation declares an internal buffer.void
readHeader
(ByteBuffer theBuffer) After reading the header from the internal buffer, also grab a copy for reuse later.boolean
readRow()
Deprecated.com.fishlib.io.sched.Message
Read a complete row from the source into a new buffer from the pool and return the handle.Methods inherited from class com.illumon.iris.binarystore.AbstractBinaryStoreReaderV2
getApplicationVersion, getFlagGetter, getPropertyGetter, getRecordDataGetter, parseRecord, parseRow
Methods inherited from class com.illumon.iris.binarystore.AbstractBinaryStoreReader
getColumnNames, getColumnType, getGetter, getGetter, getTypeMetadataString, handleRecord, handleRow, readIntoByteBuffer, setRecordHandler, setRowHandler
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.illumon.iris.binarystore.TableReader
readAllEntries, readAllEntries
-
Constructor Details
-
BinaryStoreSocketReaderV2
public BinaryStoreSocketReaderV2(@NotNull ReadableByteChannel channel, ByteBuffer headerBuffer, com.fishlib.io.sched.PooledMessage.Pool pool) throws IOException, EofException - Throws:
IOException
EofException
-
-
Method Details
-
readHeader
After reading the header from the internal buffer, also grab a copy for reuse later.- Specified by:
readHeader
in interfaceBinaryStoreReader
- Overrides:
readHeader
in classAbstractBinaryStoreReaderV2
- Parameters:
theBuffer
- buffer containing the header, in reading mode- Throws:
IOException
- an exception derived from IOException may be thrown if there isn't enough data in the buffer.EofException
- may be thrown if an underlying channel (if any) ends.
-
readHeader
Description copied from class:AbstractBinaryStoreReader
This implementation declares an internal buffer. This version of readHeader uses that internal buffer.- Overrides:
readHeader
in classAbstractBinaryStoreReader
- Throws:
IOException
EofException
- See Also:
-
close
Description copied from interface:TableReader
Close the input source for this TableReader.- Throws:
IOException
-
readRowBuffer
Read a complete row from the source into a new buffer from the pool and return the handle. This implementation does not need the row details.- Returns:
- a buffer handle containing the row's buffer. Will never return null.
- Throws:
IOException
- if readIntoByteBuffer encounters a problemEofException
- See Also:
-
readDataBuffer
Called byAbstractBinaryStoreReader.readIntoByteBuffer(int, ByteBuffer)
.
Convenience method to manage ByteBuffer pointers as more bytes are added to the buffer.
The byte buffer will be switched from read mode to write mode and back again. This implementation will not change the existing contents of the buffer between 0 and position().
The byte buffer will be left in a ready-to-read state.- Overrides:
readDataBuffer
in classAbstractBinaryStoreReader
- Parameters:
minAmount
- add this many bytes to the buffertheBuffer
- a ByteBuffer in read mode. Must contain enough capacity for the additional bytes.- Throws:
IOException
- passthrough fromreadData(int, ByteBuffer)
-
readData
Override the default implementation to read exactly the required bytes.- Specified by:
readData
in classAbstractBinaryStoreReader
- Parameters:
minAmount
- Caller wants this many additional bytes. Read exactly that many.theBuffer
- Put the bytes in ths buffer. Must have minAmount additional capacity.- Throws:
IOException
-
readDataExact
public static void readDataExact(int numBytes, ByteBuffer theBuffer, ReadableByteChannel channel) throws IOException Read exactly numBytes bytes from channel into the given buffer. Make the functionality available as a utility.- Parameters:
numBytes
- if blocking, loop until we get this many bytestheBuffer
- destination byte buffer in write modechannel
- read from this ReadableByteChannel- Throws:
IOException
-
readRow
Deprecated.Description copied from class:AbstractBinaryStoreReaderV2
Read data into the internal dataBuffer in order to populate the entire row. This implementation callsAbstractBinaryStoreReader.readIntoByteBuffer(int, ByteBuffer)
andAbstractBinaryStoreReader.readData(int, ByteBuffer)
. to read more data from the implementation-defined source. RowGetters are also called, but they do not read from the source in this implementation.- Specified by:
readRow
in interfaceTableReader
- Overrides:
readRow
in classAbstractBinaryStoreReaderV2
- Returns:
- true if successful, false if EOF or an error is encountered.
- Throws:
IOException
- if EOF is encountered mid-row or any invalid data is encountered.
-
readEntry
Description copied from class:AbstractBinaryStoreReaderV2
Read data into the internal dataBuffer in order to populate the entire row. This implementation callsAbstractBinaryStoreReader.readIntoByteBuffer(int, ByteBuffer)
andAbstractBinaryStoreReader.readData(int, ByteBuffer)
to read more data from the implementation-defined source. RowGetters are also called, but they do not read from the source in this implementation.- Specified by:
readEntry
in interfaceTableReader
- Overrides:
readEntry
in classAbstractBinaryStoreReaderV2
- Returns:
- true if successful, false if EOF or an error is encountered.
- Throws:
IOException
- if EOF is encountered mid-row or any invalid data is encountered.
-
getHeaderBuffer
Return the cached header buffer.- Returns:
- the cached header buffer.
- Throws:
IllegalStateException
- if the header buffer isn't set
-