Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ddafc6b4
提交
ddafc6b4
authored
7月 10, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVTableEngine: store all metadata in the MVStore.
上级
19dded26
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
60 行增加
和
20 行删除
+60
-20
DbSettings.java
h2/src/main/org/h2/constant/DbSettings.java
+7
-0
Database.java
h2/src/main/org/h2/engine/Database.java
+6
-0
Schema.java
h2/src/main/org/h2/schema/Schema.java
+6
-0
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+1
-1
TableBase.java
h2/src/main/org/h2/table/TableBase.java
+7
-1
Recover.java
h2/src/main/org/h2/tools/Recover.java
+16
-2
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+4
-1
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+2
-4
TestScalability.java
h2/src/test/org/h2/test/bench/TestScalability.java
+1
-1
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+10
-10
没有找到文件。
h2/src/main/org/h2/constant/DbSettings.java
浏览文件 @
ddafc6b4
...
@@ -321,6 +321,13 @@ public class DbSettings extends SettingsBase {
...
@@ -321,6 +321,13 @@ public class DbSettings extends SettingsBase {
*/
*/
public
String
defaultTableEngine
=
get
(
"DEFAULT_TABLE_ENGINE"
,
null
);
public
String
defaultTableEngine
=
get
(
"DEFAULT_TABLE_ENGINE"
,
null
);
/**
* Database setting <code>MV_STORE</code>
* (default: false).<br />
* Use the MVStore storage engine.
*/
public
final
boolean
mvStore
=
get
(
"MV_STORE"
,
false
);
private
DbSettings
(
HashMap
<
String
,
String
>
s
)
{
private
DbSettings
(
HashMap
<
String
,
String
>
s
)
{
super
(
s
);
super
(
s
);
}
}
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
ddafc6b4
...
@@ -1687,6 +1687,9 @@ public class Database implements DataHandler {
...
@@ -1687,6 +1687,9 @@ public class Database implements DataHandler {
if
(
pageStore
!=
null
)
{
if
(
pageStore
!=
null
)
{
pageStore
.
getCache
().
setMaxMemory
(
kb
);
pageStore
.
getCache
().
setMaxMemory
(
kb
);
}
}
if
(
mvStore
!=
null
)
{
mvStore
.
setCacheSize
(
Math
.
max
(
1
,
kb
/
1024
));
}
}
}
public
synchronized
void
setMasterUser
(
User
user
)
{
public
synchronized
void
setMasterUser
(
User
user
)
{
...
@@ -2151,6 +2154,9 @@ public class Database implements DataHandler {
...
@@ -2151,6 +2154,9 @@ public class Database implements DataHandler {
}
}
public
PageStore
getPageStore
()
{
public
PageStore
getPageStore
()
{
if
(
dbSettings
.
mvStore
&&
mvStore
==
null
)
{
mvStore
=
MVTableEngine
.
init
(
this
);
}
if
(
pageStore
==
null
)
{
if
(
pageStore
==
null
)
{
pageStore
=
new
PageStore
(
this
,
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
,
accessModeData
,
cacheSize
);
pageStore
=
new
PageStore
(
this
,
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
,
accessModeData
,
cacheSize
);
if
(
pageSize
!=
Constants
.
DEFAULT_PAGE_SIZE
)
{
if
(
pageSize
!=
Constants
.
DEFAULT_PAGE_SIZE
)
{
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
ddafc6b4
...
@@ -23,6 +23,7 @@ import org.h2.engine.User;
...
@@ -23,6 +23,7 @@ import org.h2.engine.User;
import
org.h2.index.Index
;
import
org.h2.index.Index
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
import
org.h2.mvstore.db.MVTableEngine
;
import
org.h2.table.RegularTable
;
import
org.h2.table.RegularTable
;
import
org.h2.table.Table
;
import
org.h2.table.Table
;
import
org.h2.table.TableLink
;
import
org.h2.table.TableLink
;
...
@@ -548,6 +549,11 @@ public class Schema extends DbObjectBase {
...
@@ -548,6 +549,11 @@ public class Schema extends DbObjectBase {
database
.
lockMeta
(
data
.
session
);
database
.
lockMeta
(
data
.
session
);
}
}
data
.
schema
=
this
;
data
.
schema
=
this
;
if
(
data
.
tableEngine
==
null
)
{
if
(
database
.
getSettings
().
mvStore
)
{
data
.
tableEngine
=
MVTableEngine
.
class
.
getName
();
}
}
if
(
data
.
tableEngine
!=
null
)
{
if
(
data
.
tableEngine
!=
null
)
{
TableEngine
engine
;
TableEngine
engine
;
try
{
try
{
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
ddafc6b4
...
@@ -120,7 +120,7 @@ public class PageStore implements CacheWriter {
...
@@ -120,7 +120,7 @@ public class PageStore implements CacheWriter {
public
static
final
int
LOG_MODE_SYNC
=
2
;
public
static
final
int
LOG_MODE_SYNC
=
2
;
private
static
final
int
PAGE_ID_FREE_LIST_ROOT
=
3
;
private
static
final
int
PAGE_ID_FREE_LIST_ROOT
=
3
;
private
static
final
int
PAGE_ID_META_ROOT
=
4
;
private
static
final
int
PAGE_ID_META_ROOT
=
4
;
private
static
final
int
MIN_PAGE_COUNT
=
6
;
private
static
final
int
MIN_PAGE_COUNT
=
5
;
private
static
final
int
INCREMENT_KB
=
1024
;
private
static
final
int
INCREMENT_KB
=
1024
;
private
static
final
int
INCREMENT_PERCENT_MIN
=
35
;
private
static
final
int
INCREMENT_PERCENT_MIN
=
35
;
private
static
final
int
READ_VERSION
=
3
;
private
static
final
int
READ_VERSION
=
3
;
...
...
h2/src/main/org/h2/table/TableBase.java
浏览文件 @
ddafc6b4
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
package
org
.
h2
.
table
;
package
org
.
h2
.
table
;
import
org.h2.command.ddl.CreateTableData
;
import
org.h2.command.ddl.CreateTableData
;
import
org.h2.constant.DbSettings
;
import
org.h2.mvstore.db.MVTableEngine
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
...
@@ -70,7 +72,11 @@ public abstract class TableBase extends Table {
...
@@ -70,7 +72,11 @@ public abstract class TableBase extends Table {
}
}
buff
.
append
(
"\n)"
);
buff
.
append
(
"\n)"
);
if
(
tableEngine
!=
null
)
{
if
(
tableEngine
!=
null
)
{
String
d
=
getDatabase
().
getSettings
().
defaultTableEngine
;
DbSettings
s
=
getDatabase
().
getSettings
();
String
d
=
s
.
defaultTableEngine
;
if
(
d
==
null
&&
s
.
mvStore
)
{
d
=
MVTableEngine
.
class
.
getName
();
}
if
(
d
==
null
||
!
tableEngine
.
endsWith
(
d
))
{
if
(
d
==
null
||
!
tableEngine
.
endsWith
(
d
))
{
buff
.
append
(
"\nENGINE \""
);
buff
.
append
(
"\nENGINE \""
);
buff
.
append
(
tableEngine
);
buff
.
append
(
tableEngine
);
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
ddafc6b4
...
@@ -492,8 +492,8 @@ public class Recover extends Tool implements DataHandler {
...
@@ -492,8 +492,8 @@ public class Recover extends Tool implements DataHandler {
MVStore
mv
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
readOnly
().
open
();
MVStore
mv
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
readOnly
().
open
();
TransactionStore
store
=
new
TransactionStore
(
mv
);
TransactionStore
store
=
new
TransactionStore
(
mv
);
try
{
try
{
MVMap
<
String
,
String
>
meta
=
mv
.
getMetaMap
();
MVMap
<
String
,
String
>
meta
Map
=
mv
.
getMetaMap
();
Iterator
<
String
>
it
=
meta
.
keyIterator
(
null
);
Iterator
<
String
>
it
=
meta
Map
.
keyIterator
(
null
);
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
String
key
=
it
.
next
();
String
key
=
it
.
next
();
if
(!
key
.
startsWith
(
"name.table."
))
{
if
(!
key
.
startsWith
(
"name.table."
))
{
...
@@ -537,6 +537,20 @@ public class Recover extends Tool implements DataHandler {
...
@@ -537,6 +537,20 @@ public class Recover extends Tool implements DataHandler {
}
}
buff
.
append
(
");"
);
buff
.
append
(
");"
);
writer
.
println
(
buff
.
toString
());
writer
.
println
(
buff
.
toString
());
if
(
storageId
==
0
)
{
try
{
SimpleRow
r
=
new
SimpleRow
(
values
);
MetaRecord
meta
=
new
MetaRecord
(
r
);
schema
.
add
(
meta
);
if
(
meta
.
getObjectType
()
==
DbObject
.
TABLE_OR_VIEW
)
{
String
sql
=
values
[
3
].
getString
();
String
name
=
extractTableOrViewName
(
sql
);
tableMap
.
put
(
meta
.
getId
(),
name
);
}
}
catch
(
Throwable
t
)
{
writeError
(
writer
,
t
);
}
}
}
}
}
}
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
ddafc6b4
...
@@ -680,7 +680,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -680,7 +680,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestRandomCompare
().
runTest
(
this
);
new
TestRandomCompare
().
runTest
(
this
);
new
TestKillRestart
().
runTest
(
this
);
new
TestKillRestart
().
runTest
(
this
);
new
TestKillRestartMulti
().
runTest
(
this
);
new
TestKillRestartMulti
().
runTest
(
this
);
if
(!
mvStore
)
{
// concurrent modification of the undoLog
new
TestMultiThreaded
().
runTest
(
this
);
new
TestMultiThreaded
().
runTest
(
this
);
}
new
TestOuterJoins
().
runTest
(
this
);
new
TestOuterJoins
().
runTest
(
this
);
new
TestNestedJoins
().
runTest
(
this
);
new
TestNestedJoins
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
ddafc6b4
...
@@ -248,8 +248,7 @@ public abstract class TestBase {
...
@@ -248,8 +248,7 @@ public abstract class TestBase {
String
url
;
String
url
;
if
(
name
.
startsWith
(
"jdbc:"
))
{
if
(
name
.
startsWith
(
"jdbc:"
))
{
if
(
config
.
mvStore
)
{
if
(
config
.
mvStore
)
{
name
=
addOption
(
name
,
"DEFAULT_TABLE_ENGINE"
,
name
=
addOption
(
name
,
"MV_STORE"
,
"true"
);
"org.h2.mvstore.db.MVTableEngine"
);
}
}
return
name
;
return
name
;
}
}
...
@@ -274,8 +273,7 @@ public abstract class TestBase {
...
@@ -274,8 +273,7 @@ public abstract class TestBase {
url
=
name
;
url
=
name
;
}
}
if
(
config
.
mvStore
)
{
if
(
config
.
mvStore
)
{
url
=
addOption
(
url
,
"DEFAULT_TABLE_ENGINE"
,
url
=
addOption
(
name
,
"MV_STORE"
,
"true"
);
"org.h2.mvstore.db.MVTableEngine"
);
}
}
if
(!
config
.
memory
)
{
if
(!
config
.
memory
)
{
if
(
config
.
smallLog
&&
admin
)
{
if
(
config
.
smallLog
&&
admin
)
{
...
...
h2/src/test/org/h2/test/bench/TestScalability.java
浏览文件 @
ddafc6b4
...
@@ -81,7 +81,7 @@ public class TestScalability implements Database.DatabaseTest {
...
@@ -81,7 +81,7 @@ public class TestScalability implements Database.DatabaseTest {
dbs
.
add
(
createDbEntry
(
id
++,
"H2"
,
50
,
h2Url
));
dbs
.
add
(
createDbEntry
(
id
++,
"H2"
,
50
,
h2Url
));
dbs
.
add
(
createDbEntry
(
id
++,
"H2"
,
100
,
h2Url
));
dbs
.
add
(
createDbEntry
(
id
++,
"H2"
,
100
,
h2Url
));
final
String
mvUrl
=
"jdbc:h2:data/mvTest;LOCK_TIMEOUT=10000;
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
final
String
mvUrl
=
"jdbc:h2:data/mvTest;LOCK_TIMEOUT=10000;
MV_STORE=TRUE
"
;
dbs
.
add
(
createDbEntry
(
id
++,
"MV"
,
1
,
mvUrl
));
dbs
.
add
(
createDbEntry
(
id
++,
"MV"
,
1
,
mvUrl
));
dbs
.
add
(
createDbEntry
(
id
++,
"MV"
,
10
,
mvUrl
));
dbs
.
add
(
createDbEntry
(
id
++,
"MV"
,
10
,
mvUrl
));
dbs
.
add
(
createDbEntry
(
id
++,
"MV"
,
20
,
mvUrl
));
dbs
.
add
(
createDbEntry
(
id
++,
"MV"
,
20
,
mvUrl
));
...
...
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
ddafc6b4
...
@@ -69,7 +69,7 @@ public class TestCluster extends TestBase {
...
@@ -69,7 +69,7 @@ public class TestCluster extends TestBase {
String
url2
=
getURL
(
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test"
,
false
);
String
url2
=
getURL
(
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test"
,
false
);
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
String
urlCluster
=
"jdbc:h2:tcp://"
+
serverList
+
"/test"
;
String
urlCluster
=
getURL
(
"jdbc:h2:tcp://"
+
serverList
+
"/test"
,
true
)
;
CreateCluster
.
main
(
"-urlSource"
,
url1
,
"-urlTarget"
,
url2
,
"-user"
,
user
,
"-password"
,
password
,
"-serverList"
,
CreateCluster
.
main
(
"-urlSource"
,
url1
,
"-urlTarget"
,
url2
,
"-user"
,
user
,
"-password"
,
password
,
"-serverList"
,
serverList
);
serverList
);
...
@@ -95,9 +95,9 @@ public class TestCluster extends TestBase {
...
@@ -95,9 +95,9 @@ public class TestCluster extends TestBase {
Statement
stat
;
Statement
stat
;
ResultSet
rs
;
ResultSet
rs
;
String
url1
=
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test"
;
String
url1
=
getURL
(
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test"
,
true
)
;
String
url2
=
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test"
;
String
url2
=
getURL
(
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test"
,
true
)
;
String
urlCluster
=
"jdbc:h2:tcp://"
+
serverList
+
"/test"
;
String
urlCluster
=
getURL
(
"jdbc:h2:tcp://"
+
serverList
+
"/test"
,
true
)
;
Server
server1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
Server
server1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
...
@@ -155,9 +155,9 @@ public class TestCluster extends TestBase {
...
@@ -155,9 +155,9 @@ public class TestCluster extends TestBase {
Statement
stat
;
Statement
stat
;
ResultSet
rs
;
ResultSet
rs
;
String
url1
=
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test"
;
String
url1
=
getURL
(
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test"
,
true
)
;
String
url2
=
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test"
;
String
url2
=
getURL
(
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test"
,
true
)
;
String
urlCluster
=
"jdbc:h2:tcp://"
+
serverList
+
"/test"
;
String
urlCluster
=
getURL
(
"jdbc:h2:tcp://"
+
serverList
+
"/test"
,
true
)
;
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
...
@@ -200,9 +200,9 @@ public class TestCluster extends TestBase {
...
@@ -200,9 +200,9 @@ public class TestCluster extends TestBase {
Statement
stat
;
Statement
stat
;
ResultSet
rs
;
ResultSet
rs
;
String
url1
=
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test"
;
String
url1
=
getURL
(
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test"
,
true
)
;
String
url2
=
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test"
;
String
url2
=
getURL
(
"jdbc:h2:tcp://localhost:"
+
port2
+
"/test"
,
true
)
;
String
urlCluster
=
"jdbc:h2:tcp://"
+
serverList
+
"/test"
;
String
urlCluster
=
getURL
(
"jdbc:h2:tcp://"
+
serverList
+
"/test"
,
true
)
;
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port1
,
"-baseDir"
,
getBaseDir
()
+
"/node1"
).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
""
+
port2
,
"-baseDir"
,
getBaseDir
()
+
"/node2"
).
start
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论