Class 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-21, BSD License, Leo Woerteler
  • Constructor Details

    • OptimizeAll

      public OptimizeAll()
      Default constructor.
  • Method Details

    • 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 only required by the GUI.
      Overrides:
      newData in class ACreate
      Parameters:
      ctx - database context
      Returns:
      result of check
    • stoppable

      public boolean stoppable()
      Description copied from class: Command
      Returns true if this command can be stopped. This method is only required by the GUI.
      Overrides:
      stoppable in class ACreate
      Returns:
      result of check
    • 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 context, MainOptions options, OptimizeAll cmd) throws 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
      context - database context
      options - main options
      cmd - command reference or null
      Throws:
      IOException - I/O Exception during index rebuild
      BaseXException - database exception