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