Package org.h2.mvstore.db
Class Store
- java.lang.Object
-
- org.h2.mvstore.db.Store
-
public final class Store extends java.lang.ObjectA store with open tables.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanencryptedprivate java.lang.StringfileNameprivate MVStoremvStoreThe store.private longstatisticsStartprivate java.util.concurrent.ConcurrentHashMap<java.lang.String,MVTable>tableMapThe map of open tables.private inttemporaryMapIdprivate TransactionStoretransactionStoreThe transaction store.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose(int allowedCompactionTime)Close the store.voidcloseImmediately()Close the store, without persisting changes.voidcompactFile(int maxCompactTime)Compact the database file, that is, compact blocks that have a low fill rate, and move chunks next to each other.(package private) DbExceptionconvertMVStoreException(MVStoreException e)Convert a MVStoreException to the similar exception used for the table/sql layers.MVTablecreateTable(CreateTableData data)Create a table.(package private) static char[]decodePassword(byte[] key)Convert password from byte[] to char[].voidflush()Store all pending changes.java.util.ArrayList<InDoubtTransaction>getInDoubtTransactions()java.io.InputStreamgetInputStream()MVStoregetMvStore()MVTablegetTable(java.lang.String tableName)Get MVTable by table name.TransactionStoregetTransactionStore()java.lang.StringnextTemporaryMapName()Get the name of the next available temporary map.voidprepareCommit(SessionLocal session, java.lang.String transactionName)Prepare a transaction.voidremoveTable(MVTable table)Remove a table.voidremoveTemporaryMaps(java.util.BitSet objectIds)Remove all temporary maps.voidsetCacheSize(int kb)Set the maximum memory to be used by the cache.java.util.Map<java.lang.String,java.lang.Integer>statisticsEnd()Stop collecting statistics.voidstatisticsStart()Start collecting statistics.voidsync()Force the changes to disk.
-
-
-
Field Detail
-
tableMap
private final java.util.concurrent.ConcurrentHashMap<java.lang.String,MVTable> tableMap
The map of open tables. Key: the map name, value: the table.
-
mvStore
private final MVStore mvStore
The store.
-
transactionStore
private final TransactionStore transactionStore
The transaction store.
-
statisticsStart
private long statisticsStart
-
temporaryMapId
private int temporaryMapId
-
encrypted
private final boolean encrypted
-
fileName
private final java.lang.String fileName
-
-
Constructor Detail
-
Store
public Store(Database db)
Creates the store.- Parameters:
db- the database
-
-
Method Detail
-
decodePassword
static char[] decodePassword(byte[] key)
Convert password from byte[] to char[].- Parameters:
key- password as byte[]- Returns:
- password as char[].
-
convertMVStoreException
DbException convertMVStoreException(MVStoreException e)
Convert a MVStoreException to the similar exception used for the table/sql layers.- Parameters:
e- the illegal state exception- Returns:
- the database exception
-
getMvStore
public MVStore getMvStore()
-
getTransactionStore
public TransactionStore getTransactionStore()
-
getTable
public MVTable getTable(java.lang.String tableName)
Get MVTable by table name.- Parameters:
tableName- table name- Returns:
- MVTable
-
createTable
public MVTable createTable(CreateTableData data)
Create a table.- Parameters:
data- CreateTableData- Returns:
- table created
-
removeTable
public void removeTable(MVTable table)
Remove a table.- Parameters:
table- the table
-
flush
public void flush()
Store all pending changes.
-
closeImmediately
public void closeImmediately()
Close the store, without persisting changes.
-
removeTemporaryMaps
public void removeTemporaryMaps(java.util.BitSet objectIds)
Remove all temporary maps.- Parameters:
objectIds- the ids of the objects to keep
-
nextTemporaryMapName
public java.lang.String nextTemporaryMapName()
Get the name of the next available temporary map.- Returns:
- the map name
-
prepareCommit
public void prepareCommit(SessionLocal session, java.lang.String transactionName)
Prepare a transaction.- Parameters:
session- the sessiontransactionName- the transaction name (may be null)
-
getInDoubtTransactions
public java.util.ArrayList<InDoubtTransaction> getInDoubtTransactions()
-
setCacheSize
public void setCacheSize(int kb)
Set the maximum memory to be used by the cache.- Parameters:
kb- the maximum size in KB
-
getInputStream
public java.io.InputStream getInputStream()
-
sync
public void sync()
Force the changes to disk.
-
compactFile
public void compactFile(int maxCompactTime)
Compact the database file, that is, compact blocks that have a low fill rate, and move chunks next to each other. This will typically shrink the database file. Changes are flushed to the file, and old chunks are overwritten.- Parameters:
maxCompactTime- the maximum time in milliseconds to compact
-
close
public void close(int allowedCompactionTime)
Close the store. Pending changes are persisted. If time is allocated for housekeeping, chunks with a low fill rate are compacted, and some chunks are put next to each other. If time is unlimited then full compaction is performed, which uses different algorithm - opens alternative temp store and writes all live data there, then replaces this store with a new one.- Parameters:
allowedCompactionTime- time (in milliseconds) alloted for file compaction activity, 0 means no compaction, -1 means unlimited time (full compaction)
-
statisticsStart
public void statisticsStart()
Start collecting statistics.
-
statisticsEnd
public java.util.Map<java.lang.String,java.lang.Integer> statisticsEnd()
Stop collecting statistics.- Returns:
- the statistics
-
-