Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
900c76bb
提交
900c76bb
authored
9月 11, 2013
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
There is no need to store both LobStorageInterface and DataHandler as fields in ValueLobDb.
Simplify the code and only store DataHandler.
上级
6aba2a41
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
25 行增加
和
36 行删除
+25
-36
ValueDataType.java
h2/src/main/org/h2/mvstore/db/ValueDataType.java
+1
-3
Data.java
h2/src/main/org/h2/store/Data.java
+1
-2
LobStorageBackend.java
h2/src/main/org/h2/store/LobStorageBackend.java
+2
-2
Recover.java
h2/src/main/org/h2/tools/Recover.java
+2
-4
Transfer.java
h2/src/main/org/h2/value/Transfer.java
+2
-2
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+17
-23
没有找到文件。
h2/src/main/org/h2/mvstore/db/ValueDataType.java
浏览文件 @
900c76bb
...
...
@@ -25,7 +25,6 @@ import org.h2.result.SortOrder;
import
org.h2.store.Data
;
import
org.h2.store.DataHandler
;
import
org.h2.store.LobStorageFrontend
;
import
org.h2.store.LobStorageInterface
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.value.CompareMode
;
...
...
@@ -613,8 +612,7 @@ public class ValueDataType implements DataType {
int
tableId
=
readVarInt
(
buff
);
long
lobId
=
readVarLong
(
buff
);
long
precision
=
readVarLong
(
buff
);
LobStorageInterface
lobStorage
=
handler
.
getLobStorage
();
ValueLobDb
lob
=
ValueLobDb
.
create
(
type
,
lobStorage
,
tableId
,
lobId
,
null
,
precision
);
ValueLobDb
lob
=
ValueLobDb
.
create
(
type
,
handler
,
tableId
,
lobId
,
null
,
precision
);
return
lob
;
}
else
{
int
tableId
=
readVarInt
(
buff
);
...
...
h2/src/main/org/h2/store/Data.java
浏览文件 @
900c76bb
...
...
@@ -805,8 +805,7 @@ public class Data {
int
tableId
=
readVarInt
();
long
lobId
=
readVarLong
();
long
precision
=
readVarLong
();
LobStorageInterface
lobStorage
=
handler
.
getLobStorage
();
ValueLobDb
lob
=
ValueLobDb
.
create
(
type
,
lobStorage
,
tableId
,
lobId
,
null
,
precision
);
ValueLobDb
lob
=
ValueLobDb
.
create
(
type
,
handler
,
tableId
,
lobId
,
null
,
precision
);
return
lob
;
}
else
{
int
tableId
=
readVarInt
();
...
...
h2/src/main/org/h2/store/LobStorageBackend.java
浏览文件 @
900c76bb
...
...
@@ -406,7 +406,7 @@ public class LobStorageBackend implements LobStorageInterface {
prep
.
setInt
(
3
,
tableId
);
prep
.
execute
();
reuse
(
sql
,
prep
);
ValueLobDb
v
=
ValueLobDb
.
create
(
type
,
this
,
tableId
,
lobId
,
null
,
byteCount
);
ValueLobDb
v
=
ValueLobDb
.
create
(
type
,
database
,
tableId
,
lobId
,
null
,
byteCount
);
return
v
;
}
catch
(
SQLException
e
)
{
throw
DbException
.
convert
(
e
);
...
...
@@ -439,7 +439,7 @@ public class LobStorageBackend implements LobStorageInterface {
prep
.
executeUpdate
();
reuse
(
sql
,
prep
);
ValueLobDb
v
=
ValueLobDb
.
create
(
type
,
this
,
tableId
,
lobId
,
null
,
length
);
ValueLobDb
v
=
ValueLobDb
.
create
(
type
,
database
,
tableId
,
lobId
,
null
,
length
);
return
v
;
}
catch
(
SQLException
e
)
{
throw
DbException
.
convert
(
e
);
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
900c76bb
...
...
@@ -206,8 +206,7 @@ public class Recover extends Tool implements DataHandler {
*/
public
static
Value
.
ValueBlob
readBlobDb
(
Connection
conn
,
long
lobId
,
long
precision
)
{
DataHandler
h
=
((
JdbcConnection
)
conn
).
getSession
().
getDataHandler
();
LobStorageInterface
lobStorage
=
h
.
getLobStorage
();
return
ValueLobDb
.
create
(
Value
.
BLOB
,
lobStorage
,
LobStorageFrontend
.
TABLE_TEMP
,
lobId
,
null
,
precision
);
return
ValueLobDb
.
create
(
Value
.
BLOB
,
h
,
LobStorageFrontend
.
TABLE_TEMP
,
lobId
,
null
,
precision
);
}
/**
...
...
@@ -215,8 +214,7 @@ public class Recover extends Tool implements DataHandler {
*/
public
static
Value
.
ValueClob
readClobDb
(
Connection
conn
,
long
lobId
,
long
precision
)
{
DataHandler
h
=
((
JdbcConnection
)
conn
).
getSession
().
getDataHandler
();
LobStorageInterface
lobStorage
=
h
.
getLobStorage
();
return
ValueLobDb
.
create
(
Value
.
CLOB
,
lobStorage
,
LobStorageFrontend
.
TABLE_TEMP
,
lobId
,
null
,
precision
);
return
ValueLobDb
.
create
(
Value
.
CLOB
,
h
,
LobStorageFrontend
.
TABLE_TEMP
,
lobId
,
null
,
precision
);
}
private
void
trace
(
String
message
)
{
...
...
h2/src/main/org/h2/value/Transfer.java
浏览文件 @
900c76bb
...
...
@@ -592,7 +592,7 @@ public class Transfer {
hmac
=
null
;
}
long
precision
=
readLong
();
return
ValueLobDb
.
create
(
Value
.
BLOB
,
session
.
getDataHandler
()
.
getLobStorage
()
,
tableId
,
id
,
hmac
,
precision
);
return
ValueLobDb
.
create
(
Value
.
BLOB
,
session
.
getDataHandler
(),
tableId
,
id
,
hmac
,
precision
);
}
int
len
=
(
int
)
length
;
byte
[]
small
=
new
byte
[
len
];
...
...
@@ -623,7 +623,7 @@ public class Transfer {
hmac
=
null
;
}
long
precision
=
readLong
();
return
ValueLobDb
.
create
(
Value
.
CLOB
,
session
.
getDataHandler
()
.
getLobStorage
()
,
tableId
,
id
,
hmac
,
precision
);
return
ValueLobDb
.
create
(
Value
.
CLOB
,
session
.
getDataHandler
(),
tableId
,
id
,
hmac
,
precision
);
}
DataReader
reader
=
new
DataReader
(
in
);
int
len
=
(
int
)
length
;
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
900c76bb
...
...
@@ -37,29 +37,25 @@ import org.h2.util.Utils;
public
class
ValueLobDb
extends
Value
implements
Value
.
ValueClob
,
Value
.
ValueBlob
{
private
final
int
type
;
private
long
precision
;
private
int
tableId
;
private
int
hash
;
private
LobStorageInterface
lobStorage
;
private
final
long
lobId
;
private
final
byte
[]
hmac
;
private
final
byte
[]
small
;
private
final
DataHandler
handler
;
private
long
precision
;
private
int
tableId
;
private
int
hash
;
private
FileStore
tempFile
;
private
String
fileName
;
private
ValueLobDb
(
int
type
,
LobStorageInterface
lobStorage
,
int
tableId
,
long
lobId
,
byte
[]
hmac
,
long
precision
)
{
private
ValueLobDb
(
int
type
,
DataHandler
handler
,
int
tableId
,
long
lobId
,
byte
[]
hmac
,
long
precision
)
{
this
.
type
=
type
;
this
.
lobStorage
=
lobStorage
;
this
.
handler
=
handler
;
this
.
tableId
=
tableId
;
this
.
lobId
=
lobId
;
this
.
hmac
=
hmac
;
this
.
precision
=
precision
;
this
.
small
=
null
;
this
.
handler
=
null
;
}
private
ValueLobDb
(
int
type
,
byte
[]
small
,
long
precision
)
{
...
...
@@ -84,16 +80,16 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
* Create a LOB value.
*
* @param type the type
* @param
lobStorage the storage
* @param
handler the data handler
* @param tableId the table id
* @param id the lob id
* @param hmac the message authentication code
* @param precision the precision (number of bytes / characters)
* @return the value
*/
public
static
ValueLobDb
create
(
int
type
,
LobStorageInterface
lobStorage
,
public
static
ValueLobDb
create
(
int
type
,
DataHandler
handler
,
int
tableId
,
long
id
,
byte
[]
hmac
,
long
precision
)
{
return
new
ValueLobDb
(
type
,
lobStorage
,
tableId
,
id
,
hmac
,
precision
);
return
new
ValueLobDb
(
type
,
handler
,
tableId
,
id
,
hmac
,
precision
);
}
/**
...
...
@@ -120,15 +116,15 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
if
(
t
==
type
)
{
return
this
;
}
else
if
(
t
==
Value
.
CLOB
)
{
if
(
lobStorage
!=
null
)
{
Value
copy
=
lobStorage
.
createClob
(
getReader
(),
-
1
);
if
(
handler
!=
null
)
{
Value
copy
=
handler
.
getLobStorage
()
.
createClob
(
getReader
(),
-
1
);
return
copy
;
}
else
if
(
small
!=
null
)
{
return
LobStorageFrontend
.
createSmallLob
(
t
,
small
);
}
}
else
if
(
t
==
Value
.
BLOB
)
{
if
(
lobStorage
!=
null
)
{
Value
copy
=
lobStorage
.
createBlob
(
getInputStream
(),
-
1
);
if
(
handler
!=
null
)
{
Value
copy
=
handler
.
getLobStorage
()
.
createBlob
(
getInputStream
(),
-
1
);
return
copy
;
}
else
if
(
small
!=
null
)
{
return
LobStorageFrontend
.
createSmallLob
(
t
,
small
);
...
...
@@ -159,9 +155,8 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
FileUtils
.
delete
(
fileName
);
}
}
if
(
lobStorage
!=
null
)
{
lobStorage
.
removeLob
(
lobId
);
lobStorage
=
null
;
if
(
handler
!=
null
)
{
handler
.
getLobStorage
().
removeLob
(
lobId
);
}
}
...
...
@@ -180,7 +175,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
database
.
getLobStorage
().
setTable
(
lobId
,
tabId
);
this
.
tableId
=
tabId
;
}
else
{
return
lobStorage
.
copyLob
(
type
,
lobId
,
tabId
,
getPrecision
());
return
handler
.
getLobStorage
()
.
copyLob
(
type
,
lobId
,
tabId
,
getPrecision
());
}
}
else
if
(
small
.
length
>
database
.
getMaxLengthInplaceLob
())
{
LobStorageInterface
s
=
database
.
getLobStorage
();
...
...
@@ -323,7 +318,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
}
long
byteCount
=
(
type
==
Value
.
BLOB
)
?
precision
:
-
1
;
try
{
return
lobStorage
.
getInputStream
(
lobId
,
hmac
,
byteCount
);
return
handler
.
getLobStorage
()
.
getInputStream
(
lobId
,
hmac
,
byteCount
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
toString
());
}
...
...
@@ -543,7 +538,6 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
private
FileStoreOutputStream
initTemp
()
throws
IOException
{
this
.
precision
=
0
;
this
.
lobStorage
=
this
.
handler
.
getLobStorage
();
String
path
=
this
.
handler
.
getDatabasePath
();
if
(
path
.
length
()
==
0
)
{
path
=
SysProperties
.
PREFIX_TEMP_FILE
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论