Search in sources :

Example 1 with ArrayOutputStream

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);
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) DynamicByteArrayOutputStream(org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream) ArrayOutputStream(org.apache.derby.iapi.services.io.ArrayOutputStream) FormatIdOutputStream(org.apache.derby.iapi.services.io.FormatIdOutputStream)

Example 2 with ArrayOutputStream

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();
}
Also used : ArrayOutputStream(org.apache.derby.iapi.services.io.ArrayOutputStream) FormatIdOutputStream(org.apache.derby.iapi.services.io.FormatIdOutputStream)

Aggregations

ArrayOutputStream (org.apache.derby.iapi.services.io.ArrayOutputStream)2 FormatIdOutputStream (org.apache.derby.iapi.services.io.FormatIdOutputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DynamicByteArrayOutputStream (org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream)1