Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e26337e9
提交
e26337e9
authored
7 年前
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#636: Avoid using String.substring() excessively in H2's internals
上级
83663e41
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
101 行增加
和
17 行删除
+101
-17
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
Chunk.java
h2/src/main/org/h2/mvstore/Chunk.java
+99
-17
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
e26337e9
...
@@ -21,6 +21,8 @@ Change Log
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue #636: Avoid using String.substring() excessively in H2's internals
</li>
<li>
Issue #643: H2 doesn't use index when I use IN and EQUAL in one query
<li>
Issue #643: H2 doesn't use index when I use IN and EQUAL in one query
</li>
</li>
<li>
Reset transaction start timestamp on ROLLBACK
<li>
Reset transaction start timestamp on ROLLBACK
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/Chunk.java
浏览文件 @
e26337e9
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
package
org
.
h2
.
mvstore
;
package
org
.
h2
.
mvstore
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.util.HashMap
;
import
org.h2.engine.SysProperties
;
/**
/**
* A chunk of data, containing one or multiple pages.
* A chunk of data, containing one or multiple pages.
...
@@ -179,22 +179,104 @@ public class Chunk {
...
@@ -179,22 +179,104 @@ public class Chunk {
* @return the block
* @return the block
*/
*/
public
static
Chunk
fromString
(
String
s
)
{
public
static
Chunk
fromString
(
String
s
)
{
HashMap
<
String
,
String
>
map
=
DataUtils
.
parseMap
(
s
);
// This is an inline version of DataUtils.parseMap, inlined
int
id
=
DataUtils
.
readHexInt
(
map
,
"chunk"
,
0
);
// because parseMap shows up quite high in CPU and garbage performance
Chunk
c
=
new
Chunk
(
id
);
// tracing.
c
.
block
=
DataUtils
.
readHexLong
(
map
,
"block"
,
0
);
long
block
=
0
;
c
.
len
=
DataUtils
.
readHexInt
(
map
,
"len"
,
0
);
int
id
=
0
;
c
.
pageCount
=
DataUtils
.
readHexInt
(
map
,
"pages"
,
0
);
int
len
=
0
;
c
.
pageCountLive
=
DataUtils
.
readHexInt
(
map
,
"livePages"
,
c
.
pageCount
);
int
pageCount
=
0
;
c
.
mapId
=
DataUtils
.
readHexInt
(
map
,
"map"
,
0
);
Integer
livePages
=
null
;
c
.
maxLen
=
DataUtils
.
readHexLong
(
map
,
"max"
,
0
);
int
mapId
=
0
;
c
.
maxLenLive
=
DataUtils
.
readHexLong
(
map
,
"liveMax"
,
c
.
maxLen
);
long
maxLen
=
0
;
c
.
metaRootPos
=
DataUtils
.
readHexLong
(
map
,
"root"
,
0
);
Long
maxLenLive
=
null
;
c
.
time
=
DataUtils
.
readHexLong
(
map
,
"time"
,
0
);
long
metaRootPos
=
0
;
c
.
unused
=
DataUtils
.
readHexLong
(
map
,
"unused"
,
0
);
long
time
=
0
;
c
.
version
=
DataUtils
.
readHexLong
(
map
,
"version"
,
id
);
long
unused
=
0
;
c
.
next
=
DataUtils
.
readHexLong
(
map
,
"next"
,
0
);
long
version
=
0
;
return
c
;
long
next
=
0
;
for
(
int
i
=
0
,
size
=
s
.
length
();
i
<
size
;)
{
final
int
startKey
=
i
;
i
=
s
.
indexOf
(
':'
,
i
);
if
(
i
<
0
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_CORRUPT
,
"Not a map: {0}"
,
s
);
}
final
String
key
=
s
.
substring
(
startKey
,
i
++);
final
int
startValue
=
i
;
while
(
i
<
size
)
{
char
c
=
s
.
charAt
(
i
++);
if
(
c
==
','
)
{
break
;
}
else
if
(
c
==
'\"'
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_CORRUPT
,
"there should be not quoted chars in this map: {0}"
,
s
);
}
}
final
String
val
=
s
.
substring
(
startValue
,
i
);
if
(
key
.
equals
(
"block"
))
{
block
=
DataUtils
.
parseHexLong
(
val
);
}
else
if
(
key
.
equals
(
"chunk"
))
{
id
=
DataUtils
.
parseHexInt
(
val
);
}
else
if
(
key
.
equals
(
"len"
))
{
len
=
DataUtils
.
parseHexInt
(
val
);
}
else
if
(
key
.
equals
(
"pages"
))
{
pageCount
=
DataUtils
.
parseHexInt
(
val
);
}
else
if
(
key
.
equals
(
"livePages"
))
{
livePages
=
DataUtils
.
parseHexInt
(
val
);
}
else
if
(
key
.
equals
(
"map"
))
{
mapId
=
DataUtils
.
parseHexInt
(
val
);
}
else
if
(
key
.
equals
(
"max"
))
{
maxLen
=
DataUtils
.
parseHexInt
(
val
);
}
else
if
(
key
.
equals
(
"liveMax"
))
{
maxLenLive
=
DataUtils
.
parseHexLong
(
val
);
}
else
if
(
key
.
equals
(
"root"
))
{
metaRootPos
=
DataUtils
.
parseHexLong
(
val
);
}
else
if
(
key
.
equals
(
"time"
))
{
time
=
DataUtils
.
parseHexLong
(
val
);
}
else
if
(
key
.
equals
(
"unused"
))
{
unused
=
DataUtils
.
parseHexLong
(
val
);
}
else
if
(
key
.
equals
(
"unused"
))
{
unused
=
DataUtils
.
parseHexLong
(
val
);
}
else
if
(
key
.
equals
(
"version"
))
{
version
=
DataUtils
.
parseHexLong
(
val
);
}
else
if
(
key
.
equals
(
"next"
))
{
next
=
DataUtils
.
parseHexLong
(
val
);
}
else
if
(
SysProperties
.
CHECK
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_CORRUPT
,
"unknown key in this map: {0}"
,
s
);
}
}
final
Chunk
chunk
=
new
Chunk
(
id
);
chunk
.
block
=
block
;
chunk
.
len
=
len
;
chunk
.
pageCount
=
pageCount
;
chunk
.
pageCountLive
=
livePages
==
null
?
pageCount
:
livePages
;
chunk
.
mapId
=
mapId
;
chunk
.
maxLen
=
maxLen
;
chunk
.
maxLenLive
=
maxLenLive
==
null
?
maxLen
:
maxLenLive
;
chunk
.
metaRootPos
=
metaRootPos
;
chunk
.
time
=
time
;
chunk
.
unused
=
unused
;
chunk
.
version
=
version
;
chunk
.
next
=
next
;
return
chunk
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论