Package org.h2.mvstore
Class MVStoreTool
- java.lang.Object
-
- org.h2.mvstore.MVStoreTool
-
public class MVStoreTool extends java.lang.ObjectUtility methods used in combination with the MVStore.
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_NB_FILE_HEADERS_PER_FILE
-
Constructor Summary
Constructors Constructor Description MVStoreTool()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcompact(java.lang.String fileName, boolean compress)Compress the store by creating a new file and copying the live pages there.static voidcompactCleanUp(java.lang.String fileName)Clean up if needed, in a case a compact operation was interrupted due to killing the process or a power failure.static voiddump(java.lang.String fileName, boolean details)Read the contents of the file and write them to system out.static voiddump(java.lang.String fileName, java.io.Writer writer, boolean details)Read the contents of the file and display them in a human-readable format.static voidinfo(java.lang.String fileName)Read the summary information of the file and write them to system out.static java.lang.Stringinfo(java.lang.String fileName, java.io.Writer writer)Read the summary information of the file and write them to system out.static voidmain(java.lang.String... args)Runs this tool.static voidmoveAtomicReplace(java.lang.String sourceName, java.lang.String destinationName)Rename a file(s) of the named store, and try to atomically replace an existing file(s) of another store.static voidrepair(java.lang.String fileName)Repair a store by rolling back to the newest good version.static longrollback(java.lang.String fileName, long targetVersion, java.io.Writer writer)Roll back to a given revision into a file called *.temp.
-
-
-
Field Detail
-
MAX_NB_FILE_HEADERS_PER_FILE
public static final int MAX_NB_FILE_HEADERS_PER_FILE
- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(java.lang.String... args)
Runs this tool. Options are case-sensitive. Supported options are:Command line options [-dump <fileName>] Dump the contends of the file [-info <fileName>] Get summary information about a file [-compact <fileName>] Compact a store [-compress <fileName>] Compact a store with compression enabled - Parameters:
args- the command line arguments
-
dump
public static void dump(java.lang.String fileName, boolean details)Read the contents of the file and write them to system out.- Parameters:
fileName- the name of the filedetails- whether to print details
-
info
public static void info(java.lang.String fileName)
Read the summary information of the file and write them to system out.- Parameters:
fileName- the name of the file
-
dump
public static void dump(java.lang.String fileName, java.io.Writer writer, boolean details)Read the contents of the file and display them in a human-readable format.- Parameters:
fileName- the name of the filewriter- the print writerdetails- print the page details
-
info
public static java.lang.String info(java.lang.String fileName, java.io.Writer writer)Read the summary information of the file and write them to system out.- Parameters:
fileName- the name of the filewriter- the print writer- Returns:
- null if successful (there was no error), otherwise the error message
-
compact
public static void compact(java.lang.String fileName, boolean compress)Compress the store by creating a new file and copying the live pages there. Temporarily, a file with the suffix ".tempFile" is created. This file is then renamed, replacing the original file, if possible. If not, the new file is renamed to ".newFile", then the old file is removed, and the new file is renamed. This might be interrupted, so it's better to compactCleanUp before opening a store, in case this method was used.- Parameters:
fileName- the file namecompress- whether to compress the data
-
moveAtomicReplace
public static void moveAtomicReplace(java.lang.String sourceName, java.lang.String destinationName)Rename a file(s) of the named store, and try to atomically replace an existing file(s) of another store.- Parameters:
sourceName- the old fully qualified file name of the storedestinationName- the new fully qualified file name of the store
-
compactCleanUp
public static void compactCleanUp(java.lang.String fileName)
Clean up if needed, in a case a compact operation was interrupted due to killing the process or a power failure. This will delete temporary files (if any), and in case atomic file replacements were not used, rename the new file.- Parameters:
fileName- the file name
-
repair
public static void repair(java.lang.String fileName)
Repair a store by rolling back to the newest good version.- Parameters:
fileName- the file name
-
rollback
public static long rollback(java.lang.String fileName, long targetVersion, java.io.Writer writer)Roll back to a given revision into a file called *.temp.- Parameters:
fileName- the file nametargetVersion- the version to roll back to (Long.MAX_VALUE for the latest version)writer- the log writer- Returns:
- the version rolled back to (-1 if no version)
-
-