Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0fe83909
提交
0fe83909
authored
6 年前
作者:
Andrei Tokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename fields to reflect actual type
Database.mvStore - > store MVTableEngine.Store.store - > mvStore
上级
849484e9
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
128 行增加
和
126 行删除
+128
-126
Command.java
h2/src/main/org/h2/command/Command.java
+3
-3
BackupCommand.java
h2/src/main/org/h2/command/dml/BackupCommand.java
+6
-6
Explain.java
h2/src/main/org/h2/command/dml/Explain.java
+1
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+41
-41
Session.java
h2/src/main/org/h2/engine/Session.java
+7
-7
SpatialTreeIndex.java
h2/src/main/org/h2/index/SpatialTreeIndex.java
+1
-1
DatabaseInfo.java
h2/src/main/org/h2/jmx/DatabaseInfo.java
+5
-5
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+4
-4
MVSpatialIndex.java
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
+1
-1
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+3
-3
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+34
-34
LobStorageMap.java
h2/src/main/org/h2/store/LobStorageMap.java
+3
-3
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+17
-15
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+2
-2
没有找到文件。
h2/src/main/org/h2/command/Command.java
浏览文件 @
0fe83909
...
...
@@ -181,7 +181,7 @@ public abstract class Command implements CommandInterface {
startTimeNanos
=
0
;
long
start
=
0
;
Database
database
=
session
.
getDatabase
();
Object
sync
=
database
.
isMultiThreaded
()
||
database
.
get
Mv
Store
()
!=
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
.
get
Mv
Store
()
!=
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
.
get
Mv
Store
()
==
null
)
{
if
(
database
.
getStore
()
==
null
)
{
int
sleep
=
1
+
MathUtils
.
randomInt
(
10
);
while
(
true
)
{
try
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/BackupCommand.java
浏览文件 @
0fe83909
...
...
@@ -58,9 +58,9 @@ public class BackupCommand extends Prepared {
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_NOT_PERSISTENT
);
}
try
{
Store
mvStore
=
db
.
getMv
Store
();
if
(
mvS
tore
!=
null
)
{
mvS
tore
.
flush
();
Store
store
=
db
.
get
Store
();
if
(
s
tore
!=
null
)
{
s
tore
.
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
)
&&
mvS
tore
!=
null
)
{
MVStore
s
=
mvStore
.
get
Store
();
if
(
n
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
)
&&
s
tore
!=
null
)
{
MVStore
s
=
store
.
getMv
Store
();
boolean
before
=
s
.
getReuseSpace
();
s
.
setReuseSpace
(
false
);
try
{
InputStream
in
=
mvS
tore
.
getInputStream
();
InputStream
in
=
s
tore
.
getInputStream
();
backupFile
(
out
,
base
,
n
,
in
);
}
finally
{
s
.
setReuseSpace
(
before
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Explain.java
浏览文件 @
0fe83909
...
...
@@ -83,7 +83,7 @@ public class Explain extends Prepared {
if
(
store
!=
null
)
{
store
.
statisticsStart
();
}
mvStore
=
db
.
get
Mv
Store
();
mvStore
=
db
.
getStore
();
if
(
mvStore
!=
null
)
{
mvStore
.
statisticsStart
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
0fe83909
...
...
@@ -218,7 +218,7 @@ public class Database implements DataHandler {
private
final
DbSettings
dbSettings
;
private
final
long
reconnectCheckDelayNs
;
private
int
logMode
;
private
MVTableEngine
.
Store
mvS
tore
;
private
MVTableEngine
.
Store
s
tore
;
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
get
Mv
Store
()
{
return
mvS
tore
;
public
MVTableEngine
.
Store
getStore
()
{
return
s
tore
;
}
public
void
set
MvStore
(
MVTableEngine
.
Store
mvS
tore
)
{
this
.
mvStore
=
mvS
tore
;
this
.
retentionTime
=
mvStore
.
get
Store
().
getRetentionTime
();
public
void
set
Store
(
MVTableEngine
.
Store
s
tore
)
{
this
.
store
=
s
tore
;
this
.
retentionTime
=
store
.
getMv
Store
().
getRetentionTime
();
}
/**
...
...
@@ -532,8 +532,8 @@ public class Database implements DataHandler {
try
{
powerOffCount
=
-
1
;
stopWriter
();
if
(
mvS
tore
!=
null
)
{
mvS
tore
.
closeImmediately
();
if
(
s
tore
!=
null
)
{
s
tore
.
closeImmediately
();
}
if
(
pageStore
!=
null
)
{
try
{
...
...
@@ -737,7 +737,7 @@ public class Database implements DataHandler {
getPageStore
();
}
starting
=
false
;
if
(
mvS
tore
==
null
)
{
if
(
s
tore
==
null
)
{
writer
=
WriterThread
.
create
(
this
,
writeDelay
);
}
else
{
setWriteDelay
(
writeDelay
);
...
...
@@ -753,8 +753,8 @@ public class Database implements DataHandler {
getPageStore
();
}
}
if
(
mvS
tore
!=
null
)
{
mvS
tore
.
getTransactionStore
().
init
();
if
(
s
tore
!=
null
)
{
s
tore
.
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
(
mvS
tore
!=
null
)
{
mvS
tore
.
getTransactionStore
().
endLeftoverTransactions
();
mvS
tore
.
removeTemporaryMaps
(
objectIds
);
if
(
s
tore
!=
null
)
{
s
tore
.
getTransactionStore
().
endLeftoverTransactions
();
s
tore
.
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
|=
mvS
tore
!=
null
;
lobStorageIsUsed
|=
s
tore
!=
null
;
if
(!
lobStorageIsUsed
)
{
return
;
}
...
...
@@ -1494,16 +1494,16 @@ public class Database implements DataHandler {
}
}
reconnectModified
(
false
);
if
(
mvStore
!=
null
&&
mvStore
.
getStore
()
!=
null
&&
!
mvStore
.
get
Store
().
isClosed
())
{
if
(
store
!=
null
&&
store
.
getMvStore
()
!=
null
&&
!
store
.
getMv
Store
().
isClosed
())
{
long
maxCompactTime
=
dbSettings
.
maxCompactTime
;
if
(
compactMode
==
CommandInterface
.
SHUTDOWN_COMPACT
)
{
mvS
tore
.
compactFile
(
dbSettings
.
maxCompactTime
);
s
tore
.
compactFile
(
dbSettings
.
maxCompactTime
);
}
else
if
(
compactMode
==
CommandInterface
.
SHUTDOWN_DEFRAG
)
{
maxCompactTime
=
Long
.
MAX_VALUE
;
}
else
if
(
getSettings
().
defragAlways
)
{
maxCompactTime
=
Long
.
MAX_VALUE
;
}
mvS
tore
.
close
(
maxCompactTime
);
s
tore
.
close
(
maxCompactTime
);
}
if
(
systemSession
!=
null
)
{
systemSession
.
close
();
...
...
@@ -1547,8 +1547,8 @@ public class Database implements DataHandler {
private
synchronized
void
closeFiles
()
{
try
{
if
(
mvS
tore
!=
null
)
{
mvS
tore
.
closeImmediately
();
if
(
s
tore
!=
null
)
{
s
tore
.
closeImmediately
();
}
if
(
pageStore
!=
null
)
{
pageStore
.
close
();
...
...
@@ -2028,8 +2028,8 @@ public class Database implements DataHandler {
if
(
pageStore
!=
null
)
{
pageStore
.
getCache
().
setMaxMemory
(
kb
);
}
if
(
mvS
tore
!=
null
)
{
mvS
tore
.
setCacheSize
(
Math
.
max
(
1
,
kb
));
if
(
s
tore
!=
null
)
{
s
tore
.
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
(
mvS
tore
!=
null
)
{
if
(
s
tore
!=
null
)
{
int
millis
=
value
<
0
?
0
:
value
;
mvStore
.
get
Store
().
setAutoCommitDelay
(
millis
);
store
.
getMv
Store
().
setAutoCommitDelay
(
millis
);
}
}
...
...
@@ -2102,8 +2102,8 @@ public class Database implements DataHandler {
public
void
setRetentionTime
(
int
value
)
{
retentionTime
=
value
;
if
(
mvS
tore
!=
null
)
{
mvStore
.
get
Store
().
setRetentionTime
(
value
);
if
(
s
tore
!=
null
)
{
store
.
getMv
Store
().
setRetentionTime
(
value
);
}
}
...
...
@@ -2130,8 +2130,8 @@ public class Database implements DataHandler {
* @return the list
*/
public
ArrayList
<
InDoubtTransaction
>
getInDoubtTransactions
()
{
if
(
mvS
tore
!=
null
)
{
return
mvS
tore
.
getInDoubtTransactions
();
if
(
s
tore
!=
null
)
{
return
s
tore
.
getInDoubtTransactions
();
}
return
pageStore
==
null
?
null
:
pageStore
.
getInDoubtTransactions
();
}
...
...
@@ -2146,8 +2146,8 @@ public class Database implements DataHandler {
if
(
readOnly
)
{
return
;
}
if
(
mvS
tore
!=
null
)
{
mvS
tore
.
prepareCommit
(
session
,
transaction
);
if
(
s
tore
!=
null
)
{
s
tore
.
prepareCommit
(
session
,
transaction
);
return
;
}
if
(
pageStore
!=
null
)
{
...
...
@@ -2190,7 +2190,7 @@ public class Database implements DataHandler {
}
public
Throwable
getBackgroundException
()
{
IllegalStateException
exception
=
mvStore
.
get
Store
().
getPanicException
();
IllegalStateException
exception
=
store
.
getMv
Store
().
getPanicException
();
if
(
exception
!=
null
)
{
return
exception
;
}
...
...
@@ -2208,9 +2208,9 @@ public class Database implements DataHandler {
if
(
pageStore
!=
null
)
{
pageStore
.
flushLog
();
}
if
(
mvS
tore
!=
null
)
{
if
(
s
tore
!=
null
)
{
try
{
mvS
tore
.
flush
();
s
tore
.
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
(
mvS
tore
!=
null
)
{
mvS
tore
.
sync
();
if
(
s
tore
!=
null
)
{
s
tore
.
sync
();
}
if
(
pageStore
!=
null
)
{
pageStore
.
sync
();
...
...
@@ -2614,8 +2614,8 @@ public class Database implements DataHandler {
public
PageStore
getPageStore
()
{
if
(
dbSettings
.
mvStore
)
{
if
(
mvS
tore
==
null
)
{
mvS
tore
=
MVTableEngine
.
init
(
this
);
if
(
s
tore
==
null
)
{
s
tore
=
MVTableEngine
.
init
(
this
);
}
return
null
;
}
...
...
@@ -2770,8 +2770,8 @@ public class Database implements DataHandler {
pageStore
.
checkpoint
();
}
}
if
(
mvS
tore
!=
null
)
{
mvS
tore
.
flush
();
if
(
s
tore
!=
null
)
{
s
tore
.
flush
();
}
}
getTempFileDeleter
().
deleteUnused
();
...
...
@@ -2890,7 +2890,7 @@ public class Database implements DataHandler {
this
.
logMode
=
log
;
pageStore
.
setLogMode
(
log
);
}
if
(
mvS
tore
!=
null
)
{
if
(
s
tore
!=
null
)
{
this
.
logMode
=
log
;
}
}
...
...
@@ -2899,7 +2899,7 @@ public class Database implements DataHandler {
if
(
pageStore
!=
null
)
{
return
pageStore
.
getLogMode
();
}
if
(
mvS
tore
!=
null
)
{
if
(
s
tore
!=
null
)
{
return
logMode
;
}
return
PageStore
.
LOG_MODE_OFF
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
0fe83909
...
...
@@ -735,7 +735,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
private
void
endTransaction
()
{
if
(
removeLobMap
!=
null
&&
removeLobMap
.
size
()
>
0
)
{
if
(
database
.
get
Mv
Store
()
==
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
.
get
Mv
Store
()
!=
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
.
get
Mv
Store
()
!=
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
.
get
Mv
Store
()
!=
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
.
get
Mv
Store
();
MVTableEngine
.
Store
store
=
database
.
getStore
();
if
(
store
!=
null
)
{
if
(
store
.
getStore
().
isClosed
())
{
if
(
store
.
get
Mv
Store
().
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
.
get
Mv
Store
();
MVTableEngine
.
Store
store
=
database
.
getStore
();
if
(
store
!=
null
)
{
MVTable
table
=
store
.
getTable
(
map
.
getName
());
if
(
table
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/SpatialTreeIndex.java
浏览文件 @
0fe83909
...
...
@@ -102,7 +102,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
"Persistent index with id<0"
);
}
MVTableEngine
.
init
(
session
.
getDatabase
());
store
=
session
.
getDatabase
().
get
MvStore
().
get
Store
();
store
=
session
.
getDatabase
().
get
Store
().
getMv
Store
();
// Called after CREATE SPATIAL INDEX or
// by PageStore.addMeta
treeMap
=
store
.
openMap
(
MAP_PREFIX
+
getId
(),
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jmx/DatabaseInfo.java
浏览文件 @
0fe83909
...
...
@@ -163,7 +163,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if
(
p
!=
null
)
{
return
p
.
getWriteCount
();
}
return
database
.
get
MvStore
().
get
Store
().
getFileStore
().
getReadCount
();
return
database
.
get
Store
().
getMv
Store
().
getFileStore
().
getReadCount
();
}
@Override
...
...
@@ -175,7 +175,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if
(
p
!=
null
)
{
return
p
.
getReadCount
();
}
return
database
.
get
MvStore
().
get
Store
().
getFileStore
().
getReadCount
();
return
database
.
get
Store
().
getMv
Store
().
getFileStore
().
getReadCount
();
}
@Override
...
...
@@ -187,7 +187,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if
(
p
!=
null
)
{
return
p
.
getPageCount
()
*
p
.
getPageSize
()
/
1024
;
}
return
database
.
get
MvStore
().
get
Store
().
getFileStore
().
size
();
return
database
.
get
Store
().
getMv
Store
().
getFileStore
().
size
();
}
@Override
...
...
@@ -199,7 +199,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if
(
p
!=
null
)
{
return
p
.
getCache
().
getMaxMemory
();
}
return
database
.
get
MvStore
().
get
Store
().
getCacheSize
()
*
1024
;
return
database
.
get
Store
().
getMv
Store
().
getCacheSize
()
*
1024
;
}
@Override
...
...
@@ -218,7 +218,7 @@ public class DatabaseInfo implements DatabaseInfoMBean {
if
(
p
!=
null
)
{
return
p
.
getCache
().
getMemory
();
}
return
database
.
get
MvStore
().
get
Store
().
getCacheSizeUsed
()
*
1024
;
return
database
.
get
Store
().
getMv
Store
().
getCacheSizeUsed
()
*
1024
;
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
0fe83909
...
...
@@ -148,9 +148,9 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
}
}
}
finally
{
MVStore
store
=
database
.
getMvStore
().
get
Store
();
MVStore
mvStore
=
database
.
getStore
().
getMv
Store
();
for
(
String
tempMapName
:
bufferNames
)
{
s
tore
.
removeMap
(
tempMapName
);
mvS
tore
.
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
.
get
Mv
Store
().
getStore
().
openMap
(
mapName
,
builder
);
MVMap
<
ValueArray
,
Value
>
map
=
database
.
getStore
().
get
Mv
Store
().
openMap
(
mapName
,
builder
);
if
(!
keyType
.
equals
(
map
.
getKeyType
()))
{
throw
DbException
.
throwInternalError
(
"Incompatible key type, expected "
+
keyType
+
" but got "
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
浏览文件 @
0fe83909
...
...
@@ -98,7 +98,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
MVRTreeMap
.
Builder
<
VersionedValue
>
mapBuilder
=
new
MVRTreeMap
.
Builder
<
VersionedValue
>().
valueType
(
valueType
);
spatialMap
=
db
.
get
MvStore
().
get
Store
().
openMap
(
mapName
,
mapBuilder
);
spatialMap
=
db
.
get
Store
().
getMv
Store
().
openMap
(
mapName
,
mapBuilder
);
Transaction
t
=
mvTable
.
getTransactionBegin
();
dataMap
=
t
.
openMap
(
spatialMap
);
dataMap
.
map
.
setVolatile
(!
table
.
isPersistData
()
||
!
indexType
.
isPersistent
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
0fe83909
...
...
@@ -538,7 +538,7 @@ public class MVTable extends TableBase {
private
void
rebuildIndex
(
Session
session
,
MVIndex
index
,
String
indexName
)
{
try
{
if
(
session
.
getDatabase
().
get
Mv
Store
()
==
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
().
get
Mv
Store
();
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
.
get
Mv
Store
().
removeTable
(
this
);
database
.
getStore
().
removeTable
(
this
);
super
.
removeChildrenAndResources
(
session
);
// go backwards because database.removeIndex will
// call table.removeIndex
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
0fe83909
...
...
@@ -47,7 +47,7 @@ public class MVTableEngine implements TableEngine {
* @return the store
*/
public
static
Store
init
(
final
Database
db
)
{
Store
store
=
db
.
get
Mv
Store
();
Store
store
=
db
.
getStore
();
if
(
store
!=
null
)
{
return
store
;
}
...
...
@@ -92,7 +92,7 @@ public class MVTableEngine implements TableEngine {
});
}
store
.
open
(
db
,
builder
,
encrypted
);
db
.
set
Mv
Store
(
store
);
db
.
setStore
(
store
);
return
store
;
}
...
...
@@ -127,7 +127,7 @@ public class MVTableEngine implements TableEngine {
/**
* The store.
*/
private
MVStore
s
tore
;
private
MVStore
mvS
tore
;
/**
* 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
.
s
tore
=
builder
.
open
();
FileStore
fs
=
s
tore
.
getFileStore
();
this
.
mvS
tore
=
builder
.
open
();
FileStore
fs
=
mvS
tore
.
getFileStore
();
if
(
fs
!=
null
)
{
this
.
fileName
=
fs
.
getFileName
();
}
if
(!
db
.
getSettings
().
reuseSpace
)
{
s
tore
.
setReuseSpace
(
false
);
mvS
tore
.
setReuseSpace
(
false
);
}
this
.
transactionStore
=
new
TransactionStore
(
s
tore
,
this
.
transactionStore
=
new
TransactionStore
(
mvS
tore
,
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
s
tore
;
public
MVStore
get
Mv
Store
()
{
return
mvS
tore
;
}
public
TransactionStore
getTransactionStore
()
{
...
...
@@ -238,12 +238,12 @@ public class MVTableEngine implements TableEngine {
* Store all pending changes.
*/
public
void
flush
()
{
FileStore
s
=
s
tore
.
getFileStore
();
FileStore
s
=
mvS
tore
.
getFileStore
();
if
(
s
==
null
||
s
.
isReadOnly
())
{
return
;
}
if
(!
s
tore
.
compact
(
50
,
4
*
1024
*
1024
))
{
s
tore
.
commit
();
if
(!
mvS
tore
.
compact
(
50
,
4
*
1024
*
1024
))
{
mvS
tore
.
commit
();
}
}
...
...
@@ -251,10 +251,10 @@ public class MVTableEngine implements TableEngine {
* Close the store, without persisting changes.
*/
public
void
closeImmediately
()
{
if
(
s
tore
.
isClosed
())
{
if
(
mvS
tore
.
isClosed
())
{
return
;
}
s
tore
.
closeImmediately
();
mvS
tore
.
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
:
s
tore
.
getMapNames
())
{
for
(
String
mapName
:
mvS
tore
.
getMapNames
())
{
if
(
mapName
.
startsWith
(
"temp."
))
{
s
tore
.
removeMap
(
mapName
);
mvS
tore
.
removeMap
(
mapName
);
}
else
if
(
mapName
.
startsWith
(
"table."
)
||
mapName
.
startsWith
(
"index."
))
{
int
id
=
Integer
.
parseInt
(
mapName
.
substring
(
1
+
mapName
.
indexOf
(
'.'
)));
if
(!
objectIds
.
get
(
id
))
{
s
tore
.
removeMap
(
mapName
);
mvS
tore
.
removeMap
(
mapName
);
}
}
}
...
...
@@ -294,7 +294,7 @@ public class MVTableEngine implements TableEngine {
Transaction
t
=
session
.
getTransaction
();
t
.
setName
(
transactionName
);
t
.
prepare
();
s
tore
.
commit
();
mvS
tore
.
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
(
s
tore
,
t
));
result
.
add
(
new
MVInDoubtTransaction
(
mvS
tore
,
t
));
}
}
return
result
;
...
...
@@ -314,13 +314,13 @@ public class MVTableEngine implements TableEngine {
* @param kb the maximum size in KB
*/
public
void
setCacheSize
(
int
kb
)
{
s
tore
.
setCacheSize
(
Math
.
max
(
1
,
kb
/
1024
));
mvS
tore
.
setCacheSize
(
Math
.
max
(
1
,
kb
/
1024
));
}
public
InputStream
getInputStream
()
{
FileChannel
fc
=
s
tore
.
getFileStore
().
getEncryptedFile
();
FileChannel
fc
=
mvS
tore
.
getFileStore
().
getEncryptedFile
();
if
(
fc
==
null
)
{
fc
=
s
tore
.
getFileStore
().
getFile
();
fc
=
mvS
tore
.
getFileStore
().
getFile
();
}
return
new
FileChannelInputStream
(
fc
,
false
);
}
...
...
@@ -330,7 +330,7 @@ public class MVTableEngine implements TableEngine {
*/
public
void
sync
()
{
flush
();
s
tore
.
sync
();
mvS
tore
.
sync
();
}
/**
...
...
@@ -342,11 +342,11 @@ public class MVTableEngine implements TableEngine {
* @param maxCompactTime the maximum time in milliseconds to compact
*/
public
void
compactFile
(
long
maxCompactTime
)
{
s
tore
.
setRetentionTime
(
0
);
mvS
tore
.
setRetentionTime
(
0
);
long
start
=
System
.
nanoTime
();
while
(
s
tore
.
compact
(
95
,
16
*
1024
*
1024
))
{
s
tore
.
sync
();
s
tore
.
compactMoveChunks
(
95
,
16
*
1024
*
1024
);
while
(
mvS
tore
.
compact
(
95
,
16
*
1024
*
1024
))
{
mvS
tore
.
sync
();
mvS
tore
.
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
()
&&
s
tore
.
getFileStore
()
!=
null
)
{
if
(!
mvStore
.
isClosed
()
&&
mvS
tore
.
getFileStore
()
!=
null
)
{
boolean
compactFully
=
false
;
if
(!
s
tore
.
getFileStore
().
isReadOnly
())
{
if
(!
mvS
tore
.
getFileStore
().
isReadOnly
())
{
transactionStore
.
close
();
if
(
maxCompactTime
==
Long
.
MAX_VALUE
)
{
compactFully
=
true
;
}
}
String
fileName
=
s
tore
.
getFileStore
().
getFileName
();
s
tore
.
close
();
String
fileName
=
mvS
tore
.
getFileStore
().
getFileName
();
mvS
tore
.
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
}
s
tore
.
closeImmediately
();
mvS
tore
.
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
=
s
tore
.
getFileStore
();
FileStore
fs
=
mvS
tore
.
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
=
s
tore
.
getFileStore
();
FileStore
fs
=
mvS
tore
.
getFileStore
();
int
reads
=
fs
==
null
?
0
:
(
int
)
(
fs
.
getReadCount
()
-
statisticsStart
);
map
.
put
(
"reads"
,
reads
);
return
map
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/LobStorageMap.java
浏览文件 @
0fe83909
...
...
@@ -72,13 +72,13 @@ public class LobStorageMap implements LobStorageInterface {
return
;
}
init
=
true
;
Store
s
=
database
.
get
Mv
Store
();
Store
s
=
database
.
getStore
();
MVStore
mvStore
;
if
(
s
==
null
)
{
// in-memory database
mvStore
=
MVStore
.
open
(
null
);
}
else
{
mvStore
=
s
.
getStore
();
mvStore
=
s
.
get
Mv
Store
();
}
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
.
get
MvStore
().
get
Store
().
isClosed
())
{
if
(
database
.
get
Store
().
getMv
Store
().
isClosed
())
{
return
;
}
// this might not be very efficient -
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
0fe83909
...
...
@@ -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
s
tore
=
database
.
getPageStore
();
if
(
s
tore
!=
null
)
{
PageStore
pageS
tore
=
database
.
getPageStore
();
if
(
pageS
tore
!=
null
)
{
add
(
rows
,
"info.FILE_WRITE_TOTAL"
,
Long
.
toString
(
s
tore
.
getWriteCountTotal
()));
Long
.
toString
(
pageS
tore
.
getWriteCountTotal
()));
add
(
rows
,
"info.FILE_WRITE"
,
Long
.
toString
(
s
tore
.
getWriteCount
()));
Long
.
toString
(
pageS
tore
.
getWriteCount
()));
add
(
rows
,
"info.FILE_READ"
,
Long
.
toString
(
s
tore
.
getReadCount
()));
Long
.
toString
(
pageS
tore
.
getReadCount
()));
add
(
rows
,
"info.PAGE_COUNT"
,
Integer
.
toString
(
s
tore
.
getPageCount
()));
Integer
.
toString
(
pageS
tore
.
getPageCount
()));
add
(
rows
,
"info.PAGE_SIZE"
,
Integer
.
toString
(
s
tore
.
getPageSize
()));
Integer
.
toString
(
pageS
tore
.
getPageSize
()));
add
(
rows
,
"info.CACHE_MAX_SIZE"
,
Integer
.
toString
(
s
tore
.
getCache
().
getMaxMemory
()));
Integer
.
toString
(
pageS
tore
.
getCache
().
getMaxMemory
()));
add
(
rows
,
"info.CACHE_SIZE"
,
Integer
.
toString
(
s
tore
.
getCache
().
getMemory
()));
Integer
.
toString
(
pageS
tore
.
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
.
get
Store
().
get
UpdateFailureRatio
()));
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
.
get
Store
().
get
CacheSize
()));
Integer
.
toString
(
mvStore
.
getCacheSize
()));
add
(
rows
,
"info.CACHE_SIZE"
,
Integer
.
toString
(
mvStore
.
get
Store
().
get
CacheSizeUsed
()));
Integer
.
toString
(
mvStore
.
getCacheSizeUsed
()));
}
}
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
0fe83909
...
...
@@ -1130,7 +1130,7 @@ public class TestMVTableEngine extends TestDb {
conn
=
getConnection
(
dbName
);
Database
db
=
(
Database
)
((
JdbcConnection
)
conn
).
getSession
()
.
getDataHandler
();
assertTrue
(
db
.
get
MvStore
().
get
Store
().
getFileStore
().
isReadOnly
());
assertTrue
(
db
.
get
Store
().
getMv
Store
().
getFileStore
().
isReadOnly
());
conn
.
close
();
}
...
...
@@ -1144,7 +1144,7 @@ public class TestMVTableEngine extends TestDb {
conn
=
getConnection
(
dbName
);
Database
db
=
(
Database
)
((
JdbcConnection
)
conn
).
getSession
().
getDataHandler
();
db
.
get
MvStore
().
get
Store
().
setRetentionTime
(
0
);
db
.
get
Store
().
getMv
Store
().
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) "
+
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论