Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
1abb466e
提交
1abb466e
authored
5月 27, 2013
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"handler" field can be declared final
上级
7fb2c292
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
17 行删除
+27
-17
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+27
-17
没有找到文件。
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
1abb466e
...
@@ -47,7 +47,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -47,7 +47,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
private
final
byte
[]
small
;
private
final
byte
[]
small
;
private
DataHandler
handler
;
private
final
DataHandler
handler
;
private
FileStore
tempFile
;
private
FileStore
tempFile
;
private
String
fileName
;
private
String
fileName
;
...
@@ -59,6 +59,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -59,6 +59,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
this
.
hmac
=
hmac
;
this
.
hmac
=
hmac
;
this
.
precision
=
precision
;
this
.
precision
=
precision
;
this
.
small
=
null
;
this
.
small
=
null
;
this
.
handler
=
null
;
}
}
private
ValueLobDb
(
int
type
,
byte
[]
small
,
long
precision
)
{
private
ValueLobDb
(
int
type
,
byte
[]
small
,
long
precision
)
{
...
@@ -67,8 +68,18 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -67,8 +68,18 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
this
.
precision
=
precision
;
this
.
precision
=
precision
;
this
.
lobId
=
0
;
this
.
lobId
=
0
;
this
.
hmac
=
null
;
this
.
hmac
=
null
;
this
.
handler
=
null
;
}
}
private
ValueLobDb
(
int
type
,
DataHandler
handler
)
{
this
.
type
=
type
;
this
.
small
=
null
;
this
.
precision
=
0
;
this
.
lobId
=
0
;
this
.
hmac
=
null
;
this
.
handler
=
handler
;
}
/**
/**
* Create a LOB value.
* Create a LOB value.
*
*
...
@@ -440,8 +451,8 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -440,8 +451,8 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
byte
[]
small
=
new
String
(
buff
,
0
,
len
).
getBytes
(
Constants
.
UTF8
);
byte
[]
small
=
new
String
(
buff
,
0
,
len
).
getBytes
(
Constants
.
UTF8
);
return
ValueLobDb
.
createSmallLob
(
Value
.
CLOB
,
small
,
len
);
return
ValueLobDb
.
createSmallLob
(
Value
.
CLOB
,
small
,
len
);
}
}
ValueLobDb
lob
=
new
ValueLobDb
(
Value
.
CLOB
,
null
,
0
);
ValueLobDb
lob
=
new
ValueLobDb
(
Value
.
CLOB
,
handler
);
lob
.
createTempFromReader
(
buff
,
len
,
in
,
remaining
,
handler
);
lob
.
createTempFromReader
(
buff
,
len
,
in
,
remaining
);
return
lob
;
return
lob
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
null
);
throw
DbException
.
convertIOException
(
e
,
null
);
...
@@ -477,16 +488,16 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -477,16 +488,16 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
System
.
arraycopy
(
buff
,
0
,
small
,
0
,
len
);
System
.
arraycopy
(
buff
,
0
,
small
,
0
,
len
);
return
ValueLobDb
.
createSmallLob
(
Value
.
BLOB
,
small
,
small
.
length
);
return
ValueLobDb
.
createSmallLob
(
Value
.
BLOB
,
small
,
small
.
length
);
}
}
ValueLobDb
lob
=
new
ValueLobDb
(
Value
.
BLOB
,
null
,
0
);
ValueLobDb
lob
=
new
ValueLobDb
(
Value
.
BLOB
,
handler
);
lob
.
createTempFromStream
(
buff
,
len
,
in
,
remaining
,
handler
);
lob
.
createTempFromStream
(
buff
,
len
,
in
,
remaining
);
return
lob
;
return
lob
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
null
);
throw
DbException
.
convertIOException
(
e
,
null
);
}
}
}
}
private
void
createTempFromReader
(
char
[]
buff
,
int
len
,
Reader
in
,
long
remaining
,
DataHandler
h
)
throws
IOException
{
private
void
createTempFromReader
(
char
[]
buff
,
int
len
,
Reader
in
,
long
remaining
)
throws
IOException
{
FileStoreOutputStream
out
=
initTemp
(
h
);
FileStoreOutputStream
out
=
initTemp
();
try
{
try
{
while
(
true
)
{
while
(
true
)
{
precision
+=
len
;
precision
+=
len
;
...
@@ -496,7 +507,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -496,7 +507,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
if
(
remaining
<=
0
)
{
if
(
remaining
<=
0
)
{
break
;
break
;
}
}
len
=
getBufferSize
(
h
,
false
,
remaining
);
len
=
getBufferSize
(
this
.
handler
,
false
,
remaining
);
len
=
IOUtils
.
readFully
(
in
,
buff
,
len
);
len
=
IOUtils
.
readFully
(
in
,
buff
,
len
);
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
break
;
break
;
...
@@ -508,9 +519,9 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -508,9 +519,9 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
}
}
private
void
createTempFromStream
(
byte
[]
buff
,
int
len
,
InputStream
in
,
private
void
createTempFromStream
(
byte
[]
buff
,
int
len
,
InputStream
in
,
long
remaining
,
DataHandler
h
)
throws
IOException
{
long
remaining
)
throws
IOException
{
FileStoreOutputStream
out
=
initTemp
(
h
);
FileStoreOutputStream
out
=
initTemp
();
boolean
compress
=
h
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
boolean
compress
=
this
.
handler
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
try
{
try
{
while
(
true
)
{
while
(
true
)
{
precision
+=
len
;
precision
+=
len
;
...
@@ -519,7 +530,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -519,7 +530,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
if
(
remaining
<=
0
)
{
if
(
remaining
<=
0
)
{
break
;
break
;
}
}
len
=
getBufferSize
(
h
,
compress
,
remaining
);
len
=
getBufferSize
(
this
.
handler
,
compress
,
remaining
);
len
=
IOUtils
.
readFully
(
in
,
buff
,
0
,
len
);
len
=
IOUtils
.
readFully
(
in
,
buff
,
0
,
len
);
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
break
;
break
;
...
@@ -530,16 +541,15 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -530,16 +541,15 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
}
}
}
}
private
FileStoreOutputStream
initTemp
(
DataHandler
h
)
throws
IOException
{
private
FileStoreOutputStream
initTemp
()
throws
IOException
{
this
.
precision
=
0
;
this
.
precision
=
0
;
this
.
handler
=
h
;
this
.
lobStorage
=
this
.
handler
.
getLobStorage
();
this
.
lobStorage
=
h
.
getLobStorage
();
String
path
=
this
.
handler
.
getDatabasePath
();
String
path
=
h
.
getDatabasePath
();
if
(
path
.
length
()
==
0
)
{
if
(
path
.
length
()
==
0
)
{
path
=
SysProperties
.
PREFIX_TEMP_FILE
;
path
=
SysProperties
.
PREFIX_TEMP_FILE
;
}
}
fileName
=
FileUtils
.
createTempFile
(
path
,
Constants
.
SUFFIX_TEMP_FILE
,
true
,
true
);
fileName
=
FileUtils
.
createTempFile
(
path
,
Constants
.
SUFFIX_TEMP_FILE
,
true
,
true
);
tempFile
=
h
.
openFile
(
fileName
,
"rw"
,
false
);
tempFile
=
this
.
handler
.
openFile
(
fileName
,
"rw"
,
false
);
tempFile
.
autoDelete
();
tempFile
.
autoDelete
();
FileStoreOutputStream
out
=
new
FileStoreOutputStream
(
tempFile
,
null
,
null
);
FileStoreOutputStream
out
=
new
FileStoreOutputStream
(
tempFile
,
null
,
null
);
return
out
;
return
out
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论