Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
453dbd2e
提交
453dbd2e
authored
5月 04, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass custom closeable to TempFileDeleter to close the store too
上级
73ef660f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
31 行增加
和
6 行删除
+31
-6
MVTempResult.java
h2/src/main/org/h2/mvstore/db/MVTempResult.java
+31
-6
没有找到文件。
h2/src/main/org/h2/mvstore/db/MVTempResult.java
浏览文件 @
453dbd2e
...
@@ -33,6 +33,30 @@ import org.h2.value.Value;
...
@@ -33,6 +33,30 @@ import org.h2.value.Value;
*/
*/
public
abstract
class
MVTempResult
implements
ResultExternal
{
public
abstract
class
MVTempResult
implements
ResultExternal
{
private
static
final
class
CloseImpl
implements
AutoCloseable
{
/**
* MVStore.
*/
private
final
MVStore
store
;
/**
* File name.
*/
private
final
String
fileName
;
CloseImpl
(
MVStore
store
,
String
fileName
)
{
this
.
store
=
store
;
this
.
fileName
=
fileName
;
}
@Override
public
void
close
()
throws
Exception
{
store
.
closeImmediately
();
FileUtils
.
tryDelete
(
fileName
);
}
}
/**
/**
* Creates MVStore-based temporary result.
* Creates MVStore-based temporary result.
*
*
...
@@ -82,9 +106,9 @@ public abstract class MVTempResult implements ResultExternal {
...
@@ -82,9 +106,9 @@ public abstract class MVTempResult implements ResultExternal {
private
final
TempFileDeleter
tempFileDeleter
;
private
final
TempFileDeleter
tempFileDeleter
;
/**
/**
*
Name of the temporary fil
e.
*
Closeable to close the storag
e.
*/
*/
private
final
String
fileNam
e
;
private
final
CloseImpl
closeabl
e
;
/**
/**
* Reference to the record in the temporary file deleter.
* Reference to the record in the temporary file deleter.
...
@@ -100,8 +124,8 @@ public abstract class MVTempResult implements ResultExternal {
...
@@ -100,8 +124,8 @@ public abstract class MVTempResult implements ResultExternal {
MVTempResult
(
MVTempResult
parent
)
{
MVTempResult
(
MVTempResult
parent
)
{
this
.
parent
=
parent
;
this
.
parent
=
parent
;
this
.
store
=
parent
.
store
;
this
.
store
=
parent
.
store
;
this
.
fileName
=
null
;
this
.
tempFileDeleter
=
null
;
this
.
tempFileDeleter
=
null
;
this
.
closeable
=
null
;
this
.
fileRef
=
null
;
this
.
fileRef
=
null
;
}
}
...
@@ -113,7 +137,7 @@ public abstract class MVTempResult implements ResultExternal {
...
@@ -113,7 +137,7 @@ public abstract class MVTempResult implements ResultExternal {
*/
*/
MVTempResult
(
Session
session
)
{
MVTempResult
(
Session
session
)
{
try
{
try
{
fileName
=
FileUtils
.
createTempFile
(
"h2tmp"
,
Constants
.
SUFFIX_TEMP_FILE
,
false
,
true
);
String
fileName
=
FileUtils
.
createTempFile
(
"h2tmp"
,
Constants
.
SUFFIX_TEMP_FILE
,
false
,
true
);
Builder
builder
=
new
MVStore
.
Builder
().
fileName
(
fileName
);
Builder
builder
=
new
MVStore
.
Builder
().
fileName
(
fileName
);
byte
[]
key
=
session
.
getDatabase
().
getFileEncryptionKey
();
byte
[]
key
=
session
.
getDatabase
().
getFileEncryptionKey
();
if
(
key
!=
null
)
{
if
(
key
!=
null
)
{
...
@@ -121,7 +145,8 @@ public abstract class MVTempResult implements ResultExternal {
...
@@ -121,7 +145,8 @@ public abstract class MVTempResult implements ResultExternal {
}
}
store
=
builder
.
open
();
store
=
builder
.
open
();
tempFileDeleter
=
session
.
getDatabase
().
getTempFileDeleter
();
tempFileDeleter
=
session
.
getDatabase
().
getTempFileDeleter
();
fileRef
=
tempFileDeleter
.
addFile
(
fileName
,
this
);
closeable
=
new
CloseImpl
(
store
,
fileName
);
fileRef
=
tempFileDeleter
.
addFile
(
closeable
,
this
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convert
(
e
);
throw
DbException
.
convert
(
e
);
}
}
...
@@ -159,7 +184,7 @@ public abstract class MVTempResult implements ResultExternal {
...
@@ -159,7 +184,7 @@ public abstract class MVTempResult implements ResultExternal {
private
void
delete
()
{
private
void
delete
()
{
store
.
closeImmediately
();
store
.
closeImmediately
();
tempFileDeleter
.
deleteFile
(
fileRef
,
fileNam
e
);
tempFileDeleter
.
deleteFile
(
fileRef
,
closeabl
e
);
}
}
@Override
@Override
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论