提交 0fe83909 authored 作者: Andrei Tokar's avatar Andrei Tokar

Rename fields to reflect actual type

Database.mvStore - > store
MVTableEngine.Store.store - > mvStore
上级 849484e9
......@@ -181,7 +181,7 @@ public abstract class Command implements CommandInterface {
startTimeNanos = 0;
long start = 0;
Database database = session.getDatabase();
Object sync = database.isMultiThreaded() || database.getMvStore() != null ? session : database;
Object sync = database.isMultiThreaded() || database.getStore() != null ? session : database;
session.waitIfExclusiveModeEnabled();
boolean callStop = true;
boolean writing = !isReadOnly();
......@@ -241,7 +241,7 @@ public abstract class Command implements CommandInterface {
public ResultWithGeneratedKeys executeUpdate(Object generatedKeysRequest) {
long start = 0;
Database database = session.getDatabase();
Object sync = database.isMultiThreaded() || database.getMvStore() != null ? session : database;
Object sync = database.isMultiThreaded() || database.getStore() != null ? session : database;
session.waitIfExclusiveModeEnabled();
boolean callStop = true;
boolean writing = !isReadOnly();
......@@ -330,7 +330,7 @@ public abstract class Command implements CommandInterface {
}
// Only in PageStore mode we need to sleep here to avoid busy wait loop
Database database = session.getDatabase();
if (database.getMvStore() == null) {
if (database.getStore() == null) {
int sleep = 1 + MathUtils.randomInt(10);
while (true) {
try {
......
......@@ -58,9 +58,9 @@ public class BackupCommand extends Prepared {
throw DbException.get(ErrorCode.DATABASE_IS_NOT_PERSISTENT);
}
try {
Store mvStore = db.getMvStore();
if (mvStore != null) {
mvStore.flush();
Store store = db.getStore();
if (store != null) {
store.flush();
}
String name = db.getName();
name = FileUtils.getName(name);
......@@ -83,12 +83,12 @@ public class BackupCommand extends Prepared {
if (n.endsWith(Constants.SUFFIX_LOB_FILE)) {
backupFile(out, base, n);
}
if (n.endsWith(Constants.SUFFIX_MV_FILE) && mvStore != null) {
MVStore s = mvStore.getStore();
if (n.endsWith(Constants.SUFFIX_MV_FILE) && store != null) {
MVStore s = store.getMvStore();
boolean before = s.getReuseSpace();
s.setReuseSpace(false);
try {
InputStream in = mvStore.getInputStream();
InputStream in = store.getInputStream();
backupFile(out, base, n, in);
} finally {
s.setReuseSpace(before);
......
......@@ -83,7 +83,7 @@ public class Explain extends Prepared {
if (store != null) {
store.statisticsStart();
}
mvStore = db.getMvStore();
mvStore = db.getStore();
if (mvStore != null) {
mvStore.statisticsStart();
}
......
......@@ -218,7 +218,7 @@ public class Database implements DataHandler {
private final DbSettings dbSettings;
private final long reconnectCheckDelayNs;
private int logMode;
private MVTableEngine.Store mvStore;
private MVTableEngine.Store store;
private int retentionTime;
private boolean allowBuiltinAliasOverride;
private final AtomicReference<DbException> backgroundException = new AtomicReference<>();
......@@ -376,13 +376,13 @@ public class Database implements DataHandler {
powerOffCount = count;
}
public MVTableEngine.Store getMvStore() {
return mvStore;
public MVTableEngine.Store getStore() {
return store;
}
public void setMvStore(MVTableEngine.Store mvStore) {
this.mvStore = mvStore;
this.retentionTime = mvStore.getStore().getRetentionTime();
public void setStore(MVTableEngine.Store store) {
this.store = store;
this.retentionTime = store.getMvStore().getRetentionTime();
}
/**
......@@ -532,8 +532,8 @@ public class Database implements DataHandler {
try {
powerOffCount = -1;
stopWriter();
if (mvStore != null) {
mvStore.closeImmediately();
if (store != null) {
store.closeImmediately();
}
if (pageStore != null) {
try {
......@@ -737,7 +737,7 @@ public class Database implements DataHandler {
getPageStore();
}
starting = false;
if (mvStore == null) {
if (store == null) {
writer = WriterThread.create(this, writeDelay);
} else {
setWriteDelay(writeDelay);
......@@ -753,8 +753,8 @@ public class Database implements DataHandler {
getPageStore();
}
}
if(mvStore != null) {
mvStore.getTransactionStore().init();
if(store != null) {
store.getTransactionStore().init();
}
systemUser = new User(this, 0, SYSTEM_USER_NAME, true);
mainSchema = new Schema(this, 0, Constants.SCHEMA_MAIN, systemUser, true);
......@@ -809,9 +809,9 @@ public class Database implements DataHandler {
}
}
systemSession.commit(true);
if (mvStore != null) {
mvStore.getTransactionStore().endLeftoverTransactions();
mvStore.removeTemporaryMaps(objectIds);
if (store != null) {
store.getTransactionStore().endLeftoverTransactions();
store.removeTemporaryMaps(objectIds);
}
recompileInvalidViews(systemSession);
starting = false;
......@@ -1438,7 +1438,7 @@ public class Database implements DataHandler {
}
boolean lobStorageIsUsed = infoSchema.findTableOrView(
systemSession, LobStorageBackend.LOB_DATA_TABLE) != null;
lobStorageIsUsed |= mvStore != null;
lobStorageIsUsed |= store != null;
if (!lobStorageIsUsed) {
return;
}
......@@ -1494,16 +1494,16 @@ public class Database implements DataHandler {
}
}
reconnectModified(false);
if (mvStore != null && mvStore.getStore() != null && !mvStore.getStore().isClosed()) {
if (store != null && store.getMvStore() != null && !store.getMvStore().isClosed()) {
long maxCompactTime = dbSettings.maxCompactTime;
if (compactMode == CommandInterface.SHUTDOWN_COMPACT) {
mvStore.compactFile(dbSettings.maxCompactTime);
store.compactFile(dbSettings.maxCompactTime);
} else if (compactMode == CommandInterface.SHUTDOWN_DEFRAG) {
maxCompactTime = Long.MAX_VALUE;
} else if (getSettings().defragAlways) {
maxCompactTime = Long.MAX_VALUE;
}
mvStore.close(maxCompactTime);
store.close(maxCompactTime);
}
if (systemSession != null) {
systemSession.close();
......@@ -1547,8 +1547,8 @@ public class Database implements DataHandler {
private synchronized void closeFiles() {
try {
if (mvStore != null) {
mvStore.closeImmediately();
if (store != null) {
store.closeImmediately();
}
if (pageStore != null) {
pageStore.close();
......@@ -2028,8 +2028,8 @@ public class Database implements DataHandler {
if (pageStore != null) {
pageStore.getCache().setMaxMemory(kb);
}
if (mvStore != null) {
mvStore.setCacheSize(Math.max(1, kb));
if (store != null) {
store.setCacheSize(Math.max(1, kb));
}
}
......@@ -2090,9 +2090,9 @@ public class Database implements DataHandler {
// TODO check if MIN_WRITE_DELAY is a good value
flushOnEachCommit = writeDelay < Constants.MIN_WRITE_DELAY;
}
if (mvStore != null) {
if (store != null) {
int millis = value < 0 ? 0 : value;
mvStore.getStore().setAutoCommitDelay(millis);
store.getMvStore().setAutoCommitDelay(millis);
}
}
......@@ -2102,8 +2102,8 @@ public class Database implements DataHandler {
public void setRetentionTime(int value) {
retentionTime = value;
if (mvStore != null) {
mvStore.getStore().setRetentionTime(value);
if (store != null) {
store.getMvStore().setRetentionTime(value);
}
}
......@@ -2130,8 +2130,8 @@ public class Database implements DataHandler {
* @return the list
*/
public ArrayList<InDoubtTransaction> getInDoubtTransactions() {
if (mvStore != null) {
return mvStore.getInDoubtTransactions();
if (store != null) {
return store.getInDoubtTransactions();
}
return pageStore == null ? null : pageStore.getInDoubtTransactions();
}
......@@ -2146,8 +2146,8 @@ public class Database implements DataHandler {
if (readOnly) {
return;
}
if (mvStore != null) {
mvStore.prepareCommit(session, transaction);
if (store != null) {
store.prepareCommit(session, transaction);
return;
}
if (pageStore != null) {
......@@ -2190,7 +2190,7 @@ public class Database implements DataHandler {
}
public Throwable getBackgroundException() {
IllegalStateException exception = mvStore.getStore().getPanicException();
IllegalStateException exception = store.getMvStore().getPanicException();
if(exception != null) {
return exception;
}
......@@ -2208,9 +2208,9 @@ public class Database implements DataHandler {
if (pageStore != null) {
pageStore.flushLog();
}
if (mvStore != null) {
if (store != null) {
try {
mvStore.flush();
store.flush();
} catch (RuntimeException e) {
backgroundException.compareAndSet(null, DbException.convert(e));
throw e;
......@@ -2286,8 +2286,8 @@ public class Database implements DataHandler {
if (readOnly) {
return;
}
if (mvStore != null) {
mvStore.sync();
if (store != null) {
store.sync();
}
if (pageStore != null) {
pageStore.sync();
......@@ -2614,8 +2614,8 @@ public class Database implements DataHandler {
public PageStore getPageStore() {
if (dbSettings.mvStore) {
if (mvStore == null) {
mvStore = MVTableEngine.init(this);
if (store == null) {
store = MVTableEngine.init(this);
}
return null;
}
......@@ -2770,8 +2770,8 @@ public class Database implements DataHandler {
pageStore.checkpoint();
}
}
if (mvStore != null) {
mvStore.flush();
if (store != null) {
store.flush();
}
}
getTempFileDeleter().deleteUnused();
......@@ -2890,7 +2890,7 @@ public class Database implements DataHandler {
this.logMode = log;
pageStore.setLogMode(log);
}
if (mvStore != null) {
if (store != null) {
this.logMode = log;
}
}
......@@ -2899,7 +2899,7 @@ public class Database implements DataHandler {
if (pageStore != null) {
return pageStore.getLogMode();
}
if (mvStore != null) {
if (store != null) {
return logMode;
}
return PageStore.LOG_MODE_OFF;
......
......@@ -735,7 +735,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
private void endTransaction() {
if (removeLobMap != null && removeLobMap.size() > 0) {
if (database.getMvStore() == null) {
if (database.getStore() == null) {
// need to flush the transaction log, because we can't unlink
// lobs if the commit record is not written
database.flush();
......@@ -826,7 +826,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
if (undoLog != null) {
sp.logIndex = undoLog.size();
}
if (database.getMvStore() != null) {
if (database.getStore() != null) {
sp.transactionSavepoint = getStatementSavepoint();
}
return sp;
......@@ -1072,7 +1072,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
* @return true if yes
*/
public boolean containsUncommitted() {
if (database.getMvStore() != null) {
if (database.getStore() != null) {
return transaction != null && transaction.hasChanges();
}
return firstUncommittedLog != Session.LOG_WRITTEN;
......@@ -1608,7 +1608,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
}
public Value getTransactionId() {
if (database.getMvStore() != null) {
if (database.getStore() != null) {
if (transaction == null || !transaction.hasChanges()) {
return ValueNull.INSTANCE;
}
......@@ -1644,9 +1644,9 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
*/
public Transaction getTransaction() {
if (transaction == null) {
MVTableEngine.Store store = database.getMvStore();
MVTableEngine.Store store = database.getStore();
if (store != null) {
if (store.getStore().isClosed()) {
if (store.getMvStore().isClosed()) {
Throwable backgroundException = database.getBackgroundException();
database.shutdownImmediately();
throw DbException.get(ErrorCode.DATABASE_IS_CLOSED, backgroundException);
......@@ -1749,7 +1749,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
VersionedValue restoredValue) {
// Here we are relying on the fact that map which backs table's primary index
// has the same name as the table itself
MVTableEngine.Store store = database.getMvStore();
MVTableEngine.Store store = database.getStore();
if(store != null) {
MVTable table = store.getTable(map.getName());
if (table != null) {
......
......@@ -102,7 +102,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
"Persistent index with id<0");
}
MVTableEngine.init(session.getDatabase());
store = session.getDatabase().getMvStore().getStore();
store = session.getDatabase().getStore().getMvStore();
// Called after CREATE SPATIAL INDEX or
// by PageStore.addMeta
treeMap = store.openMap(MAP_PREFIX + getId(),
......
......@@ -163,7 +163,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if (p != null) {
return p.getWriteCount();
}
return database.getMvStore().getStore().getFileStore().getReadCount();
return database.getStore().getMvStore().getFileStore().getReadCount();
}
@Override
......@@ -175,7 +175,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if (p != null) {
return p.getReadCount();
}
return database.getMvStore().getStore().getFileStore().getReadCount();
return database.getStore().getMvStore().getFileStore().getReadCount();
}
@Override
......@@ -187,7 +187,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if (p != null) {
return p.getPageCount() * p.getPageSize() / 1024;
}
return database.getMvStore().getStore().getFileStore().size();
return database.getStore().getMvStore().getFileStore().size();
}
@Override
......@@ -199,7 +199,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if (p != null) {
return p.getCache().getMaxMemory();
}
return database.getMvStore().getStore().getCacheSize() * 1024;
return database.getStore().getMvStore().getCacheSize() * 1024;
}
@Override
......@@ -218,7 +218,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if (p != null) {
return p.getCache().getMemory();
}
return database.getMvStore().getStore().getCacheSizeUsed() * 1024;
return database.getStore().getMvStore().getCacheSizeUsed() * 1024;
}
@Override
......
......@@ -148,9 +148,9 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
}
}
} finally {
MVStore store = database.getMvStore().getStore();
MVStore mvStore = database.getStore().getMvStore();
for (String tempMapName : bufferNames) {
store.removeMap(tempMapName);
mvStore.removeMap(tempMapName);
}
}
}
......@@ -167,8 +167,8 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
new MVMap.Builder<ValueArray, Value>()
.singleWriter()
.keyType(keyType).valueType(valueType);
MVMap<ValueArray, Value> map = database.getMvStore().
getStore().openMap(mapName, builder);
MVMap<ValueArray, Value> map = database.getStore().
getMvStore().openMap(mapName, builder);
if (!keyType.equals(map.getKeyType())) {
throw DbException.throwInternalError(
"Incompatible key type, expected " + keyType + " but got "
......
......@@ -98,7 +98,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
MVRTreeMap.Builder<VersionedValue> mapBuilder =
new MVRTreeMap.Builder<VersionedValue>().
valueType(valueType);
spatialMap = db.getMvStore().getStore().openMap(mapName, mapBuilder);
spatialMap = db.getStore().getMvStore().openMap(mapName, mapBuilder);
Transaction t = mvTable.getTransactionBegin();
dataMap = t.openMap(spatialMap);
dataMap.map.setVolatile(!table.isPersistData() || !indexType.isPersistent());
......
......@@ -538,7 +538,7 @@ public class MVTable extends TableBase {
private void rebuildIndex(Session session, MVIndex index, String indexName) {
try {
if (session.getDatabase().getMvStore() == null ||
if (session.getDatabase().getStore() == null ||
index instanceof MVSpatialIndex) {
// in-memory
rebuildIndexBuffered(session, index);
......@@ -577,7 +577,7 @@ public class MVTable extends TableBase {
long total = remaining;
Cursor cursor = scan.find(session, null, null);
long i = 0;
Store store = session.getDatabase().getMvStore();
Store store = session.getDatabase().getStore();
int bufferSize = database.getMaxMemoryRows() / 2;
ArrayList<Row> buffer = new ArrayList<>(bufferSize);
......@@ -807,7 +807,7 @@ public class MVTable extends TableBase {
database.getLobStorage().removeAllForTable(getId());
database.lockMeta(session);
}
database.getMvStore().removeTable(this);
database.getStore().removeTable(this);
super.removeChildrenAndResources(session);
// go backwards because database.removeIndex will
// call table.removeIndex
......
......@@ -47,7 +47,7 @@ public class MVTableEngine implements TableEngine {
* @return the store
*/
public static Store init(final Database db) {
Store store = db.getMvStore();
Store store = db.getStore();
if (store != null) {
return store;
}
......@@ -92,7 +92,7 @@ public class MVTableEngine implements TableEngine {
});
}
store.open(db, builder, encrypted);
db.setMvStore(store);
db.setStore(store);
return store;
}
......@@ -127,7 +127,7 @@ public class MVTableEngine implements TableEngine {
/**
* The store.
*/
private MVStore store;
private MVStore mvStore;
/**
* The transaction store.
......@@ -152,15 +152,15 @@ public class MVTableEngine implements TableEngine {
void open(Database db, MVStore.Builder builder, boolean encrypted) {
this.encrypted = encrypted;
try {
this.store = builder.open();
FileStore fs = store.getFileStore();
this.mvStore = builder.open();
FileStore fs = mvStore.getFileStore();
if (fs != null) {
this.fileName = fs.getFileName();
}
if (!db.getSettings().reuseSpace) {
store.setReuseSpace(false);
mvStore.setReuseSpace(false);
}
this.transactionStore = new TransactionStore(store,
this.transactionStore = new TransactionStore(mvStore,
new ValueDataType(db, null), db.getLockTimeout());
} catch (IllegalStateException e) {
throw convertIllegalStateException(e);
......@@ -201,8 +201,8 @@ public class MVTableEngine implements TableEngine {
}
public MVStore getStore() {
return store;
public MVStore getMvStore() {
return mvStore;
}
public TransactionStore getTransactionStore() {
......@@ -238,12 +238,12 @@ public class MVTableEngine implements TableEngine {
* Store all pending changes.
*/
public void flush() {
FileStore s = store.getFileStore();
FileStore s = mvStore.getFileStore();
if (s == null || s.isReadOnly()) {
return;
}
if (!store.compact(50, 4 * 1024 * 1024)) {
store.commit();
if (!mvStore.compact(50, 4 * 1024 * 1024)) {
mvStore.commit();
}
}
......@@ -251,10 +251,10 @@ public class MVTableEngine implements TableEngine {
* Close the store, without persisting changes.
*/
public void closeImmediately() {
if (store.isClosed()) {
if (mvStore.isClosed()) {
return;
}
store.closeImmediately();
mvStore.closeImmediately();
}
/**
......@@ -263,13 +263,13 @@ public class MVTableEngine implements TableEngine {
* @param objectIds the ids of the objects to keep
*/
public void removeTemporaryMaps(BitSet objectIds) {
for (String mapName : store.getMapNames()) {
for (String mapName : mvStore.getMapNames()) {
if (mapName.startsWith("temp.")) {
store.removeMap(mapName);
mvStore.removeMap(mapName);
} else if (mapName.startsWith("table.") || mapName.startsWith("index.")) {
int id = Integer.parseInt(mapName.substring(1 + mapName.indexOf('.')));
if (!objectIds.get(id)) {
store.removeMap(mapName);
mvStore.removeMap(mapName);
}
}
}
......@@ -294,7 +294,7 @@ public class MVTableEngine implements TableEngine {
Transaction t = session.getTransaction();
t.setName(transactionName);
t.prepare();
store.commit();
mvStore.commit();
}
public ArrayList<InDoubtTransaction> getInDoubtTransactions() {
......@@ -302,7 +302,7 @@ public class MVTableEngine implements TableEngine {
ArrayList<InDoubtTransaction> result = Utils.newSmallArrayList();
for (Transaction t : list) {
if (t.getStatus() == Transaction.STATUS_PREPARED) {
result.add(new MVInDoubtTransaction(store, t));
result.add(new MVInDoubtTransaction(mvStore, t));
}
}
return result;
......@@ -314,13 +314,13 @@ public class MVTableEngine implements TableEngine {
* @param kb the maximum size in KB
*/
public void setCacheSize(int kb) {
store.setCacheSize(Math.max(1, kb / 1024));
mvStore.setCacheSize(Math.max(1, kb / 1024));
}
public InputStream getInputStream() {
FileChannel fc = store.getFileStore().getEncryptedFile();
FileChannel fc = mvStore.getFileStore().getEncryptedFile();
if (fc == null) {
fc = store.getFileStore().getFile();
fc = mvStore.getFileStore().getFile();
}
return new FileChannelInputStream(fc, false);
}
......@@ -330,7 +330,7 @@ public class MVTableEngine implements TableEngine {
*/
public void sync() {
flush();
store.sync();
mvStore.sync();
}
/**
......@@ -342,11 +342,11 @@ public class MVTableEngine implements TableEngine {
* @param maxCompactTime the maximum time in milliseconds to compact
*/
public void compactFile(long maxCompactTime) {
store.setRetentionTime(0);
mvStore.setRetentionTime(0);
long start = System.nanoTime();
while (store.compact(95, 16 * 1024 * 1024)) {
store.sync();
store.compactMoveChunks(95, 16 * 1024 * 1024);
while (mvStore.compact(95, 16 * 1024 * 1024)) {
mvStore.sync();
mvStore.compactMoveChunks(95, 16 * 1024 * 1024);
long time = System.nanoTime() - start;
if (time > TimeUnit.MILLISECONDS.toNanos(maxCompactTime)) {
break;
......@@ -363,16 +363,16 @@ public class MVTableEngine implements TableEngine {
*/
public void close(long maxCompactTime) {
try {
if (!store.isClosed() && store.getFileStore() != null) {
if (!mvStore.isClosed() && mvStore.getFileStore() != null) {
boolean compactFully = false;
if (!store.getFileStore().isReadOnly()) {
if (!mvStore.getFileStore().isReadOnly()) {
transactionStore.close();
if (maxCompactTime == Long.MAX_VALUE) {
compactFully = true;
}
}
String fileName = store.getFileStore().getFileName();
store.close();
String fileName = mvStore.getFileStore().getFileName();
mvStore.close();
if (compactFully && FileUtils.exists(fileName)) {
// the file could have been deleted concurrently,
// so only compact if the file still exists
......@@ -386,7 +386,7 @@ public class MVTableEngine implements TableEngine {
} else if (errorCode == DataUtils.ERROR_FILE_CORRUPT) {
// wrong encryption key - ok
}
store.closeImmediately();
mvStore.closeImmediately();
throw DbException.get(ErrorCode.IO_EXCEPTION_1, e, "Closing");
}
}
......@@ -395,7 +395,7 @@ public class MVTableEngine implements TableEngine {
* Start collecting statistics.
*/
public void statisticsStart() {
FileStore fs = store.getFileStore();
FileStore fs = mvStore.getFileStore();
statisticsStart = fs == null ? 0 : fs.getReadCount();
}
......@@ -406,7 +406,7 @@ public class MVTableEngine implements TableEngine {
*/
public Map<String, Integer> statisticsEnd() {
HashMap<String, Integer> map = new HashMap<>();
FileStore fs = store.getFileStore();
FileStore fs = mvStore.getFileStore();
int reads = fs == null ? 0 : (int) (fs.getReadCount() - statisticsStart);
map.put("reads", reads);
return map;
......
......@@ -72,13 +72,13 @@ public class LobStorageMap implements LobStorageInterface {
return;
}
init = true;
Store s = database.getMvStore();
Store s = database.getStore();
MVStore mvStore;
if (s == null) {
// in-memory database
mvStore = MVStore.open(null);
} else {
mvStore = s.getStore();
mvStore = s.getMvStore();
}
lobMap = mvStore.openMap("lobMap");
refMap = mvStore.openMap("lobRef");
......@@ -289,7 +289,7 @@ public class LobStorageMap implements LobStorageInterface {
@Override
public void removeAllForTable(int tableId) {
init();
if (database.getMvStore().getStore().isClosed()) {
if (database.getStore().getMvStore().isClosed()) {
return;
}
// this might not be very efficient -
......
......@@ -45,6 +45,7 @@ import org.h2.index.MetaIndex;
import org.h2.jdbc.JdbcSQLException;
import org.h2.message.DbException;
import org.h2.mvstore.FileStore;
import org.h2.mvstore.MVStore;
import org.h2.mvstore.db.MVTableEngine.Store;
import org.h2.result.Row;
import org.h2.result.SearchRow;
......@@ -1051,32 +1052,33 @@ public class MetaTable extends Table {
add(rows, k, s.get(k));
}
if (database.isPersistent()) {
PageStore store = database.getPageStore();
if (store != null) {
PageStore pageStore = database.getPageStore();
if (pageStore != null) {
add(rows, "info.FILE_WRITE_TOTAL",
Long.toString(store.getWriteCountTotal()));
Long.toString(pageStore.getWriteCountTotal()));
add(rows, "info.FILE_WRITE",
Long.toString(store.getWriteCount()));
Long.toString(pageStore.getWriteCount()));
add(rows, "info.FILE_READ",
Long.toString(store.getReadCount()));
Long.toString(pageStore.getReadCount()));
add(rows, "info.PAGE_COUNT",
Integer.toString(store.getPageCount()));
Integer.toString(pageStore.getPageCount()));
add(rows, "info.PAGE_SIZE",
Integer.toString(store.getPageSize()));
Integer.toString(pageStore.getPageSize()));
add(rows, "info.CACHE_MAX_SIZE",
Integer.toString(store.getCache().getMaxMemory()));
Integer.toString(pageStore.getCache().getMaxMemory()));
add(rows, "info.CACHE_SIZE",
Integer.toString(store.getCache().getMemory()));
Integer.toString(pageStore.getCache().getMemory()));
}
Store mvStore = database.getMvStore();
if (mvStore != null) {
FileStore fs = mvStore.getStore().getFileStore();
Store store = database.getStore();
if (store != null) {
MVStore mvStore = store.getMvStore();
FileStore fs = mvStore.getFileStore();
add(rows, "info.FILE_WRITE",
Long.toString(fs.getWriteCount()));
add(rows, "info.FILE_READ",
Long.toString(fs.getReadCount()));
add(rows, "info.UPDATE_FAILURE_PERCENT",
String.format(Locale.ENGLISH, "%.2f%%", 100 * mvStore.getStore().getUpdateFailureRatio()));
String.format(Locale.ENGLISH, "%.2f%%", 100 * mvStore.getUpdateFailureRatio()));
long size;
try {
size = fs.getFile().size();
......@@ -1090,9 +1092,9 @@ public class MetaTable extends Table {
add(rows, "info.PAGE_SIZE",
Integer.toString(pageSize));
add(rows, "info.CACHE_MAX_SIZE",
Integer.toString(mvStore.getStore().getCacheSize()));
Integer.toString(mvStore.getCacheSize()));
add(rows, "info.CACHE_SIZE",
Integer.toString(mvStore.getStore().getCacheSizeUsed()));
Integer.toString(mvStore.getCacheSizeUsed()));
}
}
break;
......
......@@ -1130,7 +1130,7 @@ public class TestMVTableEngine extends TestDb {
conn = getConnection(dbName);
Database db = (Database) ((JdbcConnection) conn).getSession()
.getDataHandler();
assertTrue(db.getMvStore().getStore().getFileStore().isReadOnly());
assertTrue(db.getStore().getMvStore().getFileStore().isReadOnly());
conn.close();
}
......@@ -1144,7 +1144,7 @@ public class TestMVTableEngine extends TestDb {
conn = getConnection(dbName);
Database db = (Database) ((JdbcConnection) conn).
getSession().getDataHandler();
db.getMvStore().getStore().setRetentionTime(0);
db.getStore().getMvStore().setRetentionTime(0);
stat = conn.createStatement();
stat.execute("create table test(id int primary key, data varchar)");
stat.execute("insert into test select x, space(1000) " +
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论