com.sleepycat.je.incomp
Class INCompressor

java.lang.Object
  extended by com.sleepycat.je.utilint.DaemonThread
      extended by com.sleepycat.je.incomp.INCompressor
All Implemented Interfaces:
DaemonRunner, java.lang.Runnable

public class INCompressor
extends DaemonThread

The IN Compressor. JE compression consist of removing delete entries from BINs, and pruning empty IN/BINs from the tree. Compression is carried out by either a daemon thread or lazily by operations (namely checkpointing and eviction) that are writing INS.


Field Summary
 
Fields inherited from class com.sleepycat.je.utilint.DaemonThread
name, nWakeupRequests, stifleExceptionChatter
 
Constructor Summary
INCompressor(EnvironmentImpl env, long waitTime, java.lang.String name)
           
 
Method Summary
 void addBinKeyToQueue(BIN bin, Key deletedKey, boolean doWakeup)
          Adds the BIN and deleted Key to the queue if the BIN is not already in the queue, or adds the deleted key to an existing entry if one exists.
 void addBinRefToQueue(BINReference binRef, boolean doWakeup)
          Adds the BINReference to the queue if the BIN is not already in the queue, or adds the deleted keys to an existing entry if one exists.
 void addMultipleBinRefsToQueue(java.util.Collection<BINReference> binRefs, boolean doWakeup)
          Adds an entire collection of BINReferences to the queue at once.
 void clearEnv()
           
 void doCompress()
          The real work to doing a compress.
 boolean exists(long nodeId)
           
 int getBinRefQueueSize()
           
 void lazyCompress(IN in, LocalUtilizationTracker localTracker)
          Lazily compress a single BIN.
 void loadStats(StatsConfig config, EnvironmentStats stat)
          Return stats
protected  long nDeadlockRetries()
          Return the number of retries when a deadlock exception occurs.
 void onWakeup()
          onWakeup is synchronized to ensure that multiple invocations of the DaemonThread aren't made.
 BIN searchForBIN(DatabaseImpl db, BINReference binRef)
          Search the tree for the BIN or DBIN that corresponds to this BINReference.
 void setBeforeFlushTrackerHook(TestHook hook)
           
 void verifyCursors()
           
 
Methods inherited from class com.sleepycat.je.utilint.DaemonThread
checkErrorListener, getExceptionListener, getNWakeupRequests, getThread, isPaused, isRunning, isShutdownRequested, requestShutdown, run, runOrPause, setExceptionListener, shutdown, toString, wakeup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

INCompressor

public INCompressor(EnvironmentImpl env,
                    long waitTime,
                    java.lang.String name)
             throws DatabaseException
Throws:
DatabaseException
Method Detail

clearEnv

public void clearEnv()

setBeforeFlushTrackerHook

public void setBeforeFlushTrackerHook(TestHook hook)

verifyCursors

public void verifyCursors()
                   throws DatabaseException
Throws:
DatabaseException

getBinRefQueueSize

public int getBinRefQueueSize()
                       throws DatabaseException
Throws:
DatabaseException

addBinKeyToQueue

public void addBinKeyToQueue(BIN bin,
                             Key deletedKey,
                             boolean doWakeup)
                      throws DatabaseException
Adds the BIN and deleted Key to the queue if the BIN is not already in the queue, or adds the deleted key to an existing entry if one exists.

Throws:
DatabaseException

addBinRefToQueue

public void addBinRefToQueue(BINReference binRef,
                             boolean doWakeup)
                      throws DatabaseException
Adds the BINReference to the queue if the BIN is not already in the queue, or adds the deleted keys to an existing entry if one exists.

Throws:
DatabaseException

addMultipleBinRefsToQueue

public void addMultipleBinRefsToQueue(java.util.Collection<BINReference> binRefs,
                                      boolean doWakeup)
                               throws DatabaseException
Adds an entire collection of BINReferences to the queue at once. Use this to avoid latching for each add.

Throws:
DatabaseException

exists

public boolean exists(long nodeId)

loadStats

public void loadStats(StatsConfig config,
                      EnvironmentStats stat)
               throws DatabaseException
Return stats

Throws:
DatabaseException

nDeadlockRetries

protected long nDeadlockRetries()
                         throws DatabaseException
Return the number of retries when a deadlock exception occurs.

Overrides:
nDeadlockRetries in class DaemonThread
Throws:
DatabaseException

onWakeup

public void onWakeup()
              throws DatabaseException
Description copied from class: DaemonThread
onWakeup is synchronized to ensure that multiple invocations of the DaemonThread aren't made.

Specified by:
onWakeup in class DaemonThread
Throws:
DatabaseException

doCompress

public void doCompress()
                throws DatabaseException
The real work to doing a compress. This may be called by the compressor thread or programatically.

Throws:
DatabaseException

searchForBIN

public BIN searchForBIN(DatabaseImpl db,
                        BINReference binRef)
                 throws DatabaseException
Search the tree for the BIN or DBIN that corresponds to this BINReference.

Parameters:
binRef - the BINReference that indicates the bin we want.
Returns:
the BIN or DBIN that corresponds to this BINReference. The node is latched upon return. Returns null if the BIN can't be found.
Throws:
DatabaseException

lazyCompress

public void lazyCompress(IN in,
                         LocalUtilizationTracker localTracker)
                  throws DatabaseException
Lazily compress a single BIN. Do not do any pruning. The target IN should be latched when we enter, and it will be remain latched.

Throws:
DatabaseException