Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.data

public Class OverflowInputStream

extends BufferedByteHolderInputStream
implements Resetable, CloneableStream
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.io.CloneableStream, org.apache.derby.iapi.types.Resetable
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, .MessageId, org.apache.derby.iapi.services.io.CloneableStream, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.store.raw.RecordHandle, .LockingPolicy, org.apache.derby.iapi.types.Resetable, org.apache.derby.iapi.store.access.TransactionController, java.io.EOFException, .InputStream, .IOException

A OverflowInputStream is used by store to turn a long column into an InputStream.

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);

Field Summary

Modifier and TypeField and Description
protected int
protected long
private boolean
protected int
protected long
protected BaseContainerHandle
owner

Fields of the class

protected RecordHandle

Constructor Summary

AccessConstructor and Description
public
OverflowInputStream(ByteHolder
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().
bh
,
BaseContainerHandle
BaseContainerHandle used to read pages from the container. Note this handle is closed automatically on commit.
owner
,
long
The first overflow page of this long column.
overflowPage
,
int
The record id of 1st segment of the long column on overflowPage.
overflowId
,
RecordHandle
RecordHandle of the owning record of the long long column, this is the row level lock to get.
recordToLock
)

Constructor for OverflowInputStream

It is up to the caller to allocate the ByteHolder for this stream, and pass it in.

Method Summary

Modifier and TypeMethod and Description
public InputStream

Returns:

Copy of this stream which can be used independently.
cloneStream
()

Implements org.apache.derby.iapi.services.io.CloneableStream.cloneStream.

Clone this object.

public void
closeStream()

Implements org.apache.derby.iapi.types.Resetable.closeStream.

Close the Resetable stream.

public void
fillByteHolder()

Implements abstract org.apache.derby.impl.store.raw.data.BufferedByteHolderInputStream.fillByteHolder.

If bytes remain in stream, insure the current buffer is not empty.

public int
public long
public void
initStream()

Implements org.apache.derby.iapi.types.Resetable.initStream.

Initialize a Resetable stream.

public void
resetStream()

Implements org.apache.derby.iapi.types.Resetable.resetStream.

Reset the stream back to beginning of the long column.

public void
setOverflowId(int
Page number containing the next segment of the long column. -1 if there are no more segments.
overflowId
)

Set the next overflow page of the long column.

public void
setOverflowPage(long
Page number containing the next segment of the long column. -1 if there are no more segments.
overflowPage
)

Set the next overflow page of the long column.

Inherited from org.apache.derby.impl.store.raw.data.BufferedByteHolderInputStream:
availablereadreadskip

Field Detail

firstOverflowIdback to summary
protected int firstOverflowId
firstOverflowPageback to summary
protected long firstOverflowPage
initializedback to summary
private boolean initialized
overflowIdback to summary
protected int overflowId
overflowPageback to summary
protected long overflowPage
ownerback to summary
protected BaseContainerHandle owner

Fields of the class

recordToLockback to summary
protected RecordHandle recordToLock

Constructor Detail

OverflowInputStreamback to summary
public OverflowInputStream(ByteHolder bh, BaseContainerHandle owner, long overflowPage, int overflowId, RecordHandle recordToLock)

Constructor for OverflowInputStream

It is up to the caller to allocate the ByteHolder for this stream, and pass it in.

Parameters
bh:ByteHolder

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

BaseContainerHandle used to read pages from the container. Note this handle is closed automatically on commit.

overflowPage:long

The first overflow page of this long column.

overflowId:int

The record id of 1st segment of the long column on overflowPage.

recordToLock:RecordHandle

RecordHandle of the owning record of the long long column, this is the row level lock to get.

Method Detail

cloneStreamback to summary
public InputStream cloneStream()

Implements org.apache.derby.iapi.services.io.CloneableStream.cloneStream.

Clone this object.

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.

Returns:InputStream

Copy of this stream which can be used independently.

closeStreamback to summary
public void closeStream()

Implements org.apache.derby.iapi.types.Resetable.closeStream.

Close the Resetable stream.

Close the container associated with this stream. (This will also free the associated IS table lock and the associated S row lock.)

fillByteHolderback to summary
public void fillByteHolder() throws IOException

Implements abstract org.apache.derby.impl.store.raw.data.BufferedByteHolderInputStream.fillByteHolder.

If bytes remain in stream, insure the current buffer is not empty.

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.

getOverflowIdback to summary
public int getOverflowId()
getOverflowPageback to summary
public long getOverflowPage()
initStreamback to summary
public void initStream() throws StandardException

Implements org.apache.derby.iapi.types.Resetable.initStream.

Initialize a Resetable stream.

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.

Exceptions
StandardException:
Standard exception policy.
resetStreamback to summary
public void resetStream() throws IOException, StandardException

Implements org.apache.derby.iapi.types.Resetable.resetStream.

Reset the stream back to beginning of the long column.

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().

Exceptions
IOException:

Doc from org.apache.derby.iapi.types.Resetable.resetStream.

on error

StandardException:
Standard exception policy.
setOverflowIdback to summary
public void setOverflowId(int overflowId)

Set the next overflow page of the long column.

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.

Parameters
overflowId:int

Page number containing the next segment of the long column. -1 if there are no more segments.

setOverflowPageback to summary
public void setOverflowPage(long overflowPage)

Set the next overflow page of the long column.

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.

Parameters
overflowPage:long

Page number containing the next segment of the long column. -1 if there are no more segments.