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