Class StreamingDataset
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.StreamingDataset
 
- 
- All Implemented Interfaces:
- Dataset,- StreamingDatasetWriter,- java.io.Serializable
 
 public class StreamingDataset extends java.lang.Object implements Dataset, StreamingDatasetWriter This is an implementation of Dataset that received data in a streaming manner. All of the functions will block until the information requested is available, dictated by an overall timeout that can be set.The dataset can operate as a normal dataset, or if "transientDataMode" is true, will discard data after it is read, freeing up memory when using a large dataset for data processing purposes. Since the streaming dataset won't normally know how many rows to expect (unless it was told the number in the initialize), the interaction with it is a little different than normal. Instead of calling getRowCount(), which will return -1 if the number of rows isn't known, it's better to call hasRow(x) (with x being the next row you hope to get) until it returns False. If you need to treat this dataset as a normal dataset, you can call readFully() to block and retrieve all data. After that, it will behave like a normal dataset, with getRowCount() returning the correct value. - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classStreamingDataset.Columnstatic classStreamingDataset.Rowstatic classStreamingDataset.StreamingException
 - 
Constructor SummaryConstructors Constructor Description StreamingDataset()StreamingDataset(long waitTimeout, boolean transientDataMode)Constructs the dataset with the given timeout and mode.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intbinarySearch(int column, java.lang.Object key)Performs a binary search on the specified column, looking for the specified key.protected voidcheckError()voidfinish()Notifies the writer to close- all data has been written.voidfinishWithError(java.lang.Exception e)Finishes the stream while indicating an error occurred.intgetColumnCount()Returns the number of columns.intgetColumnIndex(java.lang.String name)Returns the index of the given column, case insensitivejava.lang.StringgetColumnName(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.intgetInternalRowCount()Mostly for unit testingdoublegetPrimitiveValueAt(int row, int col)If the given column is a numeric type or a Date, then the value will be returned as a double.QualityCodegetQualityAt(int row, int col)Returns the quality of the value at the given location.StreamingDataset.RowgetRow(int row)intgetRowCount()Return the number of rows in this datasetjava.lang.ObjectgetValueAt(int row, int col)Returns the value in the dataset at the given location.java.lang.ObjectgetValueAt(int row, java.lang.String colName)Returns the value at the given row and at a column named colName.booleanhasRow(int row)This is somewhat similar to isClosed, but will potentially wait for more data to come in, or for the dataset to close.voidinitialize(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.booleanisClosed()Returns whether this dataset has been closed to further writing.static StreamingDatasetnewWriter()Returns a new streaming dataset that is only intended to write, and not read.voidreadFully()Blocks until all of the data has been read.voidsetBlockingWrites(boolean value)If true, the dataset will block on writes until the previously written row is read (standard producer/consumer).voidsetTransientMode(boolean transientMode)protected StreamingDataset.RowwaitFor(int row)protected voidwaitForColumns()voidwrite(StreamingDataset.Row row)voidwrite(java.lang.Object[] data, QualityCode[] quality)Writes a row with the given data.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface com.inductiveautomation.ignition.common.DatasetgetColumnAsList, hasQualityData
 
- 
 
- 
- 
- 
Constructor Detail- 
StreamingDatasetpublic StreamingDataset() 
 - 
StreamingDatasetpublic StreamingDataset(long waitTimeout, boolean transientDataMode)Constructs the dataset with the given timeout and mode. "Transient Data Mode" means that data will be discarded after it is read, so all requests to getData() should only move forward in row index. This is useful for minimizing memory usage with very large datasets when this object is only being used for data processing.
 
- 
 - 
Method Detail- 
setTransientModepublic void setTransientMode(boolean transientMode) 
 - 
newWriterpublic static StreamingDataset newWriter() Returns a new streaming dataset that is only intended to write, and not read. Essentially is a plain streaming dataset, with blocking writes enabled.
 - 
setBlockingWritespublic void setBlockingWrites(boolean value) If true, the dataset will block on writes until the previously written row is read (standard producer/consumer). This prevents a build up in memory of unread rows.
 - 
readFullypublic void readFully() Blocks until all of the data has been read. Will throw a StreamingException if the overall timeout is exceeded.
 - 
isClosedpublic boolean isClosed() Returns whether this dataset has been closed to further writing.
 - 
hasRowpublic 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. Will return immediately if we know there is a row greater than the requested row available. In general, this function should be called to wait for new data before each call to getValueAt.
 - 
checkErrorprotected void checkError() 
 - 
waitForColumnsprotected void waitForColumns() 
 - 
getColumnNamespublic java.util.List<java.lang.String> getColumnNames() Description copied from interface:DatasetReturns an unmodifiable list of this dataset's column names, in order.- Specified by:
- getColumnNamesin interface- Dataset
 
 - 
getColumnTypespublic java.util.List<java.lang.Class<?>> getColumnTypes() Description copied from interface:DatasetReturns an unmodifiable list of this dataset's column types, in order.- Specified by:
- getColumnTypesin interface- Dataset
 
 - 
getColumnCountpublic int getColumnCount() Description copied from interface:DatasetReturns the number of columns.- Specified by:
- getColumnCountin interface- Dataset
 
 - 
getRowCountpublic int getRowCount() Description copied from interface:DatasetReturn the number of rows in this dataset- Specified by:
- getRowCountin interface- Dataset
 
 - 
getColumnIndexpublic int getColumnIndex(java.lang.String name) Description copied from interface:DatasetReturns the index of the given column, case insensitive- Specified by:
- getColumnIndexin interface- Dataset
- Parameters:
- name- the name of the column to look up
- Returns:
- the index of the column
 
 - 
getColumnNamepublic java.lang.String getColumnName(int col) Description copied from interface:DatasetReturns the name of the given column.- Specified by:
- getColumnNamein interface- Dataset
 
 - 
getColumnTypepublic java.lang.Class<?> getColumnType(int col) Description copied from interface:DatasetReturns the type of the given column.- Specified by:
- getColumnTypein interface- Dataset
 
 - 
waitForprotected StreamingDataset.Row waitFor(int row) 
 - 
getValueAtpublic java.lang.Object getValueAt(int row, int col)Description copied from interface:DatasetReturns the value in the dataset at the given location.- Specified by:
- getValueAtin interface- Dataset
 
 - 
getQualityAtpublic QualityCode getQualityAt(int row, int col) Description copied from interface:DatasetReturns the quality of the value at the given location.- Specified by:
- getQualityAtin interface- Dataset
 
 - 
getValueAtpublic java.lang.Object getValueAt(int row, java.lang.String colName)Description copied from interface:DatasetReturns the value at the given row and at a column named colName. Column name matching is case insensitive.- Specified by:
- getValueAtin interface- Dataset
 
 - 
getPrimitiveValueAtpublic double getPrimitiveValueAt(int row, int col)Description copied from interface:DatasetIf the given column is a numeric type or a Date, then the value will be returned as a double. (Charts uses this functionality to provide a seamless interface with certain optimized dataset implementations.- Specified by:
- getPrimitiveValueAtin interface- Dataset
 
 - 
getRowpublic StreamingDataset.Row getRow(int row) 
 - 
binarySearchpublic int binarySearch(int column, java.lang.Object key)Description copied from interface:DatasetPerforms a binary search on the specified column, looking for the specified key. Column MUST be sorted in ascending order. Dataset provides an inefficient default implementation of binary search that allocates a new array list for the entire column.- Specified by:
- binarySearchin interface- Dataset
- Returns:
- index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the list: the index of the first element greater than the key, or list.size(), if all elements in the list are less than the specified key. Note that this guarantees the return value will be greater than or equal to 0, but only if the key is found.
 
 - 
initializepublic void initialize(java.lang.String[] columnNames, java.lang.Class<?>[] columnTypes, boolean supportsQuality, int expectedRows)Description copied from interface:StreamingDatasetWriterInitializes the streaming dataset with important information, primarily the column names and types. If supportsQuality is true, it is expected that every value added has an associated quality. expectedRows gives an idea as to how many rows will be returned- useful for progress indication. Should be -1 if the number cannot be known in advance.- Specified by:
- initializein interface- StreamingDatasetWriter
- expectedRows- -1 if not known, otherwise the number of rows that will be in the dataset.
 
 - 
writepublic void write(java.lang.Object[] data, QualityCode[] quality) throws java.io.IOExceptionDescription copied from interface:StreamingDatasetWriterWrites a row with the given data. Bounds and order of arrays must match that used to call initialize. quality may be null if dataset does not support quality.- Specified by:
- writein interface- StreamingDatasetWriter
- Throws:
- java.io.IOException
 
 - 
writepublic void write(StreamingDataset.Row row) 
 - 
finishpublic void finish() Description copied from interface:StreamingDatasetWriterNotifies the writer to close- all data has been written. Should be called from a finally block.- Specified by:
- finishin interface- StreamingDatasetWriter
 
 - 
finishWithErrorpublic void finishWithError(java.lang.Exception e) Description copied from interface:StreamingDatasetWriterFinishes the stream while indicating an error occurred. Either this, or the successful finish(), must be called.- Specified by:
- finishWithErrorin interface- StreamingDatasetWriter
 
 - 
getInternalRowCountpublic int getInternalRowCount() Mostly for unit testing
 
- 
 
-