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

public Class MemByteHolder

extends Object
implements ByteHolder
Class Inheritance
All Implemented Interfaces
org.apache.derby.impl.store.raw.data.ByteHolder
Imports
org.apache.derby.shared.common.sanity.SanityManager, java.io.IOException, .InputStream, .OutputStream, java.util.Vector

A ByteHolder that stores all its bytes in memory.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv Vector<byte[]>
pack-priv byte[]
pack-priv int
pack-priv int
pack-priv int
pack-priv int
pack-priv int
pack-priv boolean

Constructor Summary

AccessConstructor and Description
public
MemByteHolder(int bufSize)

Create a new MemByteHolder.

Method Summary

Modifier and TypeMethod and Description
public int
available()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.available.

Return the number of bytes that can be read from this ByteHolder without blocking on an IO.

public void
clear()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.clear.

Clear the bytes from the ByteHolder and place it in writing mode.

public ByteHolder
cloneEmpty()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.cloneEmpty.

Return a byte holder matching existing type and size of current ByteHolder, but don't bother to fill the bytes.

private String
dumpBuf(int bufVEleAt)

Create a string representation of an internal buffer of bytes.

protected boolean

Returns:

true if the user has read all the bytes in this ByteHolder.
getNextBuffer_r
()

Get the next buffer for reading bytes.

protected void
getNextBuffer_w()

Get the next buffer for writing bytes.

protected void
getNextBuffer_w_Sanity()

Do sanity checking when getting the next write buffer

protected void
initBuffer_w()

Initialize a buffer for writing

public int
numBytesSaved()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.numBytesSaved.

Return the number of bytes that have been saved to this byte holder.

public int
read()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.read.

Read a byte from this ByteHolder.

public int
read(byte[] b, int off, int len)

Implements org.apache.derby.impl.store.raw.data.ByteHolder.read.

Read up to 'len' bytes from this ByteHolder and store them in an array at offset 'off'.

public int
read(OutputStream out, int len)

Implements org.apache.derby.impl.store.raw.data.ByteHolder.read.

Read from the ByteHolder.

public int
read(byte[] b, int off, OutputStream out, int len)

public int
shiftToFront()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.shiftToFront.

shift the remaining unread bytes to the beginning of the byte holder

public long
skip(long count)

Implements org.apache.derby.impl.store.raw.data.ByteHolder.skip.

Skip over the specified number of bytes in a ByteHolder.

public void
startReading()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.startReading.

Place a ByteHolder in reading mode.

public String
toString()

Overrides java.lang.Object.toString.

Produce a string describing the state of this ByteHolder.

public void
write(int b)

Implements org.apache.derby.impl.store.raw.data.ByteHolder.write.

Write a byte to this ByteHolder.

public void
write(byte[] data, int offset, int len)

Implements org.apache.derby.impl.store.raw.data.ByteHolder.write.

Write len bytes of data starting at 'offset' to this ByteHolder.

public long
write(InputStream is, long count)

Implements org.apache.derby.impl.store.raw.data.ByteHolder.write.

Write up to count bytes from an input stream to this ByteHolder.

public boolean
writingMode()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.writingMode.

Return true if this is in writing mode.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bufSizeback to summary
pack-priv int bufSize
bufVback to summary
pack-priv Vector<byte[]> bufV
curBufback to summary
pack-priv byte[] curBuf
curBufDataBytesback to summary
pack-priv int curBufDataBytes
curBufPosback to summary
pack-priv int curBufPos
curBufVEleAtback to summary
pack-priv int curBufVEleAt
lastBufDataBytesback to summary
pack-priv int lastBufDataBytes
lastBufVEleAtback to summary
pack-priv int lastBufVEleAt
writingback to summary
pack-priv boolean writing

Constructor Detail

MemByteHolderback to summary
public MemByteHolder(int bufSize)

Create a new MemByteHolder. Store bytes as a list of buffers of size 'bufSize'.

Method Detail

availableback to summary
public int available()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.available.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.available.

Return the number of bytes that can be read from this ByteHolder without blocking on an IO.

See Also
ByteHolder#available
clearback to summary
public void clear() throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.clear.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.clear.

Clear the bytes from the ByteHolder and place it in writing mode. This may not free the memory the ByteHolder uses to store data.

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#clear
cloneEmptyback to summary
public ByteHolder cloneEmpty()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.cloneEmpty.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.cloneEmpty.

Return a byte holder matching existing type and size of current ByteHolder, but don't bother to fill the bytes. Normal usage is expected to reset the holding stream to the beginning, so the copy of current state would be wasted.

Returns:ByteHolder

An empty ByteHolder.

See Also
ByteHolder#cloneEmpty
dumpBufback to summary
private String dumpBuf(int bufVEleAt)

Create a string representation of an internal buffer of bytes. This is useful during debugging.

getNextBuffer_rback to summary
protected boolean getNextBuffer_r() throws IOException

Get the next buffer for reading bytes.

Returns:boolean

true if the user has read all the bytes in this ByteHolder.

Exceptions
IOException:
Thrown on error
getNextBuffer_wback to summary
protected void getNextBuffer_w() throws IOException

Get the next buffer for writing bytes.

Exceptions
IOException:
Thrown on error
getNextBuffer_w_Sanityback to summary
protected void getNextBuffer_w_Sanity()

Do sanity checking when getting the next write buffer

initBuffer_wback to summary
protected void initBuffer_w()

Initialize a buffer for writing

numBytesSavedback to summary
public int numBytesSaved()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.numBytesSaved.

Return the number of bytes that have been saved to this byte holder. This result is different from available() as it is unaffected by the current read position on the ByteHolder.

See Also
ByteHolder#numBytesSaved
readback to summary
public int read() throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.read.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.read.

Read a byte from this ByteHolder.

The ByteHolder must be in reading mode to call this.

Returns:int

The byte or -1 if there are no bytes available.

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#read
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.read.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.read.

Read up to 'len' bytes from this ByteHolder and store them in an array at offset 'off'.

The ByteHolder must be in reading mode to call this.

Returns:int

the number of bytes read or -1 if the this ByteHolder has no more bytes.

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#read
readback to summary
public int read(OutputStream out, int len) throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.read.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.read.

Read from the ByteHolder.

Read up to 'len' bytes from this ByteHolder and write them to the OutputStream

The ByteHolder must be in reading mode to call this.

Returns:int

the number of bytes read or -1 if the this ByteHolder has no more bytes.

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#read
readback to summary
public int read(byte[] b, int off, OutputStream out, int len) throws IOException
Exceptions
IOException:
Thrown on error
See Also
ByteHolder#read
shiftToFrontback to summary
public int shiftToFront() throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.shiftToFront.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.shiftToFront.

shift the remaining unread bytes to the beginning of the byte holder

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#shiftToFront
skipback to summary
public long skip(long count) throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.skip.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.skip.

Skip over the specified number of bytes in a ByteHolder.

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#skip
startReadingback to summary
public void startReading() throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.startReading.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.startReading.

Place a ByteHolder in reading mode. After this call, reads scan bytes sequentially in the order they were written to the ByteHolder starting from the first byte. When the ByteHolder is already in readmode this simply arranges for reads to start at the beginning of the sequence of saved bytes.

See Also
ByteHolder#startReading
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Produce a string describing the state of this ByteHolder. This is mainly for debugging.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

writeback to summary
public void write(int b) throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.write.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.write.

Write a byte to this ByteHolder.

The ByteHolder must be in writing mode to call this.

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#write
writeback to summary
public void write(byte[] data, int offset, int len) throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.write.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.write.

Write len bytes of data starting at 'offset' to this ByteHolder.

The ByteHolder must be in writing mode to call this.

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#write
writeback to summary
public long write(InputStream is, long count) throws IOException

Implements org.apache.derby.impl.store.raw.data.ByteHolder.write.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.write.

Write up to count bytes from an input stream to this ByteHolder. This may write fewer bytes if it encounters an end of file on the input stream.

Returns:long

the number of bytes written.

Exceptions
IOException:
Thrown on error
See Also
ByteHolder#write
writingModeback to summary
public boolean writingMode()

Implements org.apache.derby.impl.store.raw.data.ByteHolder.writingMode.

Doc from org.apache.derby.impl.store.raw.data.ByteHolder.writingMode.

Return true if this is in writing mode.

See Also
ByteHolder#writingMode