Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
95940109
提交
95940109
authored
8月 01, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A persistent tree map (work in progress).
上级
dcc2163b
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
57 行增加
和
15 行删除
+57
-15
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+1
-0
RowType.java
h2/src/test/org/h2/test/store/RowType.java
+7
-0
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+2
-1
BtreeMap.java
h2/src/tools/org/h2/dev/store/btree/BtreeMap.java
+1
-0
DataType.java
h2/src/tools/org/h2/dev/store/btree/DataType.java
+1
-1
DataUtils.java
h2/src/tools/org/h2/dev/store/btree/DataUtils.java
+16
-0
Dump.java
h2/src/tools/org/h2/dev/store/btree/Dump.java
+28
-11
Page.java
h2/src/tools/org/h2/dev/store/btree/Page.java
+1
-2
没有找到文件。
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
95940109
...
@@ -663,6 +663,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -663,6 +663,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
private
void
testUnit
()
{
private
void
testUnit
()
{
// store
// store
new
TestTreeMapStore
().
runTest
(
this
);
new
TestTreeMapStore
().
runTest
(
this
);
new
TestCache
().
runTest
(
this
);
// unit
// unit
new
TestAutoReconnect
().
runTest
(
this
);
new
TestAutoReconnect
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/store/RowType.java
浏览文件 @
95940109
...
@@ -108,6 +108,13 @@ public class RowType implements DataType {
...
@@ -108,6 +108,13 @@ public class RowType implements DataType {
return
buff
.
toString
();
return
buff
.
toString
();
}
}
/**
* Convert a row type to a row.
*
* @param t the type string
* @param factory the data type factory
* @return the row type
*/
static
RowType
fromString
(
String
t
,
DataTypeFactory
factory
)
{
static
RowType
fromString
(
String
t
,
DataTypeFactory
factory
)
{
if
(!
t
.
startsWith
(
"r("
)
||
!
t
.
endsWith
(
")"
))
{
if
(!
t
.
startsWith
(
"r("
)
||
!
t
.
endsWith
(
")"
))
{
throw
new
RuntimeException
(
"Unknown type: "
+
t
);
throw
new
RuntimeException
(
"Unknown type: "
+
t
);
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
95940109
...
@@ -705,4 +705,5 @@ clusterable shortcut quota wcslen flyway cacao tea memcpy someone iced
...
@@ -705,4 +705,5 @@ clusterable shortcut quota wcslen flyway cacao tea memcpy someone iced
korea cpp raspberry inttypes korean hmac swprintf ptr agile rawtypes belgium
korea cpp raspberry inttypes korean hmac swprintf ptr agile rawtypes belgium
jia laurent midori stdc macros clocks xaltjvm teruo dylan debian counted
jia laurent midori stdc macros clocks xaltjvm teruo dylan debian counted
serializes semantics advances severe defensive maintaining collision
serializes semantics advances severe defensive maintaining collision
authenticating
authenticating song lir evict edge adjusts recency lirs prune heads sigmetrics
resident guard hir jiang resistance zhang xiaodong
h2/src/tools/org/h2/dev/store/btree/BtreeMap.java
浏览文件 @
95940109
...
@@ -37,6 +37,7 @@ public class BtreeMap<K, V> {
...
@@ -37,6 +37,7 @@ public class BtreeMap<K, V> {
* @param <K> the key type
* @param <K> the key type
* @param <V> the value type
* @param <V> the value type
* @param store the tree store
* @param store the tree store
* @param id the map id
* @param name the name of the map
* @param name the name of the map
* @param keyClass the key class
* @param keyClass the key class
* @param valueClass the value class
* @param valueClass the value class
...
...
h2/src/tools/org/h2/dev/store/btree/DataType.java
浏览文件 @
95940109
...
@@ -51,7 +51,7 @@ public interface DataType {
...
@@ -51,7 +51,7 @@ public interface DataType {
* Write the object.
* Write the object.
*
*
* @param buff the target buffer
* @param buff the target buffer
* @param
x
the value
* @param
obj
the value
*/
*/
void
write
(
ByteBuffer
buff
,
Object
obj
);
void
write
(
ByteBuffer
buff
,
Object
obj
);
...
...
h2/src/tools/org/h2/dev/store/btree/DataUtils.java
浏览文件 @
95940109
...
@@ -138,6 +138,14 @@ public class DataUtils {
...
@@ -138,6 +138,14 @@ public class DataUtils {
buff
.
put
((
byte
)
x
);
buff
.
put
((
byte
)
x
);
}
}
/**
* Copy the elements of an array, with a gap.
*
* @param src the source array
* @param dst the target array
* @param oldSize the size of the old array
* @param gapIndex the index of the gap
*/
static
void
copyWithGap
(
Object
src
,
Object
dst
,
int
oldSize
,
int
gapIndex
)
{
static
void
copyWithGap
(
Object
src
,
Object
dst
,
int
oldSize
,
int
gapIndex
)
{
if
(
gapIndex
>
0
)
{
if
(
gapIndex
>
0
)
{
System
.
arraycopy
(
src
,
0
,
dst
,
0
,
gapIndex
);
System
.
arraycopy
(
src
,
0
,
dst
,
0
,
gapIndex
);
...
@@ -147,6 +155,14 @@ public class DataUtils {
...
@@ -147,6 +155,14 @@ public class DataUtils {
}
}
}
}
/**
* Copy the elements of an array, and remove one element.
*
* @param src the source array
* @param dst the target array
* @param oldSize the size of the old array
* @param removeIndex the index of the entry to remove
*/
static
void
copyExcept
(
Object
src
,
Object
dst
,
int
oldSize
,
int
removeIndex
)
{
static
void
copyExcept
(
Object
src
,
Object
dst
,
int
oldSize
,
int
removeIndex
)
{
if
(
removeIndex
>
0
&&
oldSize
>
0
)
{
if
(
removeIndex
>
0
&&
oldSize
>
0
)
{
System
.
arraycopy
(
src
,
0
,
dst
,
0
,
removeIndex
);
System
.
arraycopy
(
src
,
0
,
dst
,
0
,
removeIndex
);
...
...
h2/src/tools/org/h2/dev/store/btree/Dump.java
浏览文件 @
95940109
...
@@ -8,6 +8,7 @@ package org.h2.dev.store.btree;
...
@@ -8,6 +8,7 @@ package org.h2.dev.store.btree;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.StringReader
;
import
java.io.StringReader
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileChannel
;
...
@@ -23,6 +24,16 @@ public class Dump {
...
@@ -23,6 +24,16 @@ public class Dump {
private
static
int
blockSize
=
4
*
1024
;
private
static
int
blockSize
=
4
*
1024
;
/**
* Runs this tool.
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-file]</td>
* <td>The database file name</td></tr>
* </table>
*
* @param args the command line arguments
*/
public
static
void
main
(
String
...
args
)
{
public
static
void
main
(
String
...
args
)
{
String
fileName
=
"test.h3"
;
String
fileName
=
"test.h3"
;
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
...
@@ -30,12 +41,18 @@ public class Dump {
...
@@ -30,12 +41,18 @@ public class Dump {
fileName
=
args
[++
i
];
fileName
=
args
[++
i
];
}
}
}
}
dump
(
fileName
);
dump
(
fileName
,
new
PrintWriter
(
System
.
out
)
);
}
}
public
static
void
dump
(
String
fileName
)
{
/**
* Dump the contents of the file.
*
* @param fileName the name of the file
* @param writer the print writer
*/
public
static
void
dump
(
String
fileName
,
PrintWriter
writer
)
{
if
(!
FileUtils
.
exists
(
fileName
))
{
if
(!
FileUtils
.
exists
(
fileName
))
{
System
.
out
.
println
(
"File not found: "
+
fileName
);
writer
.
println
(
"File not found: "
+
fileName
);
return
;
return
;
}
}
FileChannel
file
=
null
;
FileChannel
file
=
null
;
...
@@ -48,9 +65,9 @@ public class Dump {
...
@@ -48,9 +65,9 @@ public class Dump {
Properties
prop
=
new
Properties
();
Properties
prop
=
new
Properties
();
prop
.
load
(
new
ByteArrayInputStream
(
header
));
prop
.
load
(
new
ByteArrayInputStream
(
header
));
prop
.
load
(
new
StringReader
(
new
String
(
header
,
"UTF-8"
)));
prop
.
load
(
new
StringReader
(
new
String
(
header
,
"UTF-8"
)));
System
.
out
.
println
(
"file "
+
fileName
);
writer
.
println
(
"file "
+
fileName
);
System
.
out
.
println
(
" length "
+
fileLength
);
writer
.
println
(
" length "
+
fileLength
);
System
.
out
.
println
(
" "
+
prop
);
writer
.
println
(
" "
+
prop
);
ByteBuffer
block
=
ByteBuffer
.
wrap
(
new
byte
[
16
]);
ByteBuffer
block
=
ByteBuffer
.
wrap
(
new
byte
[
16
]);
for
(
long
pos
=
0
;
pos
<
fileLength
;)
{
for
(
long
pos
=
0
;
pos
<
fileLength
;)
{
file
.
position
(
pos
);
file
.
position
(
pos
);
...
@@ -64,7 +81,7 @@ public class Dump {
...
@@ -64,7 +81,7 @@ public class Dump {
int
length
=
block
.
getInt
();
int
length
=
block
.
getInt
();
int
chunkId
=
block
.
getInt
();
int
chunkId
=
block
.
getInt
();
int
metaRootOffset
=
block
.
getInt
();
int
metaRootOffset
=
block
.
getInt
();
System
.
out
.
println
(
" chunk "
+
chunkId
+
" at "
+
pos
+
writer
.
println
(
" chunk "
+
chunkId
+
" at "
+
pos
+
" length "
+
length
+
" offset "
+
metaRootOffset
);
" length "
+
length
+
" offset "
+
metaRootOffset
);
ByteBuffer
chunk
=
ByteBuffer
.
allocate
(
length
);
ByteBuffer
chunk
=
ByteBuffer
.
allocate
(
length
);
file
.
position
(
pos
);
file
.
position
(
pos
);
...
@@ -83,16 +100,16 @@ public class Dump {
...
@@ -83,16 +100,16 @@ public class Dump {
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
children
[
i
]
=
chunk
.
getLong
();
children
[
i
]
=
chunk
.
getLong
();
}
}
System
.
out
.
println
(
" map "
+
mapId
+
" at "
+
p
+
" node, "
+
count
+
" children: "
+
Arrays
.
toString
(
children
));
writer
.
println
(
" map "
+
mapId
+
" at "
+
p
+
" node, "
+
count
+
" children: "
+
Arrays
.
toString
(
children
));
}
else
{
}
else
{
System
.
out
.
println
(
" map "
+
mapId
+
" at "
+
p
+
" leaf, "
+
count
+
" rows"
);
writer
.
println
(
" map "
+
mapId
+
" at "
+
p
+
" leaf, "
+
count
+
" rows"
);
}
}
p
+=
len
;
p
+=
len
;
length
-=
len
;
length
-=
len
;
}
}
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"ERROR: "
+
e
);
writer
.
println
(
"ERROR: "
+
e
);
}
finally
{
}
finally
{
try
{
try
{
file
.
close
();
file
.
close
();
...
@@ -100,7 +117,7 @@ public class Dump {
...
@@ -100,7 +117,7 @@ public class Dump {
// ignore
// ignore
}
}
}
}
System
.
out
.
println
();
writer
.
println
();
}
}
}
}
h2/src/tools/org/h2/dev/store/btree/Page.java
浏览文件 @
95940109
...
@@ -482,7 +482,7 @@ public class Page {
...
@@ -482,7 +482,7 @@ public class Page {
buff
.
getInt
();
buff
.
getInt
();
long
id
=
buff
.
getLong
();
long
id
=
buff
.
getLong
();
if
(
id
!=
map
.
getId
())
{
if
(
id
!=
map
.
getId
())
{
throw
new
RuntimeException
(
"Page map id mis
s
match, expected "
+
map
.
getId
()
+
" got "
+
id
);
throw
new
RuntimeException
(
"Page map id mismatch, expected "
+
map
.
getId
()
+
" got "
+
id
);
}
}
boolean
node
=
buff
.
get
()
==
1
;
boolean
node
=
buff
.
get
()
==
1
;
if
(
node
)
{
if
(
node
)
{
...
@@ -541,7 +541,6 @@ public class Page {
...
@@ -541,7 +541,6 @@ public class Page {
/**
/**
* Get the maximum length in bytes to store temporary records, recursively.
* Get the maximum length in bytes to store temporary records, recursively.
*
*
* @param pageId the new page id
* @return the next page id
* @return the next page id
*/
*/
int
getMaxLengthTempRecursive
()
{
int
getMaxLengthTempRecursive
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论