use of org.apache.derby.iapi.services.io.ArrayInputStream in project derby by apache.
the class StoredPage method storeField.
/**
* storeField
*
* @exception StandardException Standard Derby error policy
* @exception IOException RESOLVE
*/
public void storeField(LogInstant instant, int slot, int fieldNumber, ObjectInput in) throws StandardException, IOException {
logAction(instant);
int offset = getFieldOffset(slot, fieldNumber);
// get the field header information, the input stream came from the log
ArrayInputStream lrdi = rawDataIn;
lrdi.setPosition(offset);
int oldFieldStatus = StoredFieldHeader.readStatus(lrdi);
int oldFieldDataLength = StoredFieldHeader.readFieldDataLength(lrdi, oldFieldStatus, slotFieldSize);
int newFieldStatus = StoredFieldHeader.readStatus(in);
int newFieldDataLength = StoredFieldHeader.readFieldDataLength(in, newFieldStatus, slotFieldSize);
newFieldStatus = StoredFieldHeader.setFixed(newFieldStatus, false);
int oldFieldLength = StoredFieldHeader.size(oldFieldStatus, oldFieldDataLength, slotFieldSize) + oldFieldDataLength;
int newFieldLength = StoredFieldHeader.size(newFieldStatus, newFieldDataLength, slotFieldSize) + newFieldDataLength;
createSpaceForUpdate(slot, offset, oldFieldLength, newFieldLength);
rawDataOut.setPosition(offset);
offset += StoredFieldHeader.write(rawDataOut, newFieldStatus, newFieldDataLength, slotFieldSize);
if (newFieldDataLength != 0)
in.readFully(pageData, offset, newFieldDataLength);
}
use of org.apache.derby.iapi.services.io.ArrayInputStream in project derby by apache.
the class StoredPage method logField.
/**
* Log a field to the ObjectOutput stream.
* <P>
* Find the field in the record and then write out the complete
* field, i.e. header and data.
*
* @exception StandardException Standard Derby error policy
* @exception IOException RESOLVE
*
* @see BasePage#logField
*/
public void logField(int slot, int fieldNumber, OutputStream out) throws StandardException, IOException {
int offset = getFieldOffset(slot, fieldNumber);
// these reads are always against the page array
ArrayInputStream lrdi = rawDataIn;
// now write out the field we are interested in ...
lrdi.setPosition(offset);
int fieldStatus = StoredFieldHeader.readStatus(lrdi);
int fieldDataLength = StoredFieldHeader.readFieldDataLength(lrdi, fieldStatus, slotFieldSize);
StoredFieldHeader.write(out, fieldStatus, fieldDataLength, slotFieldSize);
if (fieldDataLength != 0) {
// and then the data
out.write(pageData, lrdi.getPosition(), fieldDataLength);
}
}
use of org.apache.derby.iapi.services.io.ArrayInputStream in project derby by apache.
the class StoredPage method readPageHeader.
/**
************************************************************************
* Page header routines
**************************************************************************
*/
/**
* Read the page header from the page array.
* <p>
* Read the page header from byte form in the page array into in memory
* variables.
*/
private void readPageHeader() throws IOException {
// these reads are always against the page array
ArrayInputStream lrdi = rawDataIn;
lrdi.setPosition(PAGE_HEADER_OFFSET);
long spare;
isOverflowPage = lrdi.readBoolean();
setPageStatus(lrdi.readByte());
setPageVersion(lrdi.readLong());
slotsInUse = lrdi.readUnsignedShort();
nextId = lrdi.readInt();
// page generation (Future Use)
generation = lrdi.readInt();
// previous generation (Future Use)
prevGeneration = lrdi.readInt();
// BIPage location (Future Use)
bipLocation = lrdi.readLong();
// number of deleted rows on page, we start to store this release 2.0.
// for upgrade reasons, a 0 on disk means -1, so, we subtract one here.
deletedRowCount = lrdi.readUnsignedShort() - 1;
// the next 4 (total 22 bytes) are reserved for future
spare = lrdi.readUnsignedShort();
// used by encryption
spare = lrdi.readInt();
spare = lrdi.readLong();
spare = lrdi.readLong();
}
Aggregations