Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4cd69931
提交
4cd69931
authored
1月 22, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bugfixes, trace
上级
2505065e
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
37 行增加
和
4 行删除
+37
-4
LobStorageMap.java
h2/src/main/org/h2/store/LobStorageMap.java
+37
-4
没有找到文件。
h2/src/main/org/h2/store/LobStorageMap.java
浏览文件 @
4cd69931
...
...
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import
java.util.Arrays
;
import
java.util.Map.Entry
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.message.DbException
;
...
...
@@ -34,6 +35,8 @@ import org.h2.value.ValueLobDb;
*/
public
class
LobStorageMap
implements
LobStorageInterface
{
private
static
final
boolean
TRACE
=
false
;
private
final
Database
database
;
private
boolean
init
;
...
...
@@ -92,6 +95,8 @@ public class LobStorageMap implements LobStorageInterface {
dataMap
=
mvStore
.
openMap
(
"lobData"
,
new
MVMapConcurrent
.
Builder
<
Long
,
byte
[]>());
streamStore
=
new
StreamStore
(
dataMap
);
// TODO currently needed to avoid out of memory
streamStore
.
setMaxBlockSize
(
32
*
1024
);
}
@Override
...
...
@@ -118,6 +123,8 @@ public class LobStorageMap implements LobStorageInterface {
in
=
b
;
}
return
createLob
(
in
,
type
);
}
catch
(
IllegalStateException
e
)
{
throw
DbException
.
get
(
ErrorCode
.
OBJECT_CLOSED
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
null
);
}
...
...
@@ -152,6 +159,8 @@ public class LobStorageMap implements LobStorageInterface {
// the length is not correct
lob
=
ValueLobDb
.
create
(
type
,
database
,
lob
.
getTableId
(),
lob
.
getLobId
(),
null
,
in
.
getLength
());
return
lob
;
}
catch
(
IllegalStateException
e
)
{
throw
DbException
.
get
(
ErrorCode
.
OBJECT_CLOSED
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
null
);
}
...
...
@@ -164,7 +173,7 @@ public class LobStorageMap implements LobStorageInterface {
}
catch
(
Exception
e
)
{
throw
DbException
.
convertToIOException
(
e
);
}
long
lobId
=
streamStore
.
getAndIncrementNextKey
();
long
lobId
=
generateLobId
();
long
length
=
streamStore
.
length
(
streamStoreId
);
int
tableId
=
LobStorageFrontend
.
TABLE_TEMP
;
Object
[]
value
=
new
Object
[]
{
streamStoreId
,
tableId
,
length
,
0
};
...
...
@@ -172,9 +181,17 @@ public class LobStorageMap implements LobStorageInterface {
Object
[]
key
=
new
Object
[]
{
streamStoreId
,
lobId
};
refMap
.
put
(
key
,
Boolean
.
TRUE
);
ValueLobDb
lob
=
ValueLobDb
.
create
(
type
,
database
,
tableId
,
lobId
,
null
,
length
);
if
(
TRACE
)
{
trace
(
"create "
+
tableId
+
"/"
+
lobId
);
}
return
lob
;
}
private
long
generateLobId
()
{
Long
id
=
lobMap
.
lastKey
();
return
id
==
null
?
1
:
id
+
1
;
}
@Override
public
ValueLobDb
copyLob
(
ValueLobDb
old
,
int
tableId
,
long
length
)
{
init
();
...
...
@@ -185,13 +202,17 @@ public class LobStorageMap implements LobStorageInterface {
throw
DbException
.
throwInternalError
(
"Length is different"
);
}
Object
[]
value
=
lobMap
.
get
(
oldLobId
);
value
=
Arrays
.
copyOf
(
value
,
value
.
length
);
byte
[]
streamStoreId
=
(
byte
[])
value
[
0
];
long
lobId
=
streamStore
.
getAndIncrementNextKey
();
long
lobId
=
generateLobId
();
value
[
1
]
=
tableId
;
lobMap
.
put
(
lobId
,
value
);
Object
[]
key
=
new
Object
[]
{
streamStoreId
,
lobId
};
refMap
.
put
(
key
,
Boolean
.
TRUE
);
ValueLobDb
lob
=
ValueLobDb
.
create
(
type
,
database
,
tableId
,
lobId
,
null
,
length
);
if
(
TRACE
)
{
trace
(
"copy "
+
old
.
getTableId
()
+
"/"
+
old
.
getLobId
()
+
" > "
+
tableId
+
"/"
+
lobId
);
}
return
lob
;
}
...
...
@@ -209,6 +230,9 @@ public class LobStorageMap implements LobStorageInterface {
init
();
long
lobId
=
lob
.
getLobId
();
Object
[]
value
=
lobMap
.
remove
(
lobId
);
if
(
TRACE
)
{
trace
(
"move "
+
lob
.
getTableId
()
+
"/"
+
lob
.
getLobId
()
+
" > "
+
tableId
+
"/"
+
lobId
);
}
value
[
1
]
=
tableId
;
lobMap
.
put
(
lobId
,
value
);
}
...
...
@@ -239,10 +263,15 @@ public class LobStorageMap implements LobStorageInterface {
}
private
void
removeLob
(
int
tableId
,
long
lobId
)
{
if
(
TRACE
)
{
trace
(
"remove "
+
tableId
+
"/"
+
lobId
);
}
Object
[]
value
=
lobMap
.
remove
(
lobId
);
byte
[]
streamStoreId
=
(
byte
[])
value
[
0
];
Object
[]
key
=
new
Object
[]
{
streamStoreId
,
lobId
};
refMap
.
remove
(
key
);
// check if there are more entries for this streamStoreId
Object
[]
key
=
new
Object
[]
{
streamStoreId
,
0
};
key
=
new
Object
[]
{
streamStoreId
,
0
};
value
=
refMap
.
ceilingKey
(
key
);
boolean
hasMoreEntries
=
false
;
if
(
value
!=
null
)
{
...
...
@@ -256,4 +285,8 @@ public class LobStorageMap implements LobStorageInterface {
}
}
private
static
void
trace
(
String
op
)
{
System
.
out
.
println
(
"LOB "
+
op
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论