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

public final Class InsertOperation

extends LogicalPageOperation
Class Inheritance
Imports
org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.io.StoredFormatIds, .CompressedNumber, .FormatableBitSet, .DynamicByteArrayOutputStream, .LimitObjectInput, org.apache.derby.iapi.store.access.conglomerate.LogicalUndo, org.apache.derby.iapi.store.raw.PageKey, .Page, .Transaction, org.apache.derby.iapi.store.raw.log.LogInstant, org.apache.derby.iapi.store.raw.xact.RawTransaction, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.util.ByteArray, java.io.ObjectOutput, .ObjectInput, .IOException

Represents an insert of a record onto a page.
See Also
Page#insertAtSlot

Field Summary

Modifier and TypeField and Description
protected int
protected byte
protected transient ByteArray
protected transient int
startColumn

next column that need to be inserted.

Inherited from org.apache.derby.impl.store.raw.data.LogicalPageOperation:
recordIdundo

Constructor Summary

AccessConstructor and Description
pack-priv
InsertOperation(RawTransaction t, BasePage page, int slot, int recordId, Object[] row, FormatableBitSet validColumns, LogicalUndo undo, byte insertFlag, int startColumn, boolean isLongColumn, int realStartColumn, DynamicByteArrayOutputStream logBuffer, int realSpaceOnPage, int overflowThreshold)

public

Method Summary

Modifier and TypeMethod and Description
public void
doMe(Transaction
the Transaction
xact
,
LogInstant
the log instant of this operation
instant
,
LimitObjectInput
optional data
in
)

Implements org.apache.derby.iapi.store.raw.Loggable.doMe.

Apply the change indicated by this operation and optional data.

public int
public ByteArray
getPreparedLog()

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.getPreparedLog.

Implements org.apache.derby.iapi.store.raw.Loggable.getPreparedLog.

The log operations are responsible to create the ByteArray, and the log operations should write out any optional data for the change to the ByteArray.

public int
public void
readExternal(ObjectInput
the stream to read data from in order to restore the object
in
)

Overrides org.apache.derby.impl.store.raw.data.LogicalPageOperation.readExternal.

Implements java.io.Externalizable.readExternal.

Read this in

public void
restoreLoggedRow(Object[]
an IN/OUT parameter, caller passed in the row with the correct column number and type, the log operation will restore the row with the optional data stored in the log record.
row
,
LimitObjectInput in)

Implements org.apache.derby.iapi.store.raw.LogicalUndoable.restoreLoggedRow.

Restore the row stored in the optional data of the log record.

public void
restoreMe(Transaction
the Transaction doing the rollback
xact
,
BasePage
the page to rollback changes on
undoPage
,
LogInstant
the log instant of this (PageUndo) operation
CLRinstant
,
LimitObjectInput
optional data for the rollback operation
in
)

Implements abstract org.apache.derby.impl.store.raw.data.PageBasicOperation.restoreMe.

restore the before image of the page

public String
public void
undoMe(Transaction
the Transaction doing the rollback
xact
,
BasePage
the page to rollback changes on
undoPage
,
int
the recordId to rollback changes on
undoRecordId
,
LogInstant
the log instant of this (PageUndo) operation
CLRInstant
,
LimitObjectInput
optional data for the rollback operation
in
)

Implements abstract org.apache.derby.impl.store.raw.data.LogicalPageOperation.undoMe.

Undo the insert by simply marking the just inserted record as deleted.

public void
private void
writeOptionalDataToBuffer(RawTransaction t, DynamicByteArrayOutputStream logBuffer, Object[] row, FormatableBitSet validColumns, boolean isLongColumn, int realStartColumn, int realSpaceOnPage, int overflowThreshold)

Writes out the row that is to be inserted as the optional data.

Inherited from org.apache.derby.impl.store.raw.data.LogicalPageOperation:
generateUndogetContainergetRecordHandlereclaimPrepareLocksresetRecordHandle

Field Detail

doMeSlotback to summary
protected int doMeSlot
insertFlagback to summary
protected byte insertFlag
preparedLogback to summary
protected transient ByteArray preparedLog
startColumnback to summary
protected transient int startColumn

next column that need to be inserted.

Constructor Detail

InsertOperationback to summary
pack-priv InsertOperation(RawTransaction t, BasePage page, int slot, int recordId, Object[] row, FormatableBitSet validColumns, LogicalUndo undo, byte insertFlag, int startColumn, boolean isLongColumn, int realStartColumn, DynamicByteArrayOutputStream logBuffer, int realSpaceOnPage, int overflowThreshold) throws StandardException
InsertOperationback to summary
public InsertOperation()

Method Detail

doMeback to summary
public void doMe(Transaction xact, LogInstant instant, LimitObjectInput in) throws StandardException, IOException

Implements org.apache.derby.iapi.store.raw.Loggable.doMe.

Doc from org.apache.derby.iapi.store.raw.Loggable.doMe.

Apply the change indicated by this operation and optional data. If this method fail, the system will be shut down because the log record has already been written to disk. Moreover, the log record will be replayed during recovery and this doMe method will be called on the same page again, so if it fails again, recovery will fail and the database cannot be started. So it is very important to make sure that every resource you need, such as disk space, has been acquired before the logAndDo method is called!
This method cannot acquire any resource (like latching of a page) since it is called underneath the logging system, ie., the log record has already been written to the log stream.

The available() method of in indicates how much data can be read, i.e. how much was originally written.

Parameters
xact:Transaction

the Transaction

instant:LogInstant

the log instant of this operation

in:LimitObjectInput

optional data

Exceptions
StandardException:
Standard Derby policy.
IOException:
Can be thrown by any of the methods of ObjectInput.
See Also
org.apache.derby.iapi.store.raw.Loggable#doMe
getNextStartColumnback to summary
public int getNextStartColumn()
getPreparedLogback to summary
public ByteArray getPreparedLog()

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.getPreparedLog.

Implements org.apache.derby.iapi.store.raw.Loggable.getPreparedLog.

Doc from org.apache.derby.iapi.store.raw.Loggable.getPreparedLog.

The log operations are responsible to create the ByteArray, and the log operations should write out any optional data for the change to the ByteArray. The ByteArray can be prepared when the log operation is constructed, or it can be prepared when getPreparedLog() is called. Called by the log manager to allow the log operation to pass the buffer which contains optional data that will be available in to doMe() methods.

getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Return my format identifier.

Returns:int

Doc from org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

The identifier. (A UUID stuffed in an array of 16 bytes).

readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Overrides org.apache.derby.impl.store.raw.data.LogicalPageOperation.readExternal.

Implements java.io.Externalizable.readExternal.

Read this in

Parameters
in:ObjectInput

Doc from java.io.Externalizable.readExternal.

the stream to read data from in order to restore the object

Exceptions
IOException:
error reading from log stream
ClassNotFoundException:
log stream corrupted
restoreLoggedRowback to summary
public void restoreLoggedRow(Object[] row, LimitObjectInput in) throws StandardException, IOException

Implements org.apache.derby.iapi.store.raw.LogicalUndoable.restoreLoggedRow.

Restore the row stored in the optional data of the log record.

Parameters
row:Object[]

Doc from org.apache.derby.iapi.store.raw.LogicalUndoable.restoreLoggedRow.

an IN/OUT parameter, caller passed in the row with the correct column number and type, the log operation will restore the row with the optional data stored in the log record.

Exceptions
StandardException:
Standard Derby error policy
IOException:
error reading from log stream
restoreMeback to summary
public void restoreMe(Transaction xact, BasePage undoPage, LogInstant CLRinstant, LimitObjectInput in) throws StandardException, IOException

Implements abstract org.apache.derby.impl.store.raw.data.PageBasicOperation.restoreMe.

restore the before image of the page

Parameters
xact:Transaction

Doc from org.apache.derby.impl.store.raw.data.PageBasicOperation.restoreMe.

the Transaction doing the rollback

undoPage:BasePage

Doc from org.apache.derby.impl.store.raw.data.PageBasicOperation.restoreMe.

the page to rollback changes on

CLRinstant:LogInstant

Doc from org.apache.derby.impl.store.raw.data.PageBasicOperation.restoreMe.

the log instant of this (PageUndo) operation

in:LimitObjectInput

Doc from org.apache.derby.impl.store.raw.data.PageBasicOperation.restoreMe.

optional data for the rollback operation

Exceptions
StandardException:
Standard Derby Error Policy
IOException:
problem reading the complete log record from the input stream
toStringback to summary
public String toString()

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.toString.

DEBUG: Print self.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

undoMeback to summary
public void undoMe(Transaction xact, BasePage undoPage, int undoRecordId, LogInstant CLRInstant, LimitObjectInput in) throws StandardException, IOException

Implements abstract org.apache.derby.impl.store.raw.data.LogicalPageOperation.undoMe.

Undo the insert by simply marking the just inserted record as deleted. All logical undo logic has already been taken care of by generateUndo.

Parameters
xact:Transaction

Doc from org.apache.derby.impl.store.raw.data.LogicalPageOperation.undoMe.

the Transaction doing the rollback

undoPage:BasePage

Doc from org.apache.derby.impl.store.raw.data.LogicalPageOperation.undoMe.

the page to rollback changes on

undoRecordId:int

Doc from org.apache.derby.impl.store.raw.data.LogicalPageOperation.undoMe.

the recordId to rollback changes on

CLRInstant:LogInstant

Doc from org.apache.derby.impl.store.raw.data.LogicalPageOperation.undoMe.

the log instant of this (PageUndo) operation

in:LimitObjectInput

Doc from org.apache.derby.impl.store.raw.data.LogicalPageOperation.undoMe.

optional data for the rollback operation

Exceptions
StandardException:
Standard Derby policy.
IOException:
Can be thrown by any of the methods of ObjectInput.
See Also
LogicalPageOperation#undoMe
writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Overrides org.apache.derby.impl.store.raw.data.LogicalPageOperation.writeExternal.

Implements java.io.Externalizable.writeExternal.

Write this out.

Parameters
out:ObjectOutput

Doc from java.io.Externalizable.writeExternal.

the stream to write the object to

Exceptions
IOException:
error writing to log stream
writeOptionalDataToBufferback to summary
private void writeOptionalDataToBuffer(RawTransaction t, DynamicByteArrayOutputStream logBuffer, Object[] row, FormatableBitSet validColumns, boolean isLongColumn, int realStartColumn, int realSpaceOnPage, int overflowThreshold) throws StandardException, IOException

Writes out the row that is to be inserted as the optional data.

Exceptions
StandardException:
Standard Derby policy.
IOException:
Can be thrown by any of the methods of ObjectOutput