org.basex.core.cmd
Class OptimizeAll

java.lang.Object
  extended by org.basex.core.Proc
      extended by org.basex.core.Command
          extended by org.basex.core.cmd.ACreate
              extended by org.basex.core.cmd.OptimizeAll

public final class OptimizeAll
extends ACreate

Evaluates the 'optimize all' command and rebuilds all data structures of the currently opened database. This effectively eliminates all fragmentation and can lead to significant space savings after updates.

Author:
BaseX Team 2005-12, BSD License, Leo Woerteler

Field Summary
 
Fields inherited from class org.basex.core.Command
args, context, in, mprop, out, perf, prop
 
Fields inherited from class org.basex.core.Proc
listen, updating
 
Constructor Summary
OptimizeAll()
          Default constructor.
 
Method Summary
 void build(CmdBuilder cb)
          Builds a string representation from the command.
 void databases(LockResult lr)
          Adds the names of the databases that may be touched by the process.
 java.lang.String det()
          Returns short information on this process.
 boolean newData(Context ctx)
          Closes an open data reference and returns true if this command will change the Context.data reference.
static void optimizeAll(Data data, Context ctx, OptimizeAll cmd)
          Optimizes all data structures and closes the database.
 double prog()
          Returns a progress value (0 - 1).
protected  boolean run()
          Executes the command and serializes the result (internal call).
 boolean stoppable()
          Returns true if this command can be stopped.
 
Methods inherited from class org.basex.core.cmd.ACreate
create, drop, sourceToIO, supportsProg
 
Methods inherited from class org.basex.core.Command
close, databases, error, execute, execute, getOption, getOption, info, info, result, run, run, setInput, setInput, toString, updated, updating
 
Methods inherited from class org.basex.core.Proc
abort, checkStop, detail, listen, proc, progress, registered, registered, startTimeout, stop, stopTimeout, tit, title
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OptimizeAll

public OptimizeAll()
Default constructor.

Method Detail

run

protected boolean run()
Description copied from class: Command
Executes the command and serializes the result (internal call).

Specified by:
run in class Command
Returns:
success of operation

newData

public boolean newData(Context ctx)
Description copied from class: Command
Closes an open data reference and returns true if this command will change the Context.data reference. This method is required by the progress dialog in the frontend.

Overrides:
newData in class ACreate
Parameters:
ctx - database context
Returns:
result of check

databases

public void databases(LockResult lr)
Description copied from class: Proc
Adds the names of the databases that may be touched by the process.

Overrides:
databases in class ACreate
Parameters:
lr - Container for lock result to pass around

prog

public double prog()
Description copied from class: Proc
Returns a progress value (0 - 1). Can be overwritten to give more detailed information.

Overrides:
prog in class Proc
Returns:
header information

stoppable

public boolean stoppable()
Description copied from class: Command
Returns true if this command can be stopped. This method is required by the progress dialog in the frontend.

Overrides:
stoppable in class ACreate
Returns:
result of check

det

public java.lang.String det()
Description copied from class: Proc
Returns short information on this process.

Overrides:
det in class Proc
Returns:
header information

build

public void build(CmdBuilder cb)
Description copied from class: Command
Builds a string representation from the command. This string must be correctly built, as commands are sent to the server as strings.

Overrides:
build in class Command
Parameters:
cb - command builder

optimizeAll

public static void optimizeAll(Data data,
                               Context ctx,
                               OptimizeAll cmd)
                        throws java.io.IOException
Optimizes all data structures and closes the database. Recreates the database, drops the old instance and renames the recreated instance.

Parameters:
data - disk data
ctx - database context
cmd - command reference, or null
Throws:
java.io.IOException - I/O Exception during index rebuild
BaseXException - database exception