Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ead2f7ad
提交
ead2f7ad
authored
1月 23, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved order of file operations
上级
422c8dc8
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
36 行增加
和
12 行删除
+36
-12
FileStore.java
h2/src/main/org/h2/mvstore/FileStore.java
+1
-1
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+8
-0
FilePathDisk.java
h2/src/main/org/h2/store/fs/FilePathDisk.java
+7
-8
FilePathEncrypt.java
h2/src/main/org/h2/store/fs/FilePathEncrypt.java
+20
-3
没有找到文件。
h2/src/main/org/h2/mvstore/FileStore.java
浏览文件 @
ead2f7ad
...
@@ -138,7 +138,6 @@ public class FileStore {
...
@@ -138,7 +138,6 @@ public class FileStore {
file
=
new
FilePathEncrypt
.
FileEncrypt
(
fileName
,
key
,
file
);
file
=
new
FilePathEncrypt
.
FileEncrypt
(
fileName
,
key
,
file
);
}
}
file
=
FilePathCache
.
wrap
(
file
);
file
=
FilePathCache
.
wrap
(
file
);
fileSize
=
file
.
size
();
try
{
try
{
if
(
readOnly
)
{
if
(
readOnly
)
{
fileLock
=
file
.
tryLock
(
0
,
Long
.
MAX_VALUE
,
true
);
fileLock
=
file
.
tryLock
(
0
,
Long
.
MAX_VALUE
,
true
);
...
@@ -153,6 +152,7 @@ public class FileStore {
...
@@ -153,6 +152,7 @@ public class FileStore {
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_LOCKED
,
"The file is locked: {0}"
,
fileName
);
DataUtils
.
ERROR_FILE_LOCKED
,
"The file is locked: {0}"
,
fileName
);
}
}
fileSize
=
file
.
size
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_READING_FAILED
,
DataUtils
.
ERROR_READING_FAILED
,
...
...
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
ead2f7ad
...
@@ -406,6 +406,14 @@ public class MVTable extends TableBase {
...
@@ -406,6 +406,14 @@ public class MVTable extends TableBase {
}
}
if
(
index
.
needRebuild
())
{
if
(
index
.
needRebuild
())
{
try
{
try
{
// TODO Speed up creating an index, for example as follows: Read
// up to about 1 MB of entries in memory, sort them (detect
// duplicates here), write to a new map (in sorted order);
// repeat (using a new map for every block of 1 MB) until all
// record are read. Merge all maps to the target (using merge
// sort; duplicates are detected in the target). This is similar
// to a LSM tree. For randomly ordered data, this should use
// much less write operations than the current algorithm.
Index
scan
=
getScanIndex
(
session
);
Index
scan
=
getScanIndex
(
session
);
long
remaining
=
scan
.
getRowCount
(
session
);
long
remaining
=
scan
.
getRowCount
(
session
);
long
total
=
remaining
;
long
total
=
remaining
;
...
...
h2/src/main/org/h2/store/fs/FilePathDisk.java
浏览文件 @
ead2f7ad
...
@@ -245,16 +245,15 @@ public class FilePathDisk extends FilePath {
...
@@ -245,16 +245,15 @@ public class FilePathDisk extends FilePath {
@Override
@Override
public
void
createDirectory
()
{
public
void
createDirectory
()
{
File
f
=
new
File
(
name
);
if
(
f
.
exists
())
{
if
(
f
.
isDirectory
())
{
return
;
}
throw
DbException
.
get
(
ErrorCode
.
FILE_CREATION_FAILED_1
,
name
+
" (a file with this name already exists)"
);
}
File
dir
=
new
File
(
name
);
File
dir
=
new
File
(
name
);
for
(
int
i
=
0
;
i
<
SysProperties
.
MAX_FILE_RETRY
;
i
++)
{
for
(
int
i
=
0
;
i
<
SysProperties
.
MAX_FILE_RETRY
;
i
++)
{
if
((
dir
.
exists
()
&&
dir
.
isDirectory
())
||
dir
.
mkdir
())
{
if
(
dir
.
exists
())
{
if
(
dir
.
isDirectory
())
{
return
;
}
throw
DbException
.
get
(
ErrorCode
.
FILE_CREATION_FAILED_1
,
name
+
" (a file with this name already exists)"
);
}
else
if
(
dir
.
mkdir
())
{
return
;
return
;
}
}
wait
(
i
);
wait
(
i
);
...
...
h2/src/main/org/h2/store/fs/FilePathEncrypt.java
浏览文件 @
ead2f7ad
...
@@ -157,8 +157,6 @@ public class FilePathEncrypt extends FilePathWrapper {
...
@@ -157,8 +157,6 @@ public class FilePathEncrypt extends FilePathWrapper {
private
final
FileChannel
base
;
private
final
FileChannel
base
;
private
final
XTS
xts
;
/**
/**
* The current position within the file, from a user perspective.
* The current position within the file, from a user perspective.
*/
*/
...
@@ -171,9 +169,23 @@ public class FilePathEncrypt extends FilePathWrapper {
...
@@ -171,9 +169,23 @@ public class FilePathEncrypt extends FilePathWrapper {
private
final
String
name
;
private
final
String
name
;
public
FileEncrypt
(
String
name
,
byte
[]
encryptionKey
,
FileChannel
base
)
throws
IOException
{
private
XTS
xts
;
private
byte
[]
encryptionKey
;
public
FileEncrypt
(
String
name
,
byte
[]
encryptionKey
,
FileChannel
base
)
{
// don't do any read or write operations here, because they could
// fail if the file is locked, and we want to give the caller a
// chance to lock the file first
this
.
name
=
name
;
this
.
name
=
name
;
this
.
base
=
base
;
this
.
base
=
base
;
this
.
encryptionKey
=
encryptionKey
;
}
private
void
init
()
throws
IOException
{
if
(
xts
!=
null
)
{
return
;
}
this
.
size
=
base
.
size
()
-
HEADER_LENGTH
;
this
.
size
=
base
.
size
()
-
HEADER_LENGTH
;
boolean
newFile
=
size
<
0
;
boolean
newFile
=
size
<
0
;
byte
[]
salt
;
byte
[]
salt
;
...
@@ -192,6 +204,7 @@ public class FilePathEncrypt extends FilePathWrapper {
...
@@ -192,6 +204,7 @@ public class FilePathEncrypt extends FilePathWrapper {
}
}
AES
cipher
=
new
AES
();
AES
cipher
=
new
AES
();
cipher
.
setKey
(
SHA256
.
getPBKDF2
(
encryptionKey
,
salt
,
HASH_ITERATIONS
,
16
));
cipher
.
setKey
(
SHA256
.
getPBKDF2
(
encryptionKey
,
salt
,
HASH_ITERATIONS
,
16
));
encryptionKey
=
null
;
xts
=
new
XTS
(
cipher
);
xts
=
new
XTS
(
cipher
);
}
}
...
@@ -226,6 +239,7 @@ public class FilePathEncrypt extends FilePathWrapper {
...
@@ -226,6 +239,7 @@ public class FilePathEncrypt extends FilePathWrapper {
if
(
len
==
0
)
{
if
(
len
==
0
)
{
return
0
;
return
0
;
}
}
init
();
len
=
(
int
)
Math
.
min
(
len
,
size
-
position
);
len
=
(
int
)
Math
.
min
(
len
,
size
-
position
);
if
(
position
>=
size
)
{
if
(
position
>=
size
)
{
return
-
1
;
return
-
1
;
...
@@ -274,6 +288,7 @@ public class FilePathEncrypt extends FilePathWrapper {
...
@@ -274,6 +288,7 @@ public class FilePathEncrypt extends FilePathWrapper {
@Override
@Override
public
int
write
(
ByteBuffer
src
,
long
position
)
throws
IOException
{
public
int
write
(
ByteBuffer
src
,
long
position
)
throws
IOException
{
init
();
int
len
=
src
.
remaining
();
int
len
=
src
.
remaining
();
if
((
position
&
BLOCK_SIZE_MASK
)
!=
0
||
if
((
position
&
BLOCK_SIZE_MASK
)
!=
0
||
(
len
&
BLOCK_SIZE_MASK
)
!=
0
)
{
(
len
&
BLOCK_SIZE_MASK
)
!=
0
)
{
...
@@ -343,11 +358,13 @@ public class FilePathEncrypt extends FilePathWrapper {
...
@@ -343,11 +358,13 @@ public class FilePathEncrypt extends FilePathWrapper {
@Override
@Override
public
long
size
()
throws
IOException
{
public
long
size
()
throws
IOException
{
init
();
return
size
;
return
size
;
}
}
@Override
@Override
public
FileChannel
truncate
(
long
newSize
)
throws
IOException
{
public
FileChannel
truncate
(
long
newSize
)
throws
IOException
{
init
();
if
(
newSize
>
size
)
{
if
(
newSize
>
size
)
{
return
this
;
return
this
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论