public class StreamingDataset extends java.lang.Object implements Dataset, StreamingDatasetWriter
Modifier and Type | Class and Description |
---|---|
protected static class |
StreamingDataset.Column |
static class |
StreamingDataset.Row |
static class |
StreamingDataset.StreamingException |
Constructor and Description |
---|
StreamingDataset() |
StreamingDataset(long waitTimeout,
boolean transientDataMode)
Constructs the dataset with the given timeout and mode.
|
Modifier and Type | Method and Description |
---|---|
int |
binarySearch(int column,
java.lang.Object key)
Performs a binary search on the specified column, looking for the specified key.
|
protected void |
checkError() |
void |
finish()
Notifies the writer to close- all data has been written.
|
void |
finishWithError(java.lang.Exception e)
Finishes the stream while indicating an error occurred.
|
int |
getColumnCount()
Returns the number of columns.
|
int |
getColumnIndex(java.lang.String name)
Returns the index of the given column, case insensitive
|
java.lang.String |
getColumnName(int col)
Returns the name of the given column.
|
java.util.List<java.lang.String> |
getColumnNames()
Returns an unmodifiable list of this dataset's column names, in order.
|
java.lang.Class<?> |
getColumnType(int col)
Returns the type of the given column.
|
java.util.List<java.lang.Class<?>> |
getColumnTypes()
Returns an unmodifiable list of this dataset's column types, in order.
|
int |
getInternalRowCount()
Mostly for unit testing
|
double |
getPrimitiveValueAt(int row,
int col)
If the given column is a numeric type or a Date, then the value will be returned as a double.
|
DataQuality |
getQualityAt(int row,
int col)
Returns the quality of the value at the given location.
|
StreamingDataset.Row |
getRow(int row) |
int |
getRowCount()
Return the number of rows in this dataset
|
java.lang.Object |
getValueAt(int row,
int col)
Returns the value in the dataset at the given location.
|
java.lang.Object |
getValueAt(int row,
java.lang.String colName)
Returns the value at the given row and at a column named colName.
|
boolean |
hasRow(int row)
This is somewhat similar to isClosed, but will potentially wait for more data to come in, or for the dataset to
close.
|
void |
initialize(java.lang.String[] columnNames,
java.lang.Class<?>[] columnTypes,
boolean supportsQuality,
int expectedRows)
Initializes the streaming dataset with important information, primarily the column names and types.
|
boolean |
isClosed()
Returns whether this dataset has been closed to further writing.
|
static StreamingDataset |
newWriter()
Returns a new streaming dataset that is only intended to write, and not read.
|
void |
readFully()
Blocks until all of the data has been read.
|
void |
setBlockingWrites(boolean value)
If true, the dataset will block on writes until the previously written row is read (standard producer/consumer).
|
void |
setTransientMode(boolean transientMode) |
protected StreamingDataset.Row |
waitFor(int row) |
protected void |
waitForColumns() |
void |
write(java.lang.Object[] data,
DataQuality[] quality)
Writes a row with the given data.
|
void |
write(StreamingDataset.Row row) |
public StreamingDataset()
public StreamingDataset(long waitTimeout, boolean transientDataMode)
waitTimeout
- transientDataMode
- public void setTransientMode(boolean transientMode)
public static StreamingDataset newWriter()
public void setBlockingWrites(boolean value)
value
- public void readFully()
public boolean isClosed()
public boolean hasRow(int row)
protected void checkError()
protected void waitForColumns()
public java.util.List<java.lang.String> getColumnNames()
Dataset
getColumnNames
in interface Dataset
public java.util.List<java.lang.Class<?>> getColumnTypes()
Dataset
getColumnTypes
in interface Dataset
public int getColumnCount()
Dataset
getColumnCount
in interface Dataset
public int getRowCount()
Dataset
getRowCount
in interface Dataset
public int getColumnIndex(java.lang.String name)
Dataset
getColumnIndex
in interface Dataset
public java.lang.String getColumnName(int col)
Dataset
getColumnName
in interface Dataset
public java.lang.Class<?> getColumnType(int col)
Dataset
getColumnType
in interface Dataset
protected StreamingDataset.Row waitFor(int row)
public java.lang.Object getValueAt(int row, int col)
Dataset
getValueAt
in interface Dataset
public DataQuality getQualityAt(int row, int col)
Dataset
getQualityAt
in interface Dataset
public java.lang.Object getValueAt(int row, java.lang.String colName)
Dataset
getValueAt
in interface Dataset
public double getPrimitiveValueAt(int row, int col)
Dataset
getPrimitiveValueAt
in interface Dataset
public StreamingDataset.Row getRow(int row)
public int binarySearch(int column, java.lang.Object key)
Dataset
binarySearch
in interface Dataset
public void initialize(java.lang.String[] columnNames, java.lang.Class<?>[] columnTypes, boolean supportsQuality, int expectedRows)
StreamingDatasetWriter
initialize
in interface StreamingDatasetWriter
expectedRows
- -1 if not known, otherwise the number of rows that will be in the dataset.public void write(java.lang.Object[] data, DataQuality[] quality) throws java.io.IOException
StreamingDatasetWriter
write
in interface StreamingDatasetWriter
java.io.IOException
public void write(StreamingDataset.Row row)
public void finish()
StreamingDatasetWriter
finish
in interface StreamingDatasetWriter
public void finishWithError(java.lang.Exception e)
StreamingDatasetWriter
finishWithError
in interface StreamingDatasetWriter
public int getInternalRowCount()