Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
384e5195
提交
384e5195
authored
6月 17, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove MultiVersionIndex (PageStore+MVCC)
上级
acf1f91e
全部展开
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
3 行增加
和
627 行删除
+3
-627
MultiVersionCursor.java
h2/src/main/org/h2/index/MultiVersionCursor.java
+0
-188
MultiVersionIndex.java
h2/src/main/org/h2/index/MultiVersionIndex.java
+0
-406
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+1
-8
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+1
-8
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+1
-17
没有找到文件。
h2/src/main/org/h2/index/MultiVersionCursor.java
deleted
100644 → 0
浏览文件 @
acf1f91e
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
index
;
import
org.h2.engine.Session
;
import
org.h2.engine.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
/**
* The cursor implementation for the multi-version index.
*/
public
class
MultiVersionCursor
implements
Cursor
{
private
final
MultiVersionIndex
index
;
private
final
Session
session
;
private
final
Cursor
baseCursor
,
deltaCursor
;
private
final
Object
sync
;
private
SearchRow
baseRow
;
private
Row
deltaRow
;
private
boolean
onBase
;
private
boolean
end
;
private
boolean
needNewDelta
,
needNewBase
;
private
boolean
reverse
;
MultiVersionCursor
(
Session
session
,
MultiVersionIndex
index
,
Cursor
base
,
Cursor
delta
,
Object
sync
)
{
this
.
session
=
session
;
this
.
index
=
index
;
this
.
baseCursor
=
base
;
this
.
deltaCursor
=
delta
;
this
.
sync
=
sync
;
needNewDelta
=
true
;
needNewBase
=
true
;
}
/**
* Load the current row.
*/
void
loadCurrent
()
{
synchronized
(
sync
)
{
baseRow
=
baseCursor
.
getSearchRow
();
deltaRow
=
deltaCursor
.
get
();
needNewDelta
=
false
;
needNewBase
=
false
;
}
}
private
void
loadNext
(
boolean
base
)
{
synchronized
(
sync
)
{
if
(
base
)
{
if
(
step
(
baseCursor
))
{
baseRow
=
baseCursor
.
getSearchRow
();
}
else
{
baseRow
=
null
;
}
}
else
{
if
(
step
(
deltaCursor
))
{
deltaRow
=
deltaCursor
.
get
();
}
else
{
deltaRow
=
null
;
}
}
}
}
private
boolean
step
(
Cursor
cursor
)
{
return
reverse
?
cursor
.
previous
()
:
cursor
.
next
();
}
@Override
public
Row
get
()
{
synchronized
(
sync
)
{
if
(
end
)
{
return
null
;
}
return
onBase
?
baseCursor
.
get
()
:
deltaCursor
.
get
();
}
}
@Override
public
SearchRow
getSearchRow
()
{
synchronized
(
sync
)
{
if
(
end
)
{
return
null
;
}
return
onBase
?
baseCursor
.
getSearchRow
()
:
deltaCursor
.
getSearchRow
();
}
}
@Override
public
boolean
next
()
{
synchronized
(
sync
)
{
if
(
SysProperties
.
CHECK
&&
end
)
{
DbException
.
throwInternalError
();
}
while
(
true
)
{
if
(
needNewDelta
)
{
loadNext
(
false
);
needNewDelta
=
false
;
}
if
(
needNewBase
)
{
loadNext
(
true
);
needNewBase
=
false
;
}
if
(
deltaRow
==
null
)
{
if
(
baseRow
==
null
)
{
end
=
true
;
return
false
;
}
onBase
=
true
;
needNewBase
=
true
;
return
true
;
}
int
sessionId
=
deltaRow
.
getSessionId
();
boolean
isThisSession
=
sessionId
==
session
.
getId
();
boolean
isDeleted
=
deltaRow
.
isDeleted
();
if
(
isThisSession
&&
isDeleted
)
{
needNewDelta
=
true
;
continue
;
}
if
(
baseRow
==
null
)
{
if
(
isDeleted
)
{
if
(
isThisSession
)
{
end
=
true
;
return
false
;
}
// the row was deleted by another session: return it
onBase
=
false
;
needNewDelta
=
true
;
return
true
;
}
DbException
.
throwInternalError
();
}
int
compare
=
index
.
compareRows
(
deltaRow
,
baseRow
);
if
(
compare
==
0
)
{
// can't use compareKeys because the
// version would be compared as well
long
k1
=
deltaRow
.
getKey
();
long
k2
=
baseRow
.
getKey
();
compare
=
Long
.
compare
(
k1
,
k2
);
}
if
(
compare
==
0
)
{
if
(
isDeleted
)
{
if
(
isThisSession
)
{
DbException
.
throwInternalError
();
}
// another session updated the row
}
else
{
if
(
isThisSession
)
{
onBase
=
false
;
needNewBase
=
true
;
needNewDelta
=
true
;
return
true
;
}
// another session inserted the row: ignore
needNewBase
=
true
;
needNewDelta
=
true
;
continue
;
}
}
if
(
compare
>
0
)
{
onBase
=
true
;
needNewBase
=
true
;
return
true
;
}
onBase
=
false
;
needNewDelta
=
true
;
return
true
;
}
}
}
@Override
public
boolean
previous
()
{
reverse
=
true
;
try
{
return
next
();
}
finally
{
reverse
=
false
;
}
}
}
h2/src/main/org/h2/index/MultiVersionIndex.java
deleted
100644 → 0
浏览文件 @
acf1f91e
差异被折叠。
点击展开。
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
384e5195
...
...
@@ -24,7 +24,6 @@ import org.h2.engine.SysProperties;
import
org.h2.index.Cursor
;
import
org.h2.index.Index
;
import
org.h2.index.IndexType
;
import
org.h2.index.MultiVersionIndex
;
import
org.h2.index.PageBtreeIndex
;
import
org.h2.index.PageBtreeLeaf
;
import
org.h2.index.PageBtreeNode
;
...
...
@@ -1731,13 +1730,7 @@ public class PageStore implements CacheWriter {
}
meta
=
table
.
addIndex
(
session
,
"I"
+
id
,
id
,
cols
,
indexType
,
false
,
null
);
}
PageIndex
index
;
if
(
meta
instanceof
MultiVersionIndex
)
{
index
=
(
PageIndex
)
((
MultiVersionIndex
)
meta
).
getBaseIndex
();
}
else
{
index
=
(
PageIndex
)
meta
;
}
metaObjects
.
put
(
id
,
index
);
metaObjects
.
put
(
id
,
(
PageIndex
)
meta
);
}
/**
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
384e5195
...
...
@@ -42,7 +42,6 @@ import org.h2.expression.ValueExpression;
import
org.h2.index.Index
;
import
org.h2.index.IndexType
;
import
org.h2.index.MetaIndex
;
import
org.h2.index.MultiVersionIndex
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.FileStore
;
...
...
@@ -935,13 +934,7 @@ public class MetaTable extends Table {
}
}
IndexColumn
[]
cols
=
index
.
getIndexColumns
();
String
indexClass
;
if
(
index
instanceof
MultiVersionIndex
)
{
indexClass
=
((
MultiVersionIndex
)
index
).
getBaseIndex
().
getClass
().
getName
();
}
else
{
indexClass
=
index
.
getClass
().
getName
();
}
String
indexClass
=
index
.
getClass
().
getName
();
for
(
int
k
=
0
;
k
<
cols
.
length
;
k
++)
{
IndexColumn
idxCol
=
cols
[
k
];
Column
column
=
idxCol
.
column
;
...
...
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
384e5195
...
...
@@ -26,7 +26,6 @@ import org.h2.index.Cursor;
import
org.h2.index.HashIndex
;
import
org.h2.index.Index
;
import
org.h2.index.IndexType
;
import
org.h2.index.MultiVersionIndex
;
import
org.h2.index.NonUniqueHashIndex
;
import
org.h2.index.PageBtreeIndex
;
import
org.h2.index.PageDataIndex
;
...
...
@@ -141,19 +140,7 @@ public class RegularTable extends TableBase {
trace
.
error
(
e2
,
"could not undo operation"
);
throw
e2
;
}
DbException
de
=
DbException
.
convert
(
e
);
if
(
de
.
getErrorCode
()
==
ErrorCode
.
DUPLICATE_KEY_1
)
{
for
(
Index
index
:
indexes
)
{
if
(
index
.
getIndexType
().
isUnique
()
&&
index
instanceof
MultiVersionIndex
)
{
MultiVersionIndex
mv
=
(
MultiVersionIndex
)
index
;
if
(
mv
.
isUncommittedFromOtherSession
(
session
,
row
))
{
throw
DbException
.
get
(
ErrorCode
.
CONCURRENT_UPDATE_1
,
index
.
getName
());
}
}
}
}
throw
de
;
throw
DbException
.
convert
(
e
);
}
analyzeIfRequired
(
session
);
}
...
...
@@ -259,9 +246,6 @@ public class RegularTable extends TableBase {
index
=
new
TreeIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
);
}
}
if
(
database
.
isMVStore
())
{
index
=
new
MultiVersionIndex
(
index
,
this
);
}
if
(
index
.
needRebuild
()
&&
rowCount
>
0
)
{
try
{
Index
scan
=
getScanIndex
(
session
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论