Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
72a556e8
提交
72a556e8
authored
9月 16, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make FindBugs happy
上级
f7352ac0
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
36 行增加
和
16 行删除
+36
-16
FileObjectMemory.java
h2/src/main/org/h2/store/fs/FileObjectMemory.java
+10
-13
FileSystemDisk.java
h2/src/main/org/h2/store/fs/FileSystemDisk.java
+2
-2
FileUtils.java
h2/src/main/org/h2/util/FileUtils.java
+23
-0
CompareMode.java
h2/src/main/org/h2/value/CompareMode.java
+1
-1
没有找到文件。
h2/src/main/org/h2/store/fs/FileObjectMemory.java
浏览文件 @
72a556e8
...
...
@@ -25,7 +25,7 @@ public class FileObjectMemory implements FileObject {
private
static
final
int
BLOCK_SIZE_MASK
=
BLOCK_SIZE
-
1
;
private
static
final
CompressLZF
LZF
=
new
CompressLZF
();
private
static
final
byte
[]
BUFFER
=
new
byte
[
BLOCK_SIZE
*
2
];
private
static
byte
[]
cachedCompressedEmptyBlock
;
private
static
final
byte
[]
COMPRESSED_EMPTY_BLOCK
;
//## Java 1.4 begin ##
private
static
final
Cache
<
CompressItem
,
CompressItem
>
COMPRESS_LATER
=
new
Cache
<
CompressItem
,
CompressItem
>(
CACHE_SIZE
);
...
...
@@ -38,6 +38,13 @@ public class FileObjectMemory implements FileObject {
private
byte
[][]
data
;
private
long
lastModified
;
static
{
byte
[]
n
=
new
byte
[
BLOCK_SIZE
];
int
len
=
LZF
.
compress
(
n
,
BLOCK_SIZE
,
BUFFER
,
0
);
COMPRESSED_EMPTY_BLOCK
=
new
byte
[
len
];
System
.
arraycopy
(
BUFFER
,
0
,
COMPRESSED_EMPTY_BLOCK
,
0
,
len
);
}
/**
* This small cache compresses the data if an element leaves the cache.
*/
...
...
@@ -77,7 +84,7 @@ public class FileObjectMemory implements FileObject {
int
page
;
public
int
hashCode
()
{
return
data
.
hashCode
()
^
page
;
return
page
;
}
public
boolean
equals
(
Object
o
)
{
...
...
@@ -138,16 +145,6 @@ public class FileObjectMemory implements FileObject {
}
}
static
byte
[]
getCompressedEmptyBlock
()
{
if
(
cachedCompressedEmptyBlock
==
null
)
{
byte
[]
n
=
new
byte
[
BLOCK_SIZE
];
int
len
=
LZF
.
compress
(
n
,
BLOCK_SIZE
,
BUFFER
,
0
);
cachedCompressedEmptyBlock
=
new
byte
[
len
];
System
.
arraycopy
(
BUFFER
,
0
,
cachedCompressedEmptyBlock
,
0
,
len
);
}
return
cachedCompressedEmptyBlock
;
}
private
void
touch
()
{
lastModified
=
System
.
currentTimeMillis
();
}
...
...
@@ -190,7 +187,7 @@ public class FileObjectMemory implements FileObject {
byte
[][]
n
=
new
byte
[
blocks
][];
System
.
arraycopy
(
data
,
0
,
n
,
0
,
Math
.
min
(
data
.
length
,
n
.
length
));
for
(
int
i
=
data
.
length
;
i
<
blocks
;
i
++)
{
n
[
i
]
=
getCompressedEmptyBlock
()
;
n
[
i
]
=
COMPRESSED_EMPTY_BLOCK
;
}
data
=
n
;
}
...
...
h2/src/main/org/h2/store/fs/FileSystemDisk.java
浏览文件 @
72a556e8
...
...
@@ -167,7 +167,7 @@ public class FileSystemDisk extends FileSystem {
dir
=
null
;
}
else
{
dir
=
new
File
(
name
).
getAbsoluteFile
().
getParentFile
();
dir
.
mkdirs
(
);
FileUtils
.
mkdirs
(
dir
);
}
if
(
prefix
.
length
()
<
3
)
{
prefix
+=
"0"
;
...
...
@@ -304,7 +304,7 @@ public class FileSystemDisk extends FileSystem {
}
File
dir
=
new
File
(
parent
);
for
(
int
i
=
0
;
i
<
SysProperties
.
MAX_FILE_RETRY
;
i
++)
{
if
(
dir
.
exists
(
)
||
dir
.
mkdirs
())
{
if
(
(
dir
.
exists
()
&&
dir
.
isDirectory
()
)
||
dir
.
mkdirs
())
{
return
;
}
wait
(
i
);
...
...
h2/src/main/org/h2/util/FileUtils.java
浏览文件 @
72a556e8
...
...
@@ -27,6 +27,29 @@ public class FileUtils {
// utility class
}
/**
* Create the directory and all parent directories if required.
*
* @param directory the directory
* @throws IOException
*/
public
static
void
mkdirs
(
File
directory
)
throws
IOException
{
// loop, to deal with race conditions (if another thread creates or
// deletes the same directory at the same time).
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
if
(
directory
.
exists
())
{
if
(
directory
.
isDirectory
())
{
return
;
}
throw
new
IOException
(
"Could not create directory, because a file with the same name already exists: "
+
directory
.
getAbsolutePath
());
}
if
(
directory
.
mkdirs
())
{
return
;
}
}
throw
new
IOException
(
"Could not create directory: "
+
directory
.
getAbsolutePath
());
}
/**
* Change the length of the file.
*
...
...
h2/src/main/org/h2/value/CompareMode.java
浏览文件 @
72a556e8
...
...
@@ -60,7 +60,7 @@ public class CompareMode {
* @param strength the collation strength
* @return the compare mode
*/
public
static
CompareMode
getInstance
(
String
name
,
int
strength
)
{
public
static
synchronized
CompareMode
getInstance
(
String
name
,
int
strength
)
{
if
(
lastUsed
!=
null
)
{
if
(
StringUtils
.
equals
(
lastUsed
.
name
,
name
))
{
if
(
lastUsed
.
strength
==
strength
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论