Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
96601cb8
提交
96601cb8
authored
13 年前
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimise the case where we are accessing the ResultSet column values by name.
Patch by Carl Hasselskog (carl@degoo.com)
上级
7498557c
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
26 行增加
和
1 行删除
+26
-1
JdbcPreparedStatement.java
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
+12
-1
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+14
-0
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcPreparedStatement.java
浏览文件 @
96601cb8
...
...
@@ -22,6 +22,8 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
org.h2.command.CommandInterface
;
import
org.h2.constant.ErrorCode
;
import
org.h2.expression.ParameterInterface
;
...
...
@@ -62,6 +64,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
protected
CommandInterface
command
;
private
final
String
sqlStatement
;
private
ArrayList
<
Value
[]>
batchParameters
;
private
HashMap
<
String
,
Integer
>
cachedColumnLabelMap
=
null
;
JdbcPreparedStatement
(
JdbcConnection
conn
,
String
sql
,
int
id
,
int
resultSetType
,
int
resultSetConcurrency
,
boolean
closeWithResultSet
)
{
...
...
@@ -71,6 +74,14 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
}
/**
* Looking up the column index can sometimes show up on the performance profile,
* so cache the map.
*/
void
setCachedColumnLabelMap
(
HashMap
<
String
,
Integer
>
cachedColumnLabelMap
)
{
this
.
cachedColumnLabelMap
=
cachedColumnLabelMap
;
}
/**
* Executes a query (select statement) and returns the result set. If
* another result set exists for this statement, this will be closed (even
...
...
@@ -97,7 +108,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
}
finally
{
setExecutingStatement
(
null
);
}
resultSet
=
new
JdbcResultSet
(
conn
,
this
,
result
,
id
,
closedByResultSet
,
scrollable
,
updatable
);
resultSet
=
new
JdbcResultSet
(
conn
,
this
,
result
,
id
,
closedByResultSet
,
scrollable
,
updatable
,
cachedColumnLabelMap
);
}
return
resultSet
;
}
catch
(
Exception
e
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
96601cb8
...
...
@@ -91,6 +91,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
private
Value
[]
updateRow
;
private
HashMap
<
String
,
Integer
>
columnLabelMap
;
private
HashMap
<
Integer
,
Value
[]>
patchedRows
;
private
JdbcPreparedStatement
preparedStatement
=
null
;
JdbcResultSet
(
JdbcConnection
conn
,
JdbcStatement
stat
,
ResultInterface
result
,
int
id
,
boolean
closeStatement
,
boolean
scrollable
,
boolean
updatable
)
{
...
...
@@ -104,6 +105,16 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
this
.
updatable
=
updatable
;
}
/**
* Overload used to explicitly set the column-mapping.
*/
JdbcResultSet
(
JdbcConnection
conn
,
JdbcPreparedStatement
preparedStatement
,
ResultInterface
result
,
int
id
,
boolean
closeStatement
,
boolean
scrollable
,
boolean
updatable
,
HashMap
<
String
,
Integer
>
columnLabelMap
)
{
this
(
conn
,
preparedStatement
,
result
,
id
,
closeStatement
,
scrollable
,
updatable
);
this
.
columnLabelMap
=
columnLabelMap
;
this
.
preparedStatement
=
preparedStatement
;
}
/**
* Moves the cursor to the next row of the result set.
*
...
...
@@ -2876,6 +2887,9 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
// assign at the end so concurrent access is supported
columnLabelMap
=
map
;
if
(
preparedStatement
!=
null
)
{
preparedStatement
.
setCachedColumnLabelMap
(
columnLabelMap
);
}
}
Integer
index
=
columnLabelMap
.
get
(
StringUtils
.
toUpperEnglish
(
columnLabel
));
if
(
index
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论