Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
844f4f49
提交
844f4f49
authored
6 年前
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
read multiple child pages in parallel
上级
0a5b618f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
45 行增加
和
13 行删除
+45
-13
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+23
-6
Page.java
h2/src/main/org/h2/mvstore/Page.java
+22
-7
没有找到文件。
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
844f4f49
...
...
@@ -5,6 +5,7 @@
*/
package
org
.
h2
.
mvstore
;
import
static
org
.
h2
.
mvstore
.
MVMap
.
INITIAL_VERSION
;
import
java.lang.Thread.UncaughtExceptionHandler
;
import
java.nio.ByteBuffer
;
import
java.nio.charset.StandardCharsets
;
...
...
@@ -17,11 +18,17 @@ import java.util.HashMap;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.PriorityQueue
;
import
java.util.Queue
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicLong
;
...
...
@@ -30,9 +37,9 @@ import org.h2.compress.CompressDeflate;
import
org.h2.compress.CompressLZF
;
import
org.h2.compress.Compressor
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.cache.CacheLongKeyLIRS
;
import
org.h2.util.MathUtils
;
import
static
org
.
h2
.
mvstore
.
MVMap
.
INITIAL_VERSION
;
import
org.h2.util.Utils
;
/*
...
...
@@ -1374,10 +1381,11 @@ public class MVStore {
return
collector
.
getReferenced
();
}
final
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
final
class
ChunkIdsCollector
{
private
final
Set
<
Integer
>
referencedChunks
=
new
HashSet
<>
();
private
final
Set
<
Integer
>
referencedChunks
=
ConcurrentHashMap
.
newKeySet
();
private
final
ChunkIdsCollector
parent
;
private
int
mapId
;
...
...
@@ -1454,12 +1462,21 @@ public class MVStore {
long
filePos
=
chunk
.
block
*
BLOCK_SIZE
;
filePos
+=
DataUtils
.
getPageOffset
(
pos
);
if
(
filePos
<
0
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_CORRUPT
,
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_CORRUPT
,
"Negative position {0}; p={1}, c={2}"
,
filePos
,
pos
,
chunk
.
toString
());
}
long
maxPos
=
(
chunk
.
block
+
chunk
.
len
)
*
BLOCK_SIZE
;
Page
.
readChildrenPositions
(
fileStore
,
pos
,
filePos
,
maxPos
,
childCollector
);
final
List
<
Future
<?>>
futures
=
Page
.
readChildrenPositions
(
fileStore
,
pos
,
filePos
,
maxPos
,
childCollector
,
executorService
);
for
(
Future
<?>
f
:
futures
)
{
try
{
f
.
get
();
}
catch
(
InterruptedException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
catch
(
ExecutionException
ex
)
{
throw
DbException
.
convert
(
ex
);
}
}
}
// and cache resulting set of chunk ids
if
(
cacheChunkRef
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
844f4f49
...
...
@@ -5,15 +5,20 @@
*/
package
org
.
h2
.
mvstore
;
import
static
org
.
h2
.
engine
.
Constants
.
MEMORY_ARRAY
;
import
static
org
.
h2
.
engine
.
Constants
.
MEMORY_OBJECT
;
import
static
org
.
h2
.
engine
.
Constants
.
MEMORY_POINTER
;
import
static
org
.
h2
.
mvstore
.
DataUtils
.
PAGE_TYPE_LEAF
;
import
java.nio.ByteBuffer
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ForkJoinPool
;
import
java.util.concurrent.Future
;
import
org.h2.compress.Compressor
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.util.Utils
;
import
static
org
.
h2
.
engine
.
Constants
.
MEMORY_ARRAY
;
import
static
org
.
h2
.
engine
.
Constants
.
MEMORY_OBJECT
;
import
static
org
.
h2
.
engine
.
Constants
.
MEMORY_POINTER
;
import
static
org
.
h2
.
mvstore
.
DataUtils
.
PAGE_TYPE_LEAF
;
/**
* A page (a node or a leaf).
...
...
@@ -247,9 +252,10 @@ public abstract class Page implements Cloneable
* @param maxPos the maximum position (the end of the chunk)
* @param collector to report child pages positions to
*/
static
void
readChildrenPositions
(
FileStore
fileStore
,
long
pos
,
static
List
<
Future
<?>>
readChildrenPositions
(
FileStore
fileStore
,
long
pos
,
long
filePos
,
long
maxPos
,
MVStore
.
ChunkIdsCollector
collector
)
{
MVStore
.
ChunkIdsCollector
collector
,
ExecutorService
executorService
)
{
ByteBuffer
buff
;
int
maxLength
=
DataUtils
.
getPageMaxLength
(
pos
);
if
(
maxLength
==
DataUtils
.
PAGE_LARGE
)
{
...
...
@@ -302,9 +308,18 @@ public abstract class Page implements Cloneable
DataUtils
.
ERROR_FILE_CORRUPT
,
"Position {0} expected to be a non-leaf"
,
pos
);
}
final
List
<
Future
<?>>
futures
=
new
ArrayList
<>(
len
);
for
(
int
i
=
0
;
i
<=
len
;
i
++)
{
collector
.
visit
(
buff
.
getLong
());
final
long
childPagePos
=
buff
.
getLong
();
Future
<?>
f
=
executorService
.
submit
(
new
Runnable
()
{
@Override
public
void
run
()
{
collector
.
visit
(
childPagePos
);
}
});
futures
.
add
(
f
);
}
return
futures
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论