com.sleepycat.je.dbi
Class SortedLSNTreeWalker

java.lang.Object
  extended by com.sleepycat.je.dbi.SortedLSNTreeWalker

public class SortedLSNTreeWalker
extends Object

Class to walk over the tree using sorted LSN fetching for parts of the tree that are not in memory. Returns LSNs for each node in the tree except the root IN, but in an arbitrary order (i.e. not key order). The caller is responsible for getting the root IN's LSN explicitly.

A calllback function specified in the constructor is executed for each LSN found.

The walker works in two phases. The first phase is to gather and return all the INs from the INList that match the database being iterated over. For each IN, all of the LSNs of the children are passed to the callback method (processLSN). If the child was not in memory, it is added to a list of LSNs to read. When all of the in-memory INs have been processed, the list of LSNs that were harvested are sorted.

Then for each of the sorted LSNs, the target is fetched, the type determined, and the LSN and type passed to the callback method for processing. LSNs of the children of those nodes are retrieved and the process repeated until there are no more nodes to be fetched for this database's tree.


Nested Class Summary
static interface SortedLSNTreeWalker.ExceptionPredicate
           
static interface SortedLSNTreeWalker.TreeNodeProcessor
           
 
Field Summary
protected  boolean accumulateLNs
           
protected  DatabaseImpl dbImpl
           
 
Constructor Summary
SortedLSNTreeWalker(DatabaseImpl dbImpl, boolean removeINsFromINList, boolean setDbState, long rootLsn, SortedLSNTreeWalker.TreeNodeProcessor callback, List savedExceptions, SortedLSNTreeWalker.ExceptionPredicate excPredicate)
           
 
Method Summary
protected  void addToLsnINMap(Long lsn, IN in, int index)
           
protected  Node fetchLSN(long lsn, DatabaseEntry lnKeyEntry)
           
protected  IN getRootIN(long rootLsn)
          The default behavior fetches the rootIN from the log, but classes extending this may fetch the root from the tree.
 List getSavedExceptions()
           
protected  void releaseRootIN(IN ignore)
           
(package private)  void setPassNullLSNNodes(boolean passNullLSNNodes)
           
(package private)  void setProcessDupTree(boolean processDupTree)
           
 void walk()
          Find all non-resident nodes, and execute the callback.
protected  void walkInternal()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbImpl

protected DatabaseImpl dbImpl

accumulateLNs

protected boolean accumulateLNs
Constructor Detail

SortedLSNTreeWalker

public SortedLSNTreeWalker(DatabaseImpl dbImpl,
                           boolean removeINsFromINList,
                           boolean setDbState,
                           long rootLsn,
                           SortedLSNTreeWalker.TreeNodeProcessor callback,
                           List savedExceptions,
                           SortedLSNTreeWalker.ExceptionPredicate excPredicate)
                    throws DatabaseException
Throws:
DatabaseException
Method Detail

setProcessDupTree

void setProcessDupTree(boolean processDupTree)

setPassNullLSNNodes

void setPassNullLSNNodes(boolean passNullLSNNodes)

walk

public void walk()
          throws DatabaseException
Find all non-resident nodes, and execute the callback. The root IN's LSN is not returned to the callback.

Throws:
DatabaseException

walkInternal

protected void walkInternal()
                     throws DatabaseException
Throws:
DatabaseException

getRootIN

protected IN getRootIN(long rootLsn)
                throws DatabaseException
The default behavior fetches the rootIN from the log, but classes extending this may fetch the root from the tree.

Throws:
DatabaseException

releaseRootIN

protected void releaseRootIN(IN ignore)
                      throws DatabaseException
Throws:
DatabaseException

addToLsnINMap

protected void addToLsnINMap(Long lsn,
                             IN in,
                             int index)
Parameters:
index - a negative index signifies a DupCountLN.

fetchLSN

protected Node fetchLSN(long lsn,
                        DatabaseEntry lnKeyEntry)
                 throws DatabaseException
Throws:
DatabaseException

getSavedExceptions

public List getSavedExceptions()


Copyright 2004,2008 Oracle. All rights reserved.