Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bbea3c39
提交
bbea3c39
authored
11月 14, 2015
作者:
S.Vladykin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Session local view index cache.
上级
2e613734
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
36 行删除
+23
-36
Session.java
h2/src/main/org/h2/engine/Session.java
+9
-1
TableView.java
h2/src/main/org/h2/table/TableView.java
+14
-35
没有找到文件。
h2/src/main/org/h2/engine/Session.java
浏览文件 @
bbea3c39
...
...
@@ -19,6 +19,7 @@ import org.h2.command.Prepared;
import
org.h2.command.dml.SetTypes
;
import
org.h2.constraint.Constraint
;
import
org.h2.index.Index
;
import
org.h2.index.ViewIndex
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
...
...
@@ -111,6 +112,7 @@ public class Session extends SessionWithState {
private
long
modificationMetaID
=
-
1
;
private
SubQueryInfo
subQueryInfo
;
private
int
parsingView
;
private
SmallLRUCache
<
Object
,
ViewIndex
>
viewIndexCache
;
/**
* Temporary LOBs from result sets. Those are kept for some time. The
...
...
@@ -1313,6 +1315,13 @@ public class Session extends SessionWithState {
}
}
public
SmallLRUCache
<
Object
,
ViewIndex
>
getViewIndexCache
()
{
if
(
viewIndexCache
==
null
)
{
viewIndexCache
=
SmallLRUCache
.
newInstance
(
Constants
.
VIEW_INDEX_CACHE_SIZE
);
}
return
viewIndexCache
;
}
/**
* Remember the result set and close it as soon as the transaction is
* committed (if it needs to be closed). This is done to delete temporary
...
...
@@ -1549,5 +1558,4 @@ public class Session extends SessionWithState {
}
}
}
h2/src/main/org/h2/table/TableView.java
浏览文件 @
bbea3c39
...
...
@@ -32,7 +32,6 @@ import org.h2.util.New;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.SynchronizedVerifier
;
import
org.h2.value.Value
;
/**
...
...
@@ -51,8 +50,6 @@ public class TableView extends Table {
private
ViewIndex
index
;
private
boolean
recursive
;
private
DbException
createException
;
private
final
SmallLRUCache
<
CacheKey
,
ViewIndex
>
indexCache
=
SmallLRUCache
.
newInstance
(
Constants
.
VIEW_INDEX_CACHE_SIZE
);
private
long
lastModificationCheck
;
private
long
maxDataModificationId
;
private
User
owner
;
...
...
@@ -97,8 +94,6 @@ public class TableView extends Table {
this
.
columnNames
=
columnNames
;
this
.
recursive
=
recursive
;
index
=
new
ViewIndex
(
this
,
querySQL
,
params
,
recursive
);
SynchronizedVerifier
.
check
(
indexCache
);
indexCache
.
clear
();
initColumnsAndTables
(
session
);
}
...
...
@@ -136,8 +131,6 @@ public class TableView extends Table {
if
(
views
!=
null
)
{
views
=
New
.
arrayList
(
views
);
}
SynchronizedVerifier
.
check
(
indexCache
);
indexCache
.
clear
();
initColumnsAndTables
(
session
);
if
(
views
!=
null
)
{
for
(
TableView
v
:
views
)
{
...
...
@@ -234,30 +227,16 @@ public class TableView extends Table {
TableFilter
[]
filters
,
int
filter
,
SortOrder
sortOrder
)
{
PlanItem
item
=
new
PlanItem
();
item
.
cost
=
index
.
getCost
(
session
,
masks
,
filters
,
filter
,
sortOrder
);
final
CacheKey
cacheKey
=
new
CacheKey
(
masks
,
session
);
synchronized
(
this
)
{
SynchronizedVerifier
.
check
(
indexCache
);
ViewIndex
i2
=
indexCache
.
get
(
cacheKey
);
if
(
i2
!=
null
)
{
item
.
setIndex
(
i2
);
return
item
;
}
}
// We cannot hold the lock during the ViewIndex creation or we risk ABBA
// deadlocks if the view creation calls back into H2 via something like
// a FunctionTable.
ViewIndex
i2
=
new
ViewIndex
(
this
,
index
,
session
,
masks
,
filters
,
filter
,
sortOrder
);
synchronized
(
this
)
{
// have to check again in case another session has beat us to it
ViewIndex
i3
=
indexCache
.
get
(
cacheKey
);
if
(
i3
!=
null
)
{
item
.
setIndex
(
i3
);
return
item
;
}
indexCache
.
put
(
cacheKey
,
i2
);
item
.
setIndex
(
i2
);
final
CacheKey
cacheKey
=
new
CacheKey
(
masks
,
this
);
SmallLRUCache
<
Object
,
ViewIndex
>
indexCache
=
session
.
getViewIndexCache
();
ViewIndex
i
=
indexCache
.
get
(
cacheKey
);
if
(
i
!=
null
)
{
item
.
setIndex
(
i
);
return
item
;
}
i
=
new
ViewIndex
(
this
,
index
,
session
,
masks
,
filters
,
filter
,
sortOrder
);
indexCache
.
put
(
cacheKey
,
i
);
item
.
setIndex
(
i
);
return
item
;
}
...
...
@@ -596,11 +575,11 @@ public class TableView extends Table {
private
static
final
class
CacheKey
{
private
final
int
[]
masks
;
private
final
Session
session
;
private
final
TableView
view
;
public
CacheKey
(
int
[]
masks
,
Session
session
)
{
public
CacheKey
(
int
[]
masks
,
TableView
view
)
{
this
.
masks
=
masks
;
this
.
session
=
session
;
this
.
view
=
view
;
}
@Override
...
...
@@ -608,7 +587,7 @@ public class TableView extends Table {
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
Arrays
.
hashCode
(
masks
);
result
=
prime
*
result
+
session
.
hashCode
();
result
=
prime
*
result
+
view
.
hashCode
();
return
result
;
}
...
...
@@ -624,7 +603,7 @@ public class TableView extends Table {
return
false
;
}
CacheKey
other
=
(
CacheKey
)
obj
;
if
(
session
!=
other
.
session
)
{
if
(
view
!=
other
.
view
)
{
return
false
;
}
if
(!
Arrays
.
equals
(
masks
,
other
.
masks
))
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论