Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
fdc5aa12
提交
fdc5aa12
authored
10月 13, 2016
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename FileOperation to FileWriteOperation
上级
8959c4f3
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
11 行删除
+10
-11
FilePathReorderWrites.java
h2/src/test/org/h2/test/utils/FilePathReorderWrites.java
+10
-11
没有找到文件。
h2/src/test/org/h2/test/utils/FilePathReorderWrites.java
浏览文件 @
fdc5aa12
...
...
@@ -13,7 +13,6 @@ import java.nio.channels.FileChannel;
import
java.nio.channels.FileLock
;
import
java.util.ArrayList
;
import
java.util.Random
;
import
org.h2.store.fs.FileBase
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FilePathWrapper
;
...
...
@@ -163,7 +162,7 @@ class FileReorderWrites extends FileBase {
/**
* The list of not yet applied to the base channel. It is sorted by time.
*/
private
ArrayList
<
File
Operation
>
notAppliedList
=
new
ArrayList
<
Fil
eOperation
>();
private
ArrayList
<
File
WriteOperation
>
notAppliedList
=
new
ArrayList
<
FileWrit
eOperation
>();
private
int
id
;
...
...
@@ -212,17 +211,17 @@ class FileReorderWrites extends FileBase {
if
(
oldSize
<=
newSize
)
{
return
this
;
}
addOperation
(
new
FileOperation
(
id
++,
newSize
,
null
));
addOperation
(
new
File
Write
Operation
(
id
++,
newSize
,
null
));
return
this
;
}
private
int
addOperation
(
FileOperation
op
)
throws
IOException
{
private
int
addOperation
(
File
Write
Operation
op
)
throws
IOException
{
trace
(
"op "
+
op
);
checkError
();
notAppliedList
.
add
(
op
);
long
now
=
op
.
getTime
();
for
(
int
i
=
0
;
i
<
notAppliedList
.
size
()
-
1
;
i
++)
{
FileOperation
old
=
notAppliedList
.
get
(
i
);
File
Write
Operation
old
=
notAppliedList
.
get
(
i
);
boolean
applyOld
=
false
;
// String reason = "";
if
(
old
.
getTime
()
+
45000
<
now
)
{
...
...
@@ -247,7 +246,7 @@ class FileReorderWrites extends FileBase {
private
void
applyAll
()
throws
IOException
{
trace
(
"applyAll"
);
for
(
FileOperation
op
:
notAppliedList
)
{
for
(
File
Write
Operation
op
:
notAppliedList
)
{
op
.
apply
(
base
);
}
notAppliedList
.
clear
();
...
...
@@ -262,12 +261,12 @@ class FileReorderWrites extends FileBase {
@Override
public
int
write
(
ByteBuffer
src
)
throws
IOException
{
return
addOperation
(
new
FileOperation
(
id
++,
readBase
.
position
(),
src
));
return
addOperation
(
new
File
Write
Operation
(
id
++,
readBase
.
position
(),
src
));
}
@Override
public
int
write
(
ByteBuffer
src
,
long
position
)
throws
IOException
{
return
addOperation
(
new
FileOperation
(
id
++,
position
,
src
));
return
addOperation
(
new
File
Write
Operation
(
id
++,
position
,
src
));
}
private
void
checkError
()
throws
IOException
{
...
...
@@ -298,13 +297,13 @@ class FileReorderWrites extends FileBase {
* A file operation (that might be re-ordered with other operations, or not
* be applied on power failure).
*/
static
class
FileOperation
{
static
class
File
Write
Operation
{
private
final
int
id
;
private
final
long
time
;
private
final
ByteBuffer
buffer
;
private
final
long
position
;
FileOperation
(
int
id
,
long
position
,
ByteBuffer
src
)
{
File
Write
Operation
(
int
id
,
long
position
,
ByteBuffer
src
)
{
this
.
id
=
id
;
this
.
time
=
System
.
currentTimeMillis
();
if
(
src
==
null
)
{
...
...
@@ -329,7 +328,7 @@ class FileReorderWrites extends FileBase {
* @param other the other operation
* @return if there is an overlap
*/
boolean
overlaps
(
FileOperation
other
)
{
boolean
overlaps
(
File
Write
Operation
other
)
{
if
(
isTruncate
()
&&
other
.
isTruncate
())
{
// we just keep the latest truncate operation
return
true
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论