Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4b982f97
提交
4b982f97
authored
12月 09, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore tool: improved output
上级
6fa15ff8
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
44 行增加
和
23 行删除
+44
-23
MVStoreTool.java
h2/src/main/org/h2/mvstore/MVStoreTool.java
+43
-22
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-1
没有找到文件。
h2/src/main/org/h2/mvstore/MVStoreTool.java
浏览文件 @
4b982f97
...
@@ -47,7 +47,7 @@ public class MVStoreTool {
...
@@ -47,7 +47,7 @@ public class MVStoreTool {
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
"-dump"
.
equals
(
args
[
i
]))
{
if
(
"-dump"
.
equals
(
args
[
i
]))
{
String
fileName
=
args
[++
i
];
String
fileName
=
args
[++
i
];
dump
(
fileName
,
new
PrintWriter
(
System
.
out
));
dump
(
fileName
,
new
PrintWriter
(
System
.
out
)
,
true
);
}
else
if
(
"-info"
.
equals
(
args
[
i
]))
{
}
else
if
(
"-info"
.
equals
(
args
[
i
]))
{
String
fileName
=
args
[++
i
];
String
fileName
=
args
[++
i
];
info
(
fileName
,
new
PrintWriter
(
System
.
out
));
info
(
fileName
,
new
PrintWriter
(
System
.
out
));
...
@@ -65,9 +65,10 @@ public class MVStoreTool {
...
@@ -65,9 +65,10 @@ public class MVStoreTool {
* Read the contents of the file and write them to system out.
* Read the contents of the file and write them to system out.
*
*
* @param fileName the name of the file
* @param fileName the name of the file
* @param details whether to print details
*/
*/
public
static
void
dump
(
String
fileName
)
{
public
static
void
dump
(
String
fileName
,
boolean
details
)
{
dump
(
fileName
,
new
PrintWriter
(
System
.
out
));
dump
(
fileName
,
new
PrintWriter
(
System
.
out
)
,
details
);
}
}
/**
/**
...
@@ -86,7 +87,7 @@ public class MVStoreTool {
...
@@ -86,7 +87,7 @@ public class MVStoreTool {
* @param fileName the name of the file
* @param fileName the name of the file
* @param writer the print writer
* @param writer the print writer
*/
*/
public
static
void
dump
(
String
fileName
,
Writer
writer
)
{
public
static
void
dump
(
String
fileName
,
Writer
writer
,
boolean
details
)
{
PrintWriter
pw
=
new
PrintWriter
(
writer
,
true
);
PrintWriter
pw
=
new
PrintWriter
(
writer
,
true
);
if
(!
FilePath
.
get
(
fileName
).
exists
())
{
if
(!
FilePath
.
get
(
fileName
).
exists
())
{
pw
.
println
(
"File not found: "
+
fileName
);
pw
.
println
(
"File not found: "
+
fileName
);
...
@@ -96,11 +97,15 @@ public class MVStoreTool {
...
@@ -96,11 +97,15 @@ public class MVStoreTool {
pw
.
printf
(
"File %s, %d bytes, %d MB\n"
,
fileName
,
size
,
size
/
1024
/
1024
);
pw
.
printf
(
"File %s, %d bytes, %d MB\n"
,
fileName
,
size
,
size
/
1024
/
1024
);
FileChannel
file
=
null
;
FileChannel
file
=
null
;
int
blockSize
=
MVStore
.
BLOCK_SIZE
;
int
blockSize
=
MVStore
.
BLOCK_SIZE
;
TreeMap
<
Integer
,
Long
>
mapSizesTotal
=
new
TreeMap
<
Integer
,
Long
>();
long
pageSizeTotal
=
0
;
try
{
try
{
file
=
FilePath
.
get
(
fileName
).
open
(
"r"
);
file
=
FilePath
.
get
(
fileName
).
open
(
"r"
);
long
fileSize
=
file
.
size
();
long
fileSize
=
file
.
size
();
int
len
=
Long
.
toHexString
(
fileSize
).
length
();
int
len
=
Long
.
toHexString
(
fileSize
).
length
();
ByteBuffer
block
=
ByteBuffer
.
allocate
(
4096
);
ByteBuffer
block
=
ByteBuffer
.
allocate
(
4096
);
long
pageCount
=
0
;
for
(
long
pos
=
0
;
pos
<
fileSize
;)
{
for
(
long
pos
=
0
;
pos
<
fileSize
;)
{
block
.
rewind
();
block
.
rewind
();
DataUtils
.
readFully
(
file
,
pos
,
block
);
DataUtils
.
readFully
(
file
,
pos
,
block
);
...
@@ -133,8 +138,10 @@ public class MVStoreTool {
...
@@ -133,8 +138,10 @@ public class MVStoreTool {
int
p
=
block
.
position
();
int
p
=
block
.
position
();
pos
+=
length
;
pos
+=
length
;
int
remaining
=
c
.
pageCount
;
int
remaining
=
c
.
pageCount
;
TreeMap
<
Integer
,
Integer
>
mapSizes
=
new
TreeMap
<
Integer
,
Integer
>();
pageCount
+=
c
.
pageCount
;
int
totalSize
=
0
;
TreeMap
<
Integer
,
Integer
>
mapSizes
=
new
TreeMap
<
Integer
,
Integer
>();
int
pageSizeSum
=
0
;
while
(
remaining
>
0
)
{
while
(
remaining
>
0
)
{
try
{
try
{
chunk
.
position
(
p
);
chunk
.
position
(
p
);
...
@@ -151,6 +158,7 @@ public class MVStoreTool {
...
@@ -151,6 +158,7 @@ public class MVStoreTool {
int
type
=
chunk
.
get
();
int
type
=
chunk
.
get
();
boolean
compressed
=
(
type
&
2
)
!=
0
;
boolean
compressed
=
(
type
&
2
)
!=
0
;
boolean
node
=
(
type
&
1
)
!=
0
;
boolean
node
=
(
type
&
1
)
!=
0
;
if
(
details
)
{
pw
.
printf
(
pw
.
printf
(
"+%0"
+
len
+
"+%0"
+
len
+
"x %s, map %x, %d entries, %d bytes, maxLen %x%n"
,
"x %s, map %x, %d entries, %d bytes, maxLen %x%n"
,
...
@@ -162,13 +170,20 @@ public class MVStoreTool {
...
@@ -162,13 +170,20 @@ public class MVStoreTool {
pageSize
,
pageSize
,
DataUtils
.
getPageMaxLength
(
DataUtils
.
getPagePos
(
0
,
0
,
pageSize
,
0
))
DataUtils
.
getPageMaxLength
(
DataUtils
.
getPagePos
(
0
,
0
,
pageSize
,
0
))
);
);
}
p
+=
pageSize
;
p
+=
pageSize
;
Integer
mapSize
=
mapSizes
.
get
(
mapId
);
Integer
mapSize
=
mapSizes
.
get
(
mapId
);
if
(
mapSize
==
null
)
{
if
(
mapSize
==
null
)
{
mapSize
=
0
;
mapSize
=
0
;
}
}
mapSizes
.
put
(
mapId
,
mapSize
+
pageSize
);
mapSizes
.
put
(
mapId
,
mapSize
+
pageSize
);
totalSize
+=
pageSize
;
Long
total
=
mapSizesTotal
.
get
(
mapId
);
if
(
total
==
null
)
{
total
=
0L
;
}
mapSizesTotal
.
put
(
mapId
,
total
+
pageSize
);
pageSizeSum
+=
pageSize
;
pageSizeTotal
+=
pageSize
;
remaining
--;
remaining
--;
long
[]
children
=
null
;
long
[]
children
=
null
;
long
[]
counts
=
null
;
long
[]
counts
=
null
;
...
@@ -184,7 +199,7 @@ public class MVStoreTool {
...
@@ -184,7 +199,7 @@ public class MVStoreTool {
}
}
}
}
String
[]
keys
=
new
String
[
entries
];
String
[]
keys
=
new
String
[
entries
];
if
(
mapId
==
0
)
{
if
(
mapId
==
0
&&
details
)
{
if
(!
compressed
)
{
if
(!
compressed
)
{
for
(
int
i
=
0
;
i
<
entries
;
i
++)
{
for
(
int
i
=
0
;
i
<
entries
;
i
++)
{
String
k
=
StringDataType
.
INSTANCE
.
read
(
chunk
);
String
k
=
StringDataType
.
INSTANCE
.
read
(
chunk
);
...
@@ -223,7 +238,7 @@ public class MVStoreTool {
...
@@ -223,7 +238,7 @@ public class MVStoreTool {
}
}
}
}
}
else
{
}
else
{
if
(
node
)
{
if
(
node
&&
details
)
{
for
(
int
i
=
0
;
i
<=
entries
;
i
++)
{
for
(
int
i
=
0
;
i
<=
entries
;
i
++)
{
long
cp
=
children
[
i
];
long
cp
=
children
[
i
];
pw
.
printf
(
" %d children @ chunk %x +%0"
+
pw
.
printf
(
" %d children @ chunk %x +%0"
+
...
@@ -236,8 +251,8 @@ public class MVStoreTool {
...
@@ -236,8 +251,8 @@ public class MVStoreTool {
}
}
}
}
for
(
Integer
mapId
:
mapSizes
.
keySet
())
{
for
(
Integer
mapId
:
mapSizes
.
keySet
())
{
int
percent
=
100
*
mapSizes
.
get
(
mapId
)
/
totalSize
;
int
percent
=
100
*
mapSizes
.
get
(
mapId
)
/
pageSizeSum
;
pw
.
printf
(
"map %x: %d
%%%n"
,
mapId
,
percent
);
pw
.
printf
(
"map %x: %d
bytes, %d%%%n"
,
mapId
,
mapSizes
.
get
(
mapId
)
,
percent
);
}
}
int
footerPos
=
chunk
.
limit
()
-
Chunk
.
FOOTER_LENGTH
;
int
footerPos
=
chunk
.
limit
()
-
Chunk
.
FOOTER_LENGTH
;
try
{
try
{
...
@@ -254,6 +269,12 @@ public class MVStoreTool {
...
@@ -254,6 +269,12 @@ public class MVStoreTool {
}
}
pw
.
printf
(
"%n%0"
+
len
+
"x eof%n"
,
fileSize
);
pw
.
printf
(
"%n%0"
+
len
+
"x eof%n"
,
fileSize
);
pw
.
printf
(
"\n"
);
pw
.
printf
(
"\n"
);
pw
.
printf
(
"page size total: %d bytes, page count: %d, average page size: %d bytes\n"
,
pageSizeTotal
,
pageCount
,
pageSizeTotal
/
pageCount
);
for
(
Integer
mapId
:
mapSizesTotal
.
keySet
())
{
int
percent
=
(
int
)
(
100
*
mapSizesTotal
.
get
(
mapId
)
/
pageSizeTotal
);
pw
.
printf
(
"map %x: %d bytes, %d%%%n"
,
mapId
,
mapSizesTotal
.
get
(
mapId
),
percent
);
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
pw
.
println
(
"ERROR: "
+
e
);
pw
.
println
(
"ERROR: "
+
e
);
e
.
printStackTrace
(
pw
);
e
.
printStackTrace
(
pw
);
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
4b982f97
...
@@ -324,7 +324,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -324,7 +324,7 @@ public class Recover extends Tool implements DataHandler {
Constants
.
SUFFIX_PAGE_FILE
.
length
());
Constants
.
SUFFIX_PAGE_FILE
.
length
());
PrintWriter
writer
;
PrintWriter
writer
;
writer
=
getWriter
(
fileName
,
".txt"
);
writer
=
getWriter
(
fileName
,
".txt"
);
MVStoreTool
.
dump
(
fileName
,
writer
);
MVStoreTool
.
dump
(
fileName
,
writer
,
true
);
MVStoreTool
.
info
(
fileName
,
writer
);
MVStoreTool
.
info
(
fileName
,
writer
);
writer
.
close
();
writer
.
close
();
writer
=
getWriter
(
f
+
".h2.db"
,
".sql"
);
writer
=
getWriter
(
f
+
".h2.db"
,
".sql"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论