Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
983b9fe9
提交
983b9fe9
authored
11月 29, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A persistent multi-version map: move to the main source tree
上级
4c34bc07
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
0 行增加
和
2166 行删除
+0
-2166
CacheLIRS.java
h2/src/tools/org/h2/dev/store/cache/CacheLIRS.java
+0
-979
CacheLongKeyLIRS.java
h2/src/tools/org/h2/dev/store/cache/CacheLongKeyLIRS.java
+0
-1038
FilePathCache.java
h2/src/tools/org/h2/dev/store/cache/FilePathCache.java
+0
-134
package.html
h2/src/tools/org/h2/dev/store/cache/package.html
+0
-15
没有找到文件。
h2/src/tools/org/h2/dev/store/cache/CacheLIRS.java
deleted
100644 → 0
浏览文件 @
4c34bc07
差异被折叠。
点击展开。
h2/src/tools/org/h2/dev/store/cache/CacheLongKeyLIRS.java
deleted
100644 → 0
浏览文件 @
4c34bc07
差异被折叠。
点击展开。
h2/src/tools/org/h2/dev/store/cache/FilePathCache.java
deleted
100644 → 0
浏览文件 @
4c34bc07
/*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
dev
.
store
.
cache
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileLock
;
import
org.h2.store.fs.FileBase
;
import
org.h2.store.fs.FilePathWrapper
;
/**
* A file with a read cache.
*/
public
class
FilePathCache
extends
FilePathWrapper
{
public
static
FileChannel
wrap
(
FileChannel
f
)
{
return
new
FileCache
(
f
);
}
public
FileChannel
open
(
String
mode
)
throws
IOException
{
return
new
FileCache
(
getBase
().
open
(
mode
));
}
public
String
getScheme
()
{
return
"cache"
;
}
/**
* A file with a read cache.
*/
public
static
class
FileCache
extends
FileBase
{
private
static
final
int
CACHE_BLOCK_SIZE
=
4
*
1024
;
private
final
FileChannel
base
;
// 1 MB (256 * 4 * 1024)
private
final
CacheLongKeyLIRS
<
ByteBuffer
>
cache
=
CacheLongKeyLIRS
.
newInstance
(
256
);
FileCache
(
FileChannel
base
)
{
this
.
base
=
base
;
}
protected
void
implCloseChannel
()
throws
IOException
{
base
.
close
();
}
public
FileChannel
position
(
long
newPosition
)
throws
IOException
{
base
.
position
(
newPosition
);
return
this
;
}
public
long
position
()
throws
IOException
{
return
base
.
position
();
}
public
int
read
(
ByteBuffer
dst
)
throws
IOException
{
return
base
.
read
(
dst
);
}
public
int
read
(
ByteBuffer
dst
,
long
position
)
throws
IOException
{
long
cachePos
=
getCachePos
(
position
);
int
off
=
(
int
)
(
position
-
cachePos
);
int
len
=
CACHE_BLOCK_SIZE
-
off
;
ByteBuffer
buff
=
cache
.
get
(
cachePos
);
if
(
buff
==
null
)
{
buff
=
ByteBuffer
.
allocate
(
CACHE_BLOCK_SIZE
);
int
read
=
base
.
read
(
buff
,
cachePos
);
if
(
read
==
CACHE_BLOCK_SIZE
)
{
cache
.
put
(
cachePos
,
buff
);
}
else
{
if
(
read
<
0
)
{
return
-
1
;
}
len
=
Math
.
min
(
len
,
read
);
}
}
len
=
Math
.
min
(
len
,
dst
.
remaining
());
System
.
arraycopy
(
buff
.
array
(),
off
,
dst
.
array
(),
dst
.
position
(),
len
);
dst
.
position
(
dst
.
position
()
+
len
);
return
len
;
}
private
static
long
getCachePos
(
long
pos
)
{
return
(
pos
/
CACHE_BLOCK_SIZE
)
*
CACHE_BLOCK_SIZE
;
}
public
long
size
()
throws
IOException
{
return
base
.
size
();
}
public
FileChannel
truncate
(
long
newSize
)
throws
IOException
{
cache
.
clear
();
base
.
truncate
(
newSize
);
return
this
;
}
public
int
write
(
ByteBuffer
src
,
long
position
)
throws
IOException
{
if
(
cache
.
size
()
>
0
)
{
int
len
=
src
.
remaining
();
long
p
=
getCachePos
(
position
);
while
(
len
>
0
)
{
cache
.
remove
(
p
);
p
+=
CACHE_BLOCK_SIZE
;
len
-=
CACHE_BLOCK_SIZE
;
}
}
return
base
.
write
(
src
,
position
);
}
public
int
write
(
ByteBuffer
src
)
throws
IOException
{
throw
new
UnsupportedOperationException
();
// return base.write(src);
}
public
void
force
(
boolean
metaData
)
throws
IOException
{
base
.
force
(
metaData
);
}
public
FileLock
tryLock
(
long
position
,
long
size
,
boolean
shared
)
throws
IOException
{
return
base
.
tryLock
(
position
,
size
,
shared
);
}
public
String
toString
()
{
return
"cache:"
+
base
.
toString
();
}
}
}
h2/src/tools/org/h2/dev/store/cache/package.html
deleted
100644 → 0
浏览文件 @
4c34bc07
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License, Version 1.0,
and under the Eclipse Public License, Version 1.0
(http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
<head><meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/><title>
Javadoc package documentation
</title></head><body
style=
"font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"
><p>
Classes related to caching.
</p></body></html>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论