use of org.apache.derby.iapi.services.io.ArrayOutputStream in project derby by apache.
the class StoredPage method createOutStreams.
/**
* Create the output streams.
* <p>
* Create the output streams, these are created on demand
* to avoid creating unrequired objects for pages that are
* never modified during their lifetime in the cache.
* <p>
*
* @exception StandardException Standard exception policy.
*/
private void createOutStreams() {
rawDataOut = new ArrayOutputStream();
rawDataOut.setData(pageData);
logicalDataOut = new FormatIdOutputStream(rawDataOut);
}
use of org.apache.derby.iapi.services.io.ArrayOutputStream in project derby by apache.
the class FileContainer method writeHeaderToArray.
/**
* Write containerInfo into a byte array
* The container Header thus put together can be read by readHeaderFromArray.
*
* @exception IOException error in writing the header
*/
private void writeHeaderToArray(byte[] a) throws IOException {
if (SanityManager.DEBUG)
SanityManager.ASSERT(a.length >= CONTAINER_INFO_SIZE, "header won't fit in array");
ArrayOutputStream a_out = new ArrayOutputStream(a);
FormatIdOutputStream outStream = new FormatIdOutputStream(a_out);
int status = 0;
if (getDroppedState())
status |= FILE_DROPPED;
if (getCommittedDropState())
status |= FILE_COMMITTED_DROP;
if (isReusableRecordId())
status |= FILE_REUSABLE_RECORDID;
a_out.setPosition(0);
a_out.setLimit(CONTAINER_INFO_SIZE);
outStream.writeInt(formatIdInteger);
outStream.writeInt(status);
outStream.writeInt(pageSize);
outStream.writeInt(spareSpace);
outStream.writeInt(minimumRecordSize);
outStream.writeShort(initialPages);
// write spare1
outStream.writeShort(PreAllocSize);
outStream.writeLong(firstAllocPageNumber);
outStream.writeLong(firstAllocPageOffset);
outStream.writeLong(containerVersion);
outStream.writeLong(estimatedRowCount);
outStream.writeLong(reusableRecordIdSequenceNumber);
// Write spare3
outStream.writeLong(0);
checksum.reset();
checksum.update(a, 0, CONTAINER_INFO_SIZE - CHECKSUM_SIZE);
// write the checksum to the array
outStream.writeLong(checksum.getValue());
a_out.clearLimit();
}
Aggregations