Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
96601cb8
提交
96601cb8
authored
4月 26, 2012
作者:
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;
...
@@ -22,6 +22,8 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.expression.ParameterInterface
;
import
org.h2.expression.ParameterInterface
;
...
@@ -62,6 +64,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -62,6 +64,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
protected
CommandInterface
command
;
protected
CommandInterface
command
;
private
final
String
sqlStatement
;
private
final
String
sqlStatement
;
private
ArrayList
<
Value
[]>
batchParameters
;
private
ArrayList
<
Value
[]>
batchParameters
;
private
HashMap
<
String
,
Integer
>
cachedColumnLabelMap
=
null
;
JdbcPreparedStatement
(
JdbcConnection
conn
,
String
sql
,
int
id
,
int
resultSetType
,
JdbcPreparedStatement
(
JdbcConnection
conn
,
String
sql
,
int
id
,
int
resultSetType
,
int
resultSetConcurrency
,
boolean
closeWithResultSet
)
{
int
resultSetConcurrency
,
boolean
closeWithResultSet
)
{
...
@@ -71,6 +74,14 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -71,6 +74,14 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
command
=
conn
.
prepareCommand
(
sql
,
fetchSize
);
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
* Executes a query (select statement) and returns the result set. If
* another result set exists for this statement, this will be closed (even
* another result set exists for this statement, this will be closed (even
...
@@ -97,7 +108,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
...
@@ -97,7 +108,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
}
finally
{
}
finally
{
setExecutingStatement
(
null
);
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
;
return
resultSet
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
96601cb8
...
@@ -91,6 +91,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
...
@@ -91,6 +91,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
private
Value
[]
updateRow
;
private
Value
[]
updateRow
;
private
HashMap
<
String
,
Integer
>
columnLabelMap
;
private
HashMap
<
String
,
Integer
>
columnLabelMap
;
private
HashMap
<
Integer
,
Value
[]>
patchedRows
;
private
HashMap
<
Integer
,
Value
[]>
patchedRows
;
private
JdbcPreparedStatement
preparedStatement
=
null
;
JdbcResultSet
(
JdbcConnection
conn
,
JdbcStatement
stat
,
ResultInterface
result
,
int
id
,
JdbcResultSet
(
JdbcConnection
conn
,
JdbcStatement
stat
,
ResultInterface
result
,
int
id
,
boolean
closeStatement
,
boolean
scrollable
,
boolean
updatable
)
{
boolean
closeStatement
,
boolean
scrollable
,
boolean
updatable
)
{
...
@@ -103,6 +104,16 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
...
@@ -103,6 +104,16 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
this
.
scrollable
=
scrollable
;
this
.
scrollable
=
scrollable
;
this
.
updatable
=
updatable
;
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.
* Moves the cursor to the next row of the result set.
...
@@ -2876,6 +2887,9 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
...
@@ -2876,6 +2887,9 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
}
// assign at the end so concurrent access is supported
// assign at the end so concurrent access is supported
columnLabelMap
=
map
;
columnLabelMap
=
map
;
if
(
preparedStatement
!=
null
)
{
preparedStatement
.
setCachedColumnLabelMap
(
columnLabelMap
);
}
}
}
Integer
index
=
columnLabelMap
.
get
(
StringUtils
.
toUpperEnglish
(
columnLabel
));
Integer
index
=
columnLabelMap
.
get
(
StringUtils
.
toUpperEnglish
(
columnLabel
));
if
(
index
==
null
)
{
if
(
index
==
null
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论