public class OnceRowPipe extends java.lang.Object implements RowPipe, RowSequence
RowPipe
implementation which provides a one-shot
table.
The returned table is unusual in that it
can only return a RowSequence
once.
This violates the normal rules of the StarTable
interface.
Any calls beyond the first to waitForStarTable().getRowSequence()
will throw a UnrepeatableSequenceException
.Constructor and Description |
---|
OnceRowPipe()
Constructs a new streaming row store with a default buffer size.
|
OnceRowPipe(int queueSize)
Constructs a new streaming row store with a given buffer size.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptMetadata(StarTable meta)
Takes delivery of a row-less StarTable object which defines
the metadata of the table to be transmitted.
|
void |
acceptRow(java.lang.Object[] row)
Takes delivery of one row of data.
|
void |
close()
Indicates that this sequence will not be required any more.
|
void |
endRows()
Signals that there are no more rows to be transmitted.
|
java.lang.Object |
getCell(int icol)
Returns the contents of a cell in the current row.
|
java.lang.Object[] |
getRow()
Returns the contents of the current table row, as an array
with the same number of elements as there are columns in this
table.
|
boolean |
next()
Attempts to advance the current row to the next one.
|
void |
setError(java.io.IOException error)
May be called by the writing stream to set an I/O error on the pipe.
|
StarTable |
waitForStarTable()
Returns a non-random table whose first call to
getRowSequence will return a sequence that steps through
the same rows which are being written to this sink.
|
public OnceRowPipe()
public OnceRowPipe(int queueSize)
queueSize
- the maximum number of rows buffered between
write and read before acceptRow will blockpublic void setError(java.io.IOException error)
RowPipe
e
as its cause from one of the read methods.
If an error has already been set by a previous call of this method,
this has no effect (only the first error is set).public void acceptMetadata(StarTable meta)
TableSink
StarTable.getRowCount()
); if it is not known, the row count
should be -1. However, this object should not attempt to read
any of meta's cell data.
The data to be transmitted in subsequent calls of acceptRow must match the metadata transmitted in this call in the same way that rows of a StarTable must match its own metadata (number and content clases of columns etc). If this sink cannot dispose of a table corresponding to meta then it may throw a TableFormatException - this may be the case if for instance meta has columns with types that this sink can't deal with.
acceptMetadata
in interface TableSink
meta
- table metadata objectpublic void acceptRow(java.lang.Object[] row) throws java.io.IOException
TableSink
public void endRows()
TableSink
public StarTable waitForStarTable() throws java.io.IOException
UnrepeatableSequenceException
.
This method will block until acceptMetadata(uk.ac.starlink.table.StarTable)
has been called.waitForStarTable
in interface RowPipe
java.io.IOException
- if one has previously been set using
setError(java.io.IOException)
public boolean next() throws java.io.IOException
RowSequence
RowSequence.getCell(int)
or RowSequence.getRow()
methods.next
in interface RowSequence
next
in interface Sequence
java.io.IOException
- if there is some errorpublic java.lang.Object[] getRow()
RowSequence
getRow
in interface RowData
getRow
in interface RowSequence
public java.lang.Object getCell(int icol)
RowSequence
getCell
in interface RowData
getCell
in interface RowSequence
icol
- column indexpublic void close()
RowSequence
close
is undefined.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface RowSequence