Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d263ba28
提交
d263ba28
authored
4月 22, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New experimental LOB storage mechanism.
上级
1de0bbf7
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
353 行增加
和
181 行删除
+353
-181
Data.java
h2/src/main/org/h2/store/Data.java
+7
-4
LobStorage.java
h2/src/main/org/h2/store/LobStorage.java
+86
-34
Recover.java
h2/src/main/org/h2/tools/Recover.java
+210
-123
DataType.java
h2/src/main/org/h2/value/DataType.java
+10
-4
Value.java
h2/src/main/org/h2/value/Value.java
+14
-0
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+26
-16
没有找到文件。
h2/src/main/org/h2/store/Data.java
浏览文件 @
d263ba28
...
@@ -32,7 +32,7 @@ import org.h2.value.ValueFloat;
...
@@ -32,7 +32,7 @@ import org.h2.value.ValueFloat;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueJavaObject
;
import
org.h2.value.ValueJavaObject
;
import
org.h2.value.ValueLob
;
import
org.h2.value.ValueLob
;
import
org.h2.value.ValueLob
2
;
import
org.h2.value.ValueLob
Db
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueShort
;
import
org.h2.value.ValueShort
;
...
@@ -565,10 +565,11 @@ public class Data {
...
@@ -565,10 +565,11 @@ public class Data {
write
(
small
,
0
,
small
.
length
);
write
(
small
,
0
,
small
.
length
);
}
}
}
else
{
}
else
{
ValueLob
2
lob
=
(
ValueLob2
)
v
;
ValueLob
Db
lob
=
(
ValueLobDb
)
v
;
byte
[]
small
=
lob
.
getSmall
();
byte
[]
small
=
lob
.
getSmall
();
if
(
small
==
null
)
{
if
(
small
==
null
)
{
writeVarInt
(-
3
);
writeVarInt
(-
3
);
writeVarInt
(
lob
.
getTableId
());
writeVarLong
(
lob
.
getLobId
());
writeVarLong
(
lob
.
getLobId
());
writeVarLong
(
lob
.
getPrecision
());
writeVarLong
(
lob
.
getPrecision
());
}
else
{
}
else
{
...
@@ -697,10 +698,11 @@ public class Data {
...
@@ -697,10 +698,11 @@ public class Data {
read
(
small
,
0
,
smallLen
);
read
(
small
,
0
,
smallLen
);
return
LobStorage
.
createSmallLob
(
type
,
small
);
return
LobStorage
.
createSmallLob
(
type
,
small
);
}
else
if
(
smallLen
==
-
3
)
{
}
else
if
(
smallLen
==
-
3
)
{
int
tableId
=
readVarInt
();
long
lobId
=
readVarLong
();
long
lobId
=
readVarLong
();
long
precision
=
readVarLong
();
long
precision
=
readVarLong
();
LobStorage
lobStorage
=
handler
.
getLobStorage
();
LobStorage
lobStorage
=
handler
.
getLobStorage
();
ValueLob
2
lob
=
ValueLob2
.
create
(
type
,
lobStorage
,
null
,
lobId
,
precision
);
ValueLob
Db
lob
=
ValueLobDb
.
create
(
type
,
lobStorage
,
null
,
tableId
,
lobId
,
precision
);
return
lob
;
return
lob
;
}
else
{
}
else
{
int
tableId
=
readVarInt
();
int
tableId
=
readVarInt
();
...
@@ -890,10 +892,11 @@ public class Data {
...
@@ -890,10 +892,11 @@ public class Data {
len
+=
small
.
length
;
len
+=
small
.
length
;
}
}
}
else
{
}
else
{
ValueLob
2
lob
=
(
ValueLob2
)
v
;
ValueLob
Db
lob
=
(
ValueLobDb
)
v
;
byte
[]
small
=
lob
.
getSmall
();
byte
[]
small
=
lob
.
getSmall
();
if
(
small
==
null
)
{
if
(
small
==
null
)
{
len
+=
getVarIntLen
(-
3
);
len
+=
getVarIntLen
(-
3
);
len
+=
getVarIntLen
(
lob
.
getTableId
());
len
+=
getVarLongLen
(
lob
.
getLobId
());
len
+=
getVarLongLen
(
lob
.
getLobId
());
len
+=
getVarLongLen
(
lob
.
getPrecision
());
len
+=
getVarLongLen
(
lob
.
getPrecision
());
}
else
{
}
else
{
...
...
h2/src/main/org/h2/store/LobStorage.java
浏览文件 @
d263ba28
差异被折叠。
点击展开。
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
d263ba28
差异被折叠。
点击展开。
h2/src/main/org/h2/value/DataType.java
浏览文件 @
d263ba28
...
@@ -770,6 +770,10 @@ public class DataType {
...
@@ -770,6 +770,10 @@ public class DataType {
}
}
if
(
ResultSet
.
class
.
isAssignableFrom
(
x
))
{
if
(
ResultSet
.
class
.
isAssignableFrom
(
x
))
{
return
Value
.
RESULT_SET
;
return
Value
.
RESULT_SET
;
}
else
if
(
Value
.
ValueBlob
.
class
.
isAssignableFrom
(
x
))
{
return
Value
.
BLOB
;
}
else
if
(
Value
.
ValueClob
.
class
.
isAssignableFrom
(
x
))
{
return
Value
.
CLOB
;
}
else
if
(
String
.
class
.
isAssignableFrom
(
x
))
{
}
else
if
(
String
.
class
.
isAssignableFrom
(
x
))
{
return
Value
.
STRING
;
return
Value
.
STRING
;
}
else
if
(
BigDecimal
.
class
.
isAssignableFrom
(
x
))
{
}
else
if
(
BigDecimal
.
class
.
isAssignableFrom
(
x
))
{
...
@@ -836,6 +840,12 @@ public class DataType {
...
@@ -836,6 +840,12 @@ public class DataType {
}
}
if
(
x
instanceof
String
)
{
if
(
x
instanceof
String
)
{
return
ValueString
.
get
((
String
)
x
);
return
ValueString
.
get
((
String
)
x
);
}
else
if
(
x
instanceof
Value
)
{
return
(
Value
)
x
;
}
else
if
(
x
instanceof
Long
)
{
return
ValueLong
.
get
(((
Long
)
x
).
longValue
());
}
else
if
(
x
instanceof
Integer
)
{
return
ValueInt
.
get
(((
Integer
)
x
).
intValue
());
}
else
if
(
x
instanceof
BigDecimal
)
{
}
else
if
(
x
instanceof
BigDecimal
)
{
return
ValueDecimal
.
get
((
BigDecimal
)
x
);
return
ValueDecimal
.
get
((
BigDecimal
)
x
);
}
else
if
(
x
instanceof
Boolean
)
{
}
else
if
(
x
instanceof
Boolean
)
{
...
@@ -844,10 +854,6 @@ public class DataType {
...
@@ -844,10 +854,6 @@ public class DataType {
return
ValueByte
.
get
(((
Byte
)
x
).
byteValue
());
return
ValueByte
.
get
(((
Byte
)
x
).
byteValue
());
}
else
if
(
x
instanceof
Short
)
{
}
else
if
(
x
instanceof
Short
)
{
return
ValueShort
.
get
(((
Short
)
x
).
shortValue
());
return
ValueShort
.
get
(((
Short
)
x
).
shortValue
());
}
else
if
(
x
instanceof
Integer
)
{
return
ValueInt
.
get
(((
Integer
)
x
).
intValue
());
}
else
if
(
x
instanceof
Long
)
{
return
ValueLong
.
get
(((
Long
)
x
).
longValue
());
}
else
if
(
x
instanceof
Float
)
{
}
else
if
(
x
instanceof
Float
)
{
return
ValueFloat
.
get
(((
Float
)
x
).
floatValue
());
return
ValueFloat
.
get
(((
Float
)
x
).
floatValue
());
}
else
if
(
x
instanceof
Double
)
{
}
else
if
(
x
instanceof
Double
)
{
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
d263ba28
...
@@ -1007,4 +1007,18 @@ public abstract class Value {
...
@@ -1007,4 +1007,18 @@ public abstract class Value {
return
this
;
return
this
;
}
}
/**
* A "binary large object".
*/
public
interface
ValueClob
{
// this is a marker interface
}
/**
* A "character large object".
*/
public
interface
ValueBlob
{
// this is a marker interface
}
}
}
h2/src/main/org/h2/value/ValueLob
2
.java
→
h2/src/main/org/h2/value/ValueLob
Db
.java
浏览文件 @
d263ba28
...
@@ -29,7 +29,7 @@ import org.h2.util.Utils;
...
@@ -29,7 +29,7 @@ import org.h2.util.Utils;
/**
/**
* An alternate LOB implementation.
* An alternate LOB implementation.
*/
*/
public
class
ValueLob
2
extends
Value
{
public
class
ValueLob
Db
extends
Value
implements
Value
.
ValueClob
,
Value
.
ValueBlob
{
private
final
int
type
;
private
final
int
type
;
private
long
precision
;
private
long
precision
;
...
@@ -45,7 +45,7 @@ public class ValueLob2 extends Value {
...
@@ -45,7 +45,7 @@ public class ValueLob2 extends Value {
private
FileStore
tempFile
;
private
FileStore
tempFile
;
private
String
fileName
;
private
String
fileName
;
private
ValueLob
2
(
int
type
,
LobStorage
lobStorage
,
String
fileName
,
int
tableId
,
long
lobId
,
long
precision
)
{
private
ValueLob
Db
(
int
type
,
LobStorage
lobStorage
,
String
fileName
,
int
tableId
,
long
lobId
,
long
precision
)
{
this
.
type
=
type
;
this
.
type
=
type
;
this
.
lobStorage
=
lobStorage
;
this
.
lobStorage
=
lobStorage
;
this
.
fileName
=
fileName
;
this
.
fileName
=
fileName
;
...
@@ -54,7 +54,7 @@ public class ValueLob2 extends Value {
...
@@ -54,7 +54,7 @@ public class ValueLob2 extends Value {
this
.
precision
=
precision
;
this
.
precision
=
precision
;
}
}
private
ValueLob
2
(
int
type
,
byte
[]
small
,
long
precision
)
{
private
ValueLob
Db
(
int
type
,
byte
[]
small
,
long
precision
)
{
this
.
type
=
type
;
this
.
type
=
type
;
this
.
small
=
small
;
this
.
small
=
small
;
this
.
precision
=
precision
;
this
.
precision
=
precision
;
...
@@ -66,12 +66,13 @@ public class ValueLob2 extends Value {
...
@@ -66,12 +66,13 @@ public class ValueLob2 extends Value {
* @param type the type
* @param type the type
* @param lobStorage the storage
* @param lobStorage the storage
* @param fileName the file name (may be null)
* @param fileName the file name (may be null)
* @param tableId the table id
* @param id the lob id
* @param id the lob id
* @param precision the precision (number of bytes / characters)
* @param precision the precision (number of bytes / characters)
* @return the value
* @return the value
*/
*/
public
static
ValueLob
2
create
(
int
type
,
LobStorage
lobStorage
,
String
fileName
,
long
id
,
long
precision
)
{
public
static
ValueLob
Db
create
(
int
type
,
LobStorage
lobStorage
,
String
fileName
,
int
tableId
,
long
id
,
long
precision
)
{
return
new
ValueLob
2
(
type
,
lobStorage
,
fileName
,
LobStorage
.
TABLE_ID_SESSION_VARIABLE
,
id
,
precision
);
return
new
ValueLob
Db
(
type
,
lobStorage
,
fileName
,
tableId
,
id
,
precision
);
}
}
/**
/**
...
@@ -82,8 +83,8 @@ public class ValueLob2 extends Value {
...
@@ -82,8 +83,8 @@ public class ValueLob2 extends Value {
* @param precision the precision
* @param precision the precision
* @return the lob value
* @return the lob value
*/
*/
public
static
ValueLob
2
createSmallLob
(
int
type
,
byte
[]
small
,
long
precision
)
{
public
static
ValueLob
Db
createSmallLob
(
int
type
,
byte
[]
small
,
long
precision
)
{
return
new
ValueLob
2
(
type
,
small
,
precision
);
return
new
ValueLob
Db
(
type
,
small
,
precision
);
}
}
/**
/**
...
@@ -141,12 +142,21 @@ public class ValueLob2 extends Value {
...
@@ -141,12 +142,21 @@ public class ValueLob2 extends Value {
public
Value
link
(
DataHandler
h
,
int
tabId
)
{
public
Value
link
(
DataHandler
h
,
int
tabId
)
{
if
(
small
==
null
)
{
if
(
small
==
null
)
{
if
(
tabId
!=
tableId
)
{
if
(
tabId
!=
tableId
)
{
if
(
tableId
!=
LobStorage
.
TABLE_
ID_SESSION_VARIABLE
)
{
if
(
tableId
!=
LobStorage
.
TABLE_
TEMP
)
{
throw
DbException
.
throwInternalError
(
);
return
lobStorage
.
copyLob
(
type
,
lobId
,
tabId
,
getPrecision
()
);
}
}
lobStorage
.
setTable
(
lobId
,
tabId
);
lobStorage
.
setTable
(
lobId
,
tabId
);
this
.
tableId
=
tabId
;
this
.
tableId
=
tabId
;
}
}
}
else
if
(
small
.
length
>
h
.
getMaxLengthInplaceLob
())
{
LobStorage
s
=
h
.
getLobStorage
();
Value
v
;
if
(
type
==
Value
.
BLOB
)
{
v
=
s
.
createBlob
(
getInputStream
(),
getPrecision
());
}
else
{
v
=
s
.
createClob
(
getReader
(),
getPrecision
());
}
return
v
.
link
(
h
,
tabId
);
}
}
return
this
;
return
this
;
}
}
...
@@ -335,7 +345,7 @@ public class ValueLob2 extends Value {
...
@@ -335,7 +345,7 @@ public class ValueLob2 extends Value {
*
*
* @return the value
* @return the value
*/
*/
public
ValueLob
2
copyToTemp
()
{
public
ValueLob
Db
copyToTemp
()
{
return
this
;
return
this
;
}
}
...
@@ -359,7 +369,7 @@ public class ValueLob2 extends Value {
...
@@ -359,7 +369,7 @@ public class ValueLob2 extends Value {
* @param handler the data handler
* @param handler the data handler
* @return the lob value
* @return the lob value
*/
*/
public
static
ValueLob
2
createTempClob
(
Reader
in
,
long
length
,
DataHandler
handler
)
{
public
static
ValueLob
Db
createTempClob
(
Reader
in
,
long
length
,
DataHandler
handler
)
{
try
{
try
{
boolean
compress
=
handler
.
getLobCompressionAlgorithm
(
Value
.
CLOB
)
!=
null
;
boolean
compress
=
handler
.
getLobCompressionAlgorithm
(
Value
.
CLOB
)
!=
null
;
long
remaining
=
Long
.
MAX_VALUE
;
long
remaining
=
Long
.
MAX_VALUE
;
...
@@ -379,9 +389,9 @@ public class ValueLob2 extends Value {
...
@@ -379,9 +389,9 @@ public class ValueLob2 extends Value {
}
}
if
(
len
<=
handler
.
getMaxLengthInplaceLob
())
{
if
(
len
<=
handler
.
getMaxLengthInplaceLob
())
{
byte
[]
small
=
StringUtils
.
utf8Encode
(
new
String
(
buff
,
0
,
len
));
byte
[]
small
=
StringUtils
.
utf8Encode
(
new
String
(
buff
,
0
,
len
));
return
ValueLob
2
.
createSmallLob
(
Value
.
CLOB
,
small
,
len
);
return
ValueLob
Db
.
createSmallLob
(
Value
.
CLOB
,
small
,
len
);
}
}
ValueLob
2
lob
=
new
ValueLob2
(
Value
.
CLOB
,
null
,
0
);
ValueLob
Db
lob
=
new
ValueLobDb
(
Value
.
CLOB
,
null
,
0
);
lob
.
createTempFromReader
(
buff
,
len
,
in
,
remaining
,
handler
);
lob
.
createTempFromReader
(
buff
,
len
,
in
,
remaining
,
handler
);
return
lob
;
return
lob
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -397,7 +407,7 @@ public class ValueLob2 extends Value {
...
@@ -397,7 +407,7 @@ public class ValueLob2 extends Value {
* @param handler the data handler
* @param handler the data handler
* @return the lob value
* @return the lob value
*/
*/
public
static
ValueLob
2
createTempBlob
(
InputStream
in
,
long
length
,
DataHandler
handler
)
{
public
static
ValueLob
Db
createTempBlob
(
InputStream
in
,
long
length
,
DataHandler
handler
)
{
try
{
try
{
long
remaining
=
Long
.
MAX_VALUE
;
long
remaining
=
Long
.
MAX_VALUE
;
boolean
compress
=
handler
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
boolean
compress
=
handler
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
...
@@ -416,9 +426,9 @@ public class ValueLob2 extends Value {
...
@@ -416,9 +426,9 @@ public class ValueLob2 extends Value {
if
(
len
<=
handler
.
getMaxLengthInplaceLob
())
{
if
(
len
<=
handler
.
getMaxLengthInplaceLob
())
{
byte
[]
small
=
Utils
.
newBytes
(
len
);
byte
[]
small
=
Utils
.
newBytes
(
len
);
System
.
arraycopy
(
buff
,
0
,
small
,
0
,
len
);
System
.
arraycopy
(
buff
,
0
,
small
,
0
,
len
);
return
ValueLob
2
.
createSmallLob
(
Value
.
BLOB
,
small
,
small
.
length
);
return
ValueLob
Db
.
createSmallLob
(
Value
.
BLOB
,
small
,
small
.
length
);
}
}
ValueLob
2
lob
=
new
ValueLob2
(
Value
.
BLOB
,
null
,
0
);
ValueLob
Db
lob
=
new
ValueLobDb
(
Value
.
BLOB
,
null
,
0
);
lob
.
createTempFromStream
(
buff
,
len
,
in
,
remaining
,
handler
);
lob
.
createTempFromStream
(
buff
,
len
,
in
,
remaining
,
handler
);
return
lob
;
return
lob
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论