Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4675d719
提交
4675d719
authored
6月 23, 2018
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
document ValueLob.type a little
上级
d4ed1a5d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
23 行删除
+26
-23
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+26
-23
没有找到文件。
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
4675d719
...
...
@@ -109,7 +109,10 @@ public class ValueLob extends Value {
*/
private
static
int
dirCounter
;
private
final
int
type
;
/**
* either Value.BLOB or Value.CLOB
*/
private
final
int
valueType
;
private
long
precision
;
private
DataHandler
handler
;
private
int
tableId
;
...
...
@@ -124,7 +127,7 @@ public class ValueLob extends Value {
private
ValueLob
(
int
type
,
DataHandler
handler
,
String
fileName
,
int
tableId
,
int
objectId
,
boolean
linked
,
long
precision
,
boolean
compressed
)
{
this
.
t
ype
=
type
;
this
.
valueT
ype
=
type
;
this
.
handler
=
handler
;
this
.
fileName
=
fileName
;
this
.
tableId
=
tableId
;
...
...
@@ -135,7 +138,7 @@ public class ValueLob extends Value {
}
private
ValueLob
(
int
type
,
byte
[]
small
)
{
this
.
t
ype
=
type
;
this
.
valueT
ype
=
type
;
this
.
small
=
small
;
if
(
small
!=
null
)
{
if
(
type
==
Value
.
BLOB
)
{
...
...
@@ -147,7 +150,7 @@ public class ValueLob extends Value {
}
private
static
ValueLob
copy
(
ValueLob
lob
)
{
ValueLob
copy
=
new
ValueLob
(
lob
.
t
ype
,
lob
.
handler
,
lob
.
fileName
,
ValueLob
copy
=
new
ValueLob
(
lob
.
valueT
ype
,
lob
.
handler
,
lob
.
fileName
,
lob
.
tableId
,
lob
.
objectId
,
lob
.
linked
,
lob
.
precision
,
lob
.
compressed
);
copy
.
small
=
lob
.
small
;
copy
.
hash
=
lob
.
hash
;
...
...
@@ -178,7 +181,7 @@ public class ValueLob extends Value {
/**
* Create a LOB value with the given parameters.
*
* @param type the data type
* @param type the data type
, either Value.BLOB or Value.CLOB
* @param handler the file handler
* @param tableId the table object id
* @param objectId the object id
...
...
@@ -196,7 +199,7 @@ public class ValueLob extends Value {
/**
* Create a LOB value with the given parameters.
*
* @param type the data type
* @param type the data type
, either Value.BLOB or Value.CLOB
* @param handler the file handler
* @param tableId the table object id
* @param objectId the object id
...
...
@@ -454,7 +457,7 @@ public class ValueLob extends Value {
this
.
precision
=
0
;
this
.
small
=
null
;
this
.
hash
=
0
;
String
compressionAlgorithm
=
h
.
getLobCompressionAlgorithm
(
t
ype
);
String
compressionAlgorithm
=
h
.
getLobCompressionAlgorithm
(
valueT
ype
);
this
.
compressed
=
compressionAlgorithm
!=
null
;
synchronized
(
h
)
{
String
path
=
h
.
getDatabasePath
();
...
...
@@ -507,7 +510,7 @@ public class ValueLob extends Value {
*/
@Override
public
Value
convertTo
(
int
t
,
int
precision
,
Mode
mode
,
Object
column
,
String
[]
enumerators
)
{
if
(
t
==
t
ype
)
{
if
(
t
==
valueT
ype
)
{
return
this
;
}
else
if
(
t
==
Value
.
CLOB
)
{
return
ValueLob
.
createClob
(
getReader
(),
-
1
,
handler
);
...
...
@@ -593,7 +596,7 @@ public class ValueLob extends Value {
@Override
public
int
getType
()
{
return
t
ype
;
return
valueT
ype
;
}
@Override
...
...
@@ -606,7 +609,7 @@ public class ValueLob extends Value {
int
len
=
precision
>
Integer
.
MAX_VALUE
||
precision
==
0
?
Integer
.
MAX_VALUE
:
(
int
)
precision
;
try
{
if
(
t
ype
==
Value
.
CLOB
)
{
if
(
valueT
ype
==
Value
.
CLOB
)
{
if
(
small
!=
null
)
{
return
new
String
(
small
,
StandardCharsets
.
UTF_8
);
}
...
...
@@ -626,7 +629,7 @@ public class ValueLob extends Value {
@Override
public
byte
[]
getBytes
()
{
if
(
t
ype
==
CLOB
)
{
if
(
valueT
ype
==
CLOB
)
{
// convert hex to string
return
super
.
getBytes
();
}
...
...
@@ -636,7 +639,7 @@ public class ValueLob extends Value {
@Override
public
byte
[]
getBytesNoCopy
()
{
if
(
t
ype
==
CLOB
)
{
if
(
valueT
ype
==
CLOB
)
{
// convert hex to string
return
super
.
getBytesNoCopy
();
}
...
...
@@ -659,7 +662,7 @@ public class ValueLob extends Value {
// it in the database file
return
(
int
)
(
precision
^
(
precision
>>>
32
));
}
if
(
t
ype
==
CLOB
)
{
if
(
valueT
ype
==
CLOB
)
{
hash
=
getString
().
hashCode
();
}
else
{
hash
=
Utils
.
getByteArrayHash
(
getBytes
());
...
...
@@ -670,7 +673,7 @@ public class ValueLob extends Value {
@Override
protected
int
compareSecure
(
Value
v
,
CompareMode
mode
)
{
if
(
t
ype
==
Value
.
CLOB
)
{
if
(
valueT
ype
==
Value
.
CLOB
)
{
return
Integer
.
signum
(
getString
().
compareTo
(
v
.
getString
()));
}
byte
[]
v2
=
v
.
getBytesNoCopy
();
...
...
@@ -679,7 +682,7 @@ public class ValueLob extends Value {
@Override
public
Object
getObject
()
{
if
(
t
ype
==
Value
.
CLOB
)
{
if
(
valueT
ype
==
Value
.
CLOB
)
{
return
getReader
();
}
return
getInputStream
();
...
...
@@ -692,7 +695,7 @@ public class ValueLob extends Value {
@Override
public
Reader
getReader
(
long
oneBasedOffset
,
long
length
)
{
return
rangeReader
(
getReader
(),
oneBasedOffset
,
length
,
t
ype
==
Value
.
CLOB
?
precision
:
-
1
);
return
rangeReader
(
getReader
(),
oneBasedOffset
,
length
,
valueT
ype
==
Value
.
CLOB
?
precision
:
-
1
);
}
@Override
...
...
@@ -727,7 +730,7 @@ public class ValueLob extends Value {
if
(
p
>
Integer
.
MAX_VALUE
||
p
<=
0
)
{
p
=
-
1
;
}
if
(
t
ype
==
Value
.
BLOB
)
{
if
(
valueT
ype
==
Value
.
BLOB
)
{
prep
.
setBinaryStream
(
parameterIndex
,
getInputStream
(),
(
int
)
p
);
}
else
{
prep
.
setCharacterStream
(
parameterIndex
,
getReader
(),
(
int
)
p
);
...
...
@@ -737,7 +740,7 @@ public class ValueLob extends Value {
@Override
public
String
getSQL
()
{
String
s
;
if
(
t
ype
==
Value
.
CLOB
)
{
if
(
valueT
ype
==
Value
.
CLOB
)
{
s
=
getString
();
return
StringUtils
.
quoteStringSQL
(
s
);
}
...
...
@@ -752,7 +755,7 @@ public class ValueLob extends Value {
return
getSQL
();
}
StringBuilder
buff
=
new
StringBuilder
();
if
(
t
ype
==
Value
.
CLOB
)
{
if
(
valueT
ype
==
Value
.
CLOB
)
{
buff
.
append
(
"SPACE("
).
append
(
getPrecision
());
}
else
{
buff
.
append
(
"CAST(REPEAT('00', "
).
append
(
getPrecision
()).
append
(
") AS BINARY"
);
...
...
@@ -790,10 +793,10 @@ public class ValueLob extends Value {
public
void
convertToFileIfRequired
(
DataHandler
h
)
{
try
{
if
(
small
!=
null
&&
small
.
length
>
h
.
getMaxLengthInplaceLob
())
{
boolean
compress
=
h
.
getLobCompressionAlgorithm
(
t
ype
)
!=
null
;
boolean
compress
=
h
.
getLobCompressionAlgorithm
(
valueT
ype
)
!=
null
;
int
len
=
getBufferSize
(
h
,
compress
,
Long
.
MAX_VALUE
);
int
tabId
=
tableId
;
if
(
t
ype
==
Value
.
BLOB
)
{
if
(
valueT
ype
==
Value
.
BLOB
)
{
createFromStream
(
Utils
.
newBytes
(
len
),
0
,
getInputStream
(),
Long
.
MAX_VALUE
,
h
);
}
else
{
...
...
@@ -863,7 +866,7 @@ public class ValueLob extends Value {
@Override
public
ValueLob
copyToTemp
()
{
ValueLob
lob
;
if
(
t
ype
==
CLOB
)
{
if
(
valueT
ype
==
CLOB
)
{
lob
=
ValueLob
.
createClob
(
getReader
(),
precision
,
handler
);
}
else
{
lob
=
ValueLob
.
createBlob
(
getInputStream
(),
precision
,
handler
);
...
...
@@ -877,7 +880,7 @@ public class ValueLob extends Value {
return
this
;
}
ValueLob
lob
;
if
(
t
ype
==
CLOB
)
{
if
(
valueT
ype
==
CLOB
)
{
lob
=
ValueLob
.
createClob
(
getReader
(),
precision
,
handler
);
}
else
{
lob
=
ValueLob
.
createBlob
(
getInputStream
(),
precision
,
handler
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论