Top Description Inners Fields Constructors Methods
org.h2.mvstore

public Class MVStoreTool

extends Object
Class Inheritance
Imports
java.io.IOException, .OutputStream, .PrintWriter, .Writer, java.nio.ByteBuffer, java.nio.channels.FileChannel, java.nio.charset.StandardCharsets, java.sql.Timestamp, java.util.Map, .Map.Entry, .TreeMap, org.h2.compress.CompressDeflate, .CompressLZF, .Compressor, org.h2.engine.Constants, org.h2.mvstore.tx.TransactionStore, org.h2.mvstore.type.BasicDataType, .StringDataType, org.h2.store.fs.FilePath, .FileUtils, org.h2.util.Utils

Utility methods used in combination with the MVStore.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
MVStoreTool.GenericDataType

A data type that can read any data that is persisted, and converts it to a byte array.

Field Summary

Modifier and TypeField and Description
public static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
compact(String
the file name
fileName
,
boolean
whether to compress the data
compress
)

Compress the store by creating a new file and copying the live pages there.

public static void
compact(String
the name of the source store
sourceFileName
,
String
the name of the target store
targetFileName
,
boolean
whether to compress the data
compress
)

Copy all live pages from the source store to the target store.

public static void
compact(MVStore
the source store
source
,
MVStore
the target store
target
)

Copy all live pages from the source store to the target store.

public static void
compactCleanUp(String
the file name
fileName
)

Clean up if needed, in a case a compact operation was interrupted due to killing the process or a power failure.

public static void
dump(String
the name of the file
fileName
,
boolean
whether to print details
details
)

Read the contents of the file and write them to system out.

public static void
dump(String
the name of the file
fileName
,
Writer
the print writer
writer
,
boolean
print the page details
details
)

Read the contents of the file and display them in a human-readable format.

private static String
formatTimestamp(long t, long start)

private static Compressor
getCompressor(boolean fast)

pack-priv static MVMap.Builder<Object, Object>
private static int
getPercent(long value, long max)

public static void
info(String
the name of the file
fileName
)

Read the summary information of the file and write them to system out.

public static String

Returns:

null if successful (if there was no error), otherwise the error message
info
(String
the name of the file
fileName
,
Writer
the print writer
writer
)

Read the summary information of the file and write them to system out.

public static void
main(String...
the command line arguments
args
)

Runs this tool.

public static void
moveAtomicReplace(String
the old fully qualified file name of the store
sourceName
,
String
the new fully qualified file name of the store
destinationName
)

Rename a file(s) of the named store, and try to atomically replace an existing file(s) of another store.

public static void
repair(String
the file name
fileName
)

Repair a store by rolling back to the newest good version.

public static long

Returns:

the version rolled back to (-1 if no version)
rollback
(String
the file name
fileName
,
long
the version to roll back to (Long.MAX_VALUE for the latest version)
targetVersion
,
Writer
the log writer
writer
)

Roll back to a given revision into a file called *.temp.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAX_NB_FILE_HEADERS_PER_FILEback to summary
public static final int MAX_NB_FILE_HEADERS_PER_FILE

Constructor Detail

MVStoreToolback to summary
public MVStoreTool()

Method Detail

compactback to summary
public static void compact(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:String

the file name

compress:boolean

whether to compress the data

compactback to summary
public static void compact(String sourceFileName, String targetFileName, boolean compress)

Copy all live pages from the source store to the target store.

Parameters
sourceFileName:String

the name of the source store

targetFileName:String

the name of the target store

compress:boolean

whether to compress the data

compactback to summary
public static void compact(MVStore source, MVStore target)

Copy all live pages from the source store to the target store.

Parameters
source:MVStore

the source store

target:MVStore

the target store

compactCleanUpback to summary
public static void compactCleanUp(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:String

the file name

dumpback to summary
public static void dump(String fileName, boolean details)

Read the contents of the file and write them to system out.

Parameters
fileName:String

the name of the file

details:boolean

whether to print details

dumpback to summary
public static void dump(String fileName, Writer writer, boolean details)

Read the contents of the file and display them in a human-readable format.

Parameters
fileName:String

the name of the file

writer:Writer

the print writer

details:boolean

print the page details

formatTimestampback to summary
private static String formatTimestamp(long t, long start)
getCompressorback to summary
private static Compressor getCompressor(boolean fast)
getGenericMapBuilderback to summary
pack-priv static MVMap.Builder<Object, Object> getGenericMapBuilder()
Annotations
@SuppressWarnings:rawtypes, unchecked
getPercentback to summary
private static int getPercent(long value, long max)
infoback to summary
public static void info(String fileName)

Read the summary information of the file and write them to system out.

Parameters
fileName:String

the name of the file

infoback to summary
public static String info(String fileName, Writer writer)

Read the summary information of the file and write them to system out.

Parameters
fileName:String

the name of the file

writer:Writer

the print writer

Returns:String

null if successful (if there was no error), otherwise the error message

mainback to summary
public static void main(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:String[]

the command line arguments

moveAtomicReplaceback to summary
public static void moveAtomicReplace(String sourceName, String destinationName)

Rename a file(s) of the named store, and try to atomically replace an existing file(s) of another store.

Parameters
sourceName:String

the old fully qualified file name of the store

destinationName:String

the new fully qualified file name of the store

repairback to summary
public static void repair(String fileName)

Repair a store by rolling back to the newest good version.

Parameters
fileName:String

the file name

rollbackback to summary
public static long rollback(String fileName, long targetVersion, Writer writer)

Roll back to a given revision into a file called *.temp.

Parameters
fileName:String

the file name

targetVersion:long

the version to roll back to (Long.MAX_VALUE for the latest version)

writer:Writer

the log writer

Returns:long

the version rolled back to (-1 if no version)

org.h2.mvstore back to summary

private Class MVStoreTool.GenericDataType

extends BasicDataType<byte[]>
Class Inheritance

A data type that can read any data that is persisted, and converts it to a byte array.

Field Summary

Modifier and TypeField and Description
pack-priv static MVStoreTool.GenericDataType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public byte[][]
createStorage(int
number of values to hold
size
)

Implements org.h2.mvstore.type.DataType.createStorage.

Create storage object of array type to hold values

public int
getMemory(byte[]
the object
obj
)

Implements abstract org.h2.mvstore.type.BasicDataType.getMemory.

Implements org.h2.mvstore.type.DataType.getMemory.

Calculates the amount of used memory in bytes.

public boolean
isMemoryEstimationAllowed()

Overrides org.h2.mvstore.type.BasicDataType.isMemoryEstimationAllowed.

Implements org.h2.mvstore.type.DataType.isMemoryEstimationAllowed.

Whether memory estimation based on previously seen values is allowed/desirable

public byte[]
read(ByteBuffer
the source buffer
buff
)

Implements abstract org.h2.mvstore.type.BasicDataType.read.

Implements org.h2.mvstore.type.DataType.read.

Read an object.

public void
write(WriteBuffer
the target buffer
buff
,
byte[]
the value
obj
)

Implements abstract org.h2.mvstore.type.BasicDataType.write.

Implements org.h2.mvstore.type.DataType.write.

Write an object.

Inherited from org.h2.mvstore.type.BasicDataType:
binarySearchcastcompareequalshashCodereadwrite

Field Detail

INSTANCEback to summary
pack-priv static MVStoreTool.GenericDataType INSTANCE

Constructor Detail

GenericDataTypeback to summary
private GenericDataType()

Method Detail

createStorageback to summary
public byte[][] createStorage(int size)

Implements org.h2.mvstore.type.DataType.createStorage.

Doc from org.h2.mvstore.type.DataType.createStorage.

Create storage object of array type to hold values

Parameters
size:int

number of values to hold

Returns:byte[][]

storage object

Annotations
@Override
getMemoryback to summary
public int getMemory(byte[] obj)

Implements abstract org.h2.mvstore.type.BasicDataType.getMemory.

Implements org.h2.mvstore.type.DataType.getMemory.

Doc from org.h2.mvstore.type.DataType.getMemory.

Calculates the amount of used memory in bytes.

Parameters
obj:byte[]

the object

Returns:int

the used memory

Annotations
@Override
isMemoryEstimationAllowedback to summary
public boolean isMemoryEstimationAllowed()

Overrides org.h2.mvstore.type.BasicDataType.isMemoryEstimationAllowed.

Implements org.h2.mvstore.type.DataType.isMemoryEstimationAllowed.

Doc from org.h2.mvstore.type.DataType.isMemoryEstimationAllowed.

Whether memory estimation based on previously seen values is allowed/desirable

Returns:boolean

true if memory estimation is allowed

Annotations
@Override
readback to summary
public byte[] read(ByteBuffer buff)

Implements abstract org.h2.mvstore.type.BasicDataType.read.

Implements org.h2.mvstore.type.DataType.read.

Doc from org.h2.mvstore.type.DataType.read.

Read an object.

Parameters
buff:ByteBuffer

the source buffer

Returns:byte[]

the object

Annotations
@Override
writeback to summary
public void write(WriteBuffer buff, byte[] obj)

Implements abstract org.h2.mvstore.type.BasicDataType.write.

Implements org.h2.mvstore.type.DataType.write.

Doc from org.h2.mvstore.type.DataType.write.

Write an object.

Parameters
buff:WriteBuffer

the target buffer

obj:byte[]

the value

Annotations
@Override