Package com.illumon.iris.binarystore
Class AbstractBinaryStoreReader
java.lang.Object
com.illumon.iris.binarystore.AbstractBinaryStoreReader
- All Implemented Interfaces:
BinaryStoreReader
,TableReader
- Direct Known Subclasses:
AbstractBinaryStoreReaderV1
,AbstractBinaryStoreReaderV2
public abstract class AbstractBinaryStoreReader
extends Object
implements TableReader, BinaryStoreReader
This is the common class for the V1 and V2 binary store readers.
Extenders must be able to read the header and support the row getter interfaces.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.illumon.iris.binarystore.TableReader
TableReader.MissingPropertyGetterException
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]
protected SupportedType[]
protected ByteBuffer
protected byte[]
protected RowGetter[]
protected Object[]
-
Method Summary
Modifier and TypeMethodDescriptionString[]
Get an array of all known column names.getColumnType
(String columnName) Get the SupportedType of the named column.Get the getter for a named column.<T> RowGetter<T>
Return a typed RowGetter for the column with the given name.getTypeMetadataString
(String columnName) protected void
Handle a record entry after it's read in.protected void
Handle a row entry after it's read in.protected abstract void
readData
(int minAmount, ByteBuffer theBuffer) Read some data from the implementation-defined source into the given data buffer.protected void
readDataBuffer
(int minAmount, ByteBuffer theBuffer) 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.protected void
This implementation declares an internal buffer.protected void
readIntoByteBuffer
(int requiredSize, ByteBuffer theBuffer) Populates the specified byte buffer from our data source (defined in derived class).setRecordHandler
(Runnable handler) Set the handler that will handle a binary store record entry after it has been parsed.setRowHandler
(Runnable handler) Set the handler that will handle a row binary store row entry after it has been parsed.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.BinaryStoreReader
readHeader
Methods inherited from interface com.illumon.iris.binarystore.TableReader
close, getApplicationVersion, getFlagGetter, getPropertyGetter, getRecordDataGetter, readAllEntries, readAllEntries, readEntry, readRow
-
Field Details
-
columnTypes
-
columnNames
-
dataBuffer
-
rowGetters
-
typeMetadata
-
mask
protected byte[] mask
-
-
Method Details
-
getColumnNames
Description copied from interface:TableReader
Get an array of all known column names. These can be used to determine valid column names for use inTableReader.getGetter(String)
.- Specified by:
getColumnNames
in interfaceTableReader
- Returns:
- a new array of all known column names.
-
getColumnType
Description copied from interface:TableReader
Get the SupportedType of the named column.- Specified by:
getColumnType
in interfaceTableReader
- Parameters:
columnName
- the name of the column- Returns:
- the SupportedType value for the named column
-
getTypeMetadataString
-
getGetter
Get the getter for a named column.- Specified by:
getGetter
in interfaceTableReader
- Parameters:
name
- the column to get the getter for.- Returns:
- the getter
- Throws:
AbstractBinaryStoreReader.MissingGetterException
- when the getter does not exist
-
getGetter
Description copied from interface:TableReader
Return a typed RowGetter for the column with the given name. RowGetter.get() will return type tClass.- Specified by:
getGetter
in interfaceTableReader
- Parameters:
name
- the column name- Returns:
- a RowGetter of type tClass
-
readHeader
This implementation declares an internal buffer. This version of readHeader uses that internal buffer.- Throws:
IOException
EofException
- See Also:
-
readIntoByteBuffer
protected void readIntoByteBuffer(int requiredSize, ByteBuffer theBuffer) throws IOException, EofException Populates the specified byte buffer from our data source (defined in derived class).
This default implementation callsreadDataBuffer(int, ByteBuffer)
and the abstractreadData(int, ByteBuffer)
, but in the BinaryStoreProcessors used by the DIS, the buffer is passed in and no data is actually read.
The default implementations might compact the buffer viareadDataBuffer(int, ByteBuffer)
, destroying previously-read data in the buffer.- Parameters:
requiredSize
- how many bytes of data are required to continue processingtheBuffer
- the data buffer to populate- Throws:
IOException
- if we encounter an EOF mid rowEofException
- if no data is available from the file
-
readDataBuffer
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 compact the buffer (remaining bytes copied to position 0), so position and limit might change.
The byte buffer will be left in a ready-to-read state.- 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
Read some data from the implementation-defined source into the given data buffer. The buffer is expected to be in write mode. After this call, the buffer must contain minAmount additional bytes.- Parameters:
minAmount
- caller wants this many additional bytestheBuffer
- put the bytes in ths buffer. Must have minAmount additional capacity.- Throws:
IOException
-
handleRow
protected void handleRow()Handle a row entry after it's read in. Default behavior is to call the registered row handler. Extending classes may override this. -
handleRecord
protected void handleRecord()Handle a record entry after it's read in. Default behavior is to call the registered record handler. Extending classes may override this. -
setRowHandler
Set the handler that will handle a row binary store row entry after it has been parsed. This handler will be called byTableReader.readEntry()
orTableReader.readRow()
.- Parameters:
handler
- the replacement row handler- Returns:
- the previous handler
-
setRecordHandler
Set the handler that will handle a binary store record entry after it has been parsed. This handler will be called byTableReader.readEntry()
NB: The record handler will never be called in a V1 reader.- Parameters:
handler
- the replacement record handler- Returns:
- the previous handler
-