Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
68ef8e9c
提交
68ef8e9c
authored
7 年前
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tryCommit inroduced, some class finals removed, based on code review
上级
7384fd28
master
version-1.4.198
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
59 行增加
和
40 行删除
+59
-40
Cursor.java
h2/src/main/org/h2/mvstore/Cursor.java
+1
-1
CursorPos.java
h2/src/main/org/h2/mvstore/CursorPos.java
+1
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+55
-36
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+2
-2
没有找到文件。
h2/src/main/org/h2/mvstore/Cursor.java
浏览文件 @
68ef8e9c
...
...
@@ -13,7 +13,7 @@ import java.util.Iterator;
* @param <K> the key type
* @param <V> the value type
*/
public
final
class
Cursor
<
K
,
V
>
implements
Iterator
<
K
>
{
public
class
Cursor
<
K
,
V
>
implements
Iterator
<
K
>
{
private
final
K
to
;
private
CursorPos
cursorPos
;
private
CursorPos
keeper
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/CursorPos.java
浏览文件 @
68ef8e9c
...
...
@@ -8,7 +8,7 @@ package org.h2.mvstore;
/**
* A position in a cursor
*/
public
final
class
CursorPos
{
public
class
CursorPos
{
/**
* The current page.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
68ef8e9c
...
...
@@ -127,7 +127,7 @@ MVStore:
/**
* A persistent storage for maps.
*/
public
final
class
MVStore
{
public
class
MVStore
{
/**
* Whether assertions are enabled.
...
...
@@ -1037,6 +1037,25 @@ public final class MVStore {
onVersionChange
(
version
);
}
/**
* Unlike regular commit this method returns immediately if there is commit
* in progress on another thread, otherwise it acts as regular commit.
*
* This method may return BEFORE this thread changes are actually persisted!
*
* @return the new version (incremented if there were changes)
*/
public
long
tryCommit
()
{
// unlike synchronization, this will also prevent re-entrance,
// which may be possible, if the meta map have changed
if
(
currentStoreThread
.
compareAndSet
(
null
,
Thread
.
currentThread
()))
{
synchronized
(
this
)
{
store
();
}
}
return
currentVersion
;
}
/**
* Commit the changes.
* <p>
...
...
@@ -1053,42 +1072,42 @@ public final class MVStore {
*
* @return the new version (incremented if there were changes)
*/
public
long
commit
()
{
// unlike synchronization, this will also prevent re-entrance,
// which may be possible, if the meta map have changed
if
(
currentStoreThread
.
compareAndSet
(
null
,
Thread
.
currentThread
()))
{
synchronized
(
this
)
{
try
{
currentStoreVersion
=
currentVersion
;
if
(!
closed
&&
hasUnsavedChangesInternal
())
{
if
(
fileStore
==
null
)
{
lastStoredVersion
=
currentVersion
;
++
currentVersion
;
setWriteVersion
(
currentVersion
);
metaChanged
=
false
;
}
else
{
if
(
fileStore
.
isReadOnly
())
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_WRITING_FAILED
,
"This store is read-only"
);
}
try
{
storeNow
();
}
catch
(
IllegalStateException
e
)
{
panic
(
e
);
}
catch
(
Throwable
e
)
{
panic
(
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_INTERNAL
,
e
.
toString
(),
e
));
}
}
public
synchronized
long
commit
()
{
currentStoreThread
.
set
(
Thread
.
currentThread
());
store
();
return
currentVersion
;
}
private
void
store
()
{
try
{
if
(!
closed
&&
hasUnsavedChangesInternal
())
{
currentStoreVersion
=
currentVersion
;
if
(
fileStore
==
null
)
{
lastStoredVersion
=
currentVersion
;
//noinspection NonAtomicOperationOnVolatileField
++
currentVersion
;
setWriteVersion
(
currentVersion
);
metaChanged
=
false
;
}
else
{
if
(
fileStore
.
isReadOnly
())
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_WRITING_FAILED
,
"This store is read-only"
);
}
try
{
storeNow
();
}
catch
(
IllegalStateException
e
)
{
panic
(
e
);
}
catch
(
Throwable
e
)
{
panic
(
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_INTERNAL
,
e
.
toString
(),
e
));
}
}
finally
{
// in any case reset the current store version,
// to allow closing the store
currentStoreVersion
=
-
1
;
currentStoreThread
.
set
(
null
);
}
}
}
return
currentVersion
;
}
finally
{
// in any case reset the current store version,
// to allow closing the store
currentStoreVersion
=
-
1
;
currentStoreThread
.
set
(
null
);
}
}
private
void
storeNow
()
{
...
...
@@ -2283,7 +2302,7 @@ public final class MVStore {
saveNeeded
=
false
;
// check again, because it could have been written by now
if
(
unsavedMemory
>
autoCommitMemory
&&
autoCommitMemory
>
0
)
{
c
ommit
();
tryC
ommit
();
}
}
}
...
...
@@ -2578,7 +2597,7 @@ public final class MVStore {
if
(
time
<=
lastCommitTime
+
autoCommitDelay
)
{
return
;
}
c
ommit
();
tryC
ommit
();
if
(
autoCompactFillRate
>
0
)
{
// whether there were file read or write operations since
// the last time
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
68ef8e9c
...
...
@@ -475,7 +475,7 @@ public class TransactionStore {
t
.
setStatus
(
Transaction
.
STATUS_CLOSED
);
openTransactions
.
clear
(
t
.
transactionId
);
if
(
oldStatus
==
Transaction
.
STATUS_PREPARED
||
store
.
getAutoCommitDelay
()
==
0
)
{
store
.
c
ommit
();
store
.
tryC
ommit
();
return
;
}
// to avoid having to store the transaction log,
...
...
@@ -486,7 +486,7 @@ public class TransactionStore {
int
max
=
store
.
getAutoCommitMemory
();
// save at 3/4 capacity
if
(
unsaved
*
4
>
max
*
3
)
{
store
.
c
ommit
();
store
.
tryC
ommit
();
}
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论