java.io.Closeable
, java.lang.AutoCloseable
, CloneableStream
, Resetable
public class OverflowInputStream extends BufferedByteHolderInputStream implements Resetable, CloneableStream
Any time store fetches a long column, the value is returned as a stream. A long column is any column that at some point was longer than a page, so a long column in one table may not be long in another depending on page size.
When the column is fetched a new OverflowInputStream is created and then the datatype's stream is set using: ((StreamStorable)sColumn).setStream(OverflowInputStream);
Modifier and Type | Field | Description |
---|---|---|
protected int |
firstOverflowId |
|
protected long |
firstOverflowPage |
|
private boolean |
initialized |
|
protected int |
overflowId |
|
protected long |
overflowPage |
|
protected BaseContainerHandle |
owner |
Fields of the class
|
protected RecordHandle |
recordToLock |
bh
Constructor | Description |
---|---|
OverflowInputStream(ByteHolder bh,
BaseContainerHandle owner,
long overflowPage,
int overflowId,
RecordHandle recordToLock) |
Constructor for OverflowInputStream
|
Modifier and Type | Method | Description |
---|---|---|
java.io.InputStream |
cloneStream() |
Clone this object.
|
void |
closeStream() |
Close the Resetable stream.
|
void |
fillByteHolder() |
If bytes remain in stream, insure the current buffer is not empty.
|
int |
getOverflowId() |
|
long |
getOverflowPage() |
|
void |
initStream() |
Initialize a Resetable stream.
|
void |
resetStream() |
Reset the stream back to beginning of the long column.
|
void |
setOverflowId(int overflowId) |
Set the next overflow page of the long column.
|
void |
setOverflowPage(long overflowPage) |
Set the next overflow page of the long column.
|
available, read, read, skip
getByteHolder, setByteHolder
protected BaseContainerHandle owner
protected long overflowPage
protected int overflowId
protected long firstOverflowPage
protected int firstOverflowId
protected RecordHandle recordToLock
private boolean initialized
public OverflowInputStream(ByteHolder bh, BaseContainerHandle owner, long overflowPage, int overflowId, RecordHandle recordToLock)
It is up to the caller to allocate the ByteHolder for this stream, and pass it in.
bh
- ByteHolder to hold buffers of bytes as the stream is
walked. Expected usage is that a page worth of
data is held in memory at a time, filled by a
calls to restorePortionLongColumn().owner
- BaseContainerHandle used to read pages from the
container. Note this handle is closed automatically
on commit.overflowPage
- The first overflow page of this long column.overflowId
- The record id of 1st segment of the long column on
overflowPage.recordToLock
- RecordHandle of the owning record of the long long
column, this is the row level lock to get.public void fillByteHolder() throws java.io.IOException
If there are bytes in current buffer than no more work necessary, else if there are no bytes available in current buffer and there are still more overflow segments then get the next buffer's worth of data.
fillByteHolder
in class BufferedByteHolderInputStream
java.io.IOException
public void setOverflowPage(long overflowPage)
Used by StorePage.restorePortionLongColumn() as part of the call back process to save the state of the scan of the pieces of the long column. StorePage.restorePortionLongColumn() is called by fillByteHolder() to get the next page worth into a buffer, and in turn after those bytes are read the state of this stream is updated with then next overflow page.
overflowPage
- Page number containing the next segment of the
long column. -1 if there are no more segments.public void setOverflowId(int overflowId)
Used by StorePage.restorePortionLongColumn() as part of the call back process to save the state of the scan of the pieces of the long column. StorePage.restorePortionLongColumn() is called by fillByteHolder() to get the next page worth into a buffer, and in turn after those bytes are read the state of this stream is updated with then next overflow page.
overflowId
- Page number containing the next segment of the
long column. -1 if there are no more segments.public long getOverflowPage()
public int getOverflowId()
public void initStream() throws StandardException
InitStream() must be called first before using any other of the Resetable interfaces.
Reopens the container. This gets a separate intent shared locked on the table and a read lock on the appropriate row. These locks remain until the enclosing blob/clob object is closed, or until the end of the transaction in which initStream() was first called. This locking behavior protects the row while the stream is being accessed. Otherwise for instance in the case of read committed the original row lock on the row would be released when the scan went to the next row, and there would be nothing to stop another transaction from deleting the row while the client read through the stream.
initStream
in interface Resetable
StandardException
- Standard exception policy.public void resetStream() throws java.io.IOException, StandardException
Also fills in the first buffer from the stream.
Throws exception if the underlying open container has been closed, for example automatically by a commit().
resetStream
in interface Resetable
StandardException
- Standard exception policy.java.io.IOException
public void closeStream()
Close the container associated with this stream. (This will also free the associated IS table lock and the associated S row lock.)
closeStream
in interface Resetable
public java.io.InputStream cloneStream()
Creates a deep copy of this object. The returned stream has its own working buffers and can be initialized, reset and read independently from this stream.
The cloned stream is set back to the beginning of stream, no matter where the current stream happens to be positioned.
cloneStream
in interface CloneableStream
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.