org.apache.derby.impl.store.access.btree
Class BTreePostCommit

java.lang.Object
  extended byorg.apache.derby.impl.store.access.btree.BTreePostCommit
All Implemented Interfaces:
Serviceable

class BTreePostCommit
extends java.lang.Object
implements Serviceable

The BTreePostCommit class implements the Serviceable protocol. In it's role as a Serviceable object, it stores the state necessary to find a page in a btree that may have committed delete's to reclaim. In it's role as a PostCommitProcessor it looks up the page described, and reclaims space in the btree. It first trys to clean up any deleted commits on the page. It then will shrink the tree if it is going to delete all rows from the page (RESOLVE - not done yet).


Field Summary
private  AccessFactory access_factory
           
protected  BTree btree
           
private  long page_number
           
 
Fields inherited from interface org.apache.derby.iapi.services.daemon.Serviceable
DONE, REQUEUE
 
Constructor Summary
(package private) BTreePostCommit(AccessFactory access_factory, BTree btree, long input_page_number)
           
 
Method Summary
private  void doShrink(OpenBTree open_btree, DataValueDescriptor[] shrink_row)
           
private  DataValueDescriptor[] getShrinkKey(OpenBTree open_btree, ControlRow control_row, int slot_no)
           
 int performWork(ContextManager contextMgr)
          perform the work described in the postcommit work.
private  DataValueDescriptor[] purgeCommittedDeletes(OpenBTree open_btree, long pageno)
          Reclaim space taken up by committed deleted rows.
 boolean serviceASAP()
          The urgency of this post commit work.
 boolean serviceImmediately()
          If this work should be done immediately on the user thread then return true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

access_factory

private AccessFactory access_factory

page_number

private long page_number

btree

protected BTree btree
Constructor Detail

BTreePostCommit

BTreePostCommit(AccessFactory access_factory,
                BTree btree,
                long input_page_number)
Method Detail

serviceASAP

public boolean serviceASAP()
The urgency of this post commit work.

This determines where this Serviceable is put in the post commit queue. Post commit work in the btree can be safely delayed until there is not user work to do.

Specified by:
serviceASAP in interface Serviceable
Returns:
false, this work should not be serviced ASAP

serviceImmediately

public boolean serviceImmediately()
Description copied from interface: Serviceable
If this work should be done immediately on the user thread then return true. If it doesn't make any difference if this work is done on a the user thread immediately or if it is performed by another thread asynchronously later, then return false.

Specified by:
serviceImmediately in interface Serviceable

doShrink

private final void doShrink(OpenBTree open_btree,
                            DataValueDescriptor[] shrink_row)
                     throws StandardException
Throws:
StandardException

performWork

public int performWork(ContextManager contextMgr)
                throws StandardException
perform the work described in the postcommit work.

In this implementation the only work that can be executed by this post commit processor is this class itself.

Specified by:
performWork in interface Serviceable
Parameters:
contextMgr - the context manager started by the post commit daemon
Returns:
Returns Serviceable.DONE when work has completed, or returns Serviceable.REQUEUE if work needs to be requeued.
Throws:
StandardException - Standard exception policy.

getShrinkKey

private final DataValueDescriptor[] getShrinkKey(OpenBTree open_btree,
                                                 ControlRow control_row,
                                                 int slot_no)
                                          throws StandardException
Throws:
StandardException

purgeCommittedDeletes

private final DataValueDescriptor[] purgeCommittedDeletes(OpenBTree open_btree,
                                                          long pageno)
                                                   throws StandardException
Reclaim space taken up by committed deleted rows.

This routine assumes it has been called by an internal transaction which has performed no work so far, and that it has an exclusive table lock. These assumptions mean that any deleted rows encountered must be from committed transactions (otherwise we could not have gotten the exclusive table lock).

RESOLVE (mikem) - under row locking this routine must do more work to determine a deleted row is a committed deleted row.

Parameters:
open_btree - The btree already opened.
pageno - The page number of the page to look for committed deletes.
Throws:
StandardException - Standard exception policy.

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.