Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5116b071
提交
5116b071
authored
3月 28, 2018
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move constants into Page, cleanup
上级
98365b17
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
37 行增加
和
90 行删除
+37
-90
Session.java
h2/src/main/org/h2/engine/Session.java
+0
-1
DataUtils.java
h2/src/main/org/h2/mvstore/DataUtils.java
+0
-14
MVMapConcurrent.java
h2/src/main/org/h2/mvstore/MVMapConcurrent.java
+0
-66
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+17
-1
Page.java
h2/src/main/org/h2/mvstore/Page.java
+20
-8
没有找到文件。
h2/src/main/org/h2/engine/Session.java
浏览文件 @
5116b071
...
...
@@ -30,7 +30,6 @@ import org.h2.jdbc.JdbcConnection;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.TraceSystem
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.db.MVTable
;
import
org.h2.mvstore.db.MVTableEngine
;
import
org.h2.mvstore.db.TransactionStore.Change
;
...
...
h2/src/main/org/h2/mvstore/DataUtils.java
浏览文件 @
5116b071
...
...
@@ -138,20 +138,6 @@ public final class DataUtils {
*/
public
static
final
long
COMPRESSED_VAR_LONG_MAX
=
0x1ffffffffffff
L
;
/**
* The estimated number of bytes used per page object.
*/
public
static
final
int
PAGE_MEMORY
=
Constants
.
MEMORY_OBJECT
+
2
*
Constants
.
MEMORY_POINTER
+
22
;
//128;
public
static
final
int
PAGE_LEAF_MEMORY
=
PAGE_MEMORY
+
Constants
.
MEMORY_POINTER
;
public
static
final
int
PAGE_NODE_MEMORY
=
PAGE_MEMORY
+
Constants
.
MEMORY_POINTER
+
8
;
public
static
final
int
PAGE_LEAF_EMPTY_MEMORY
=
PAGE_LEAF_MEMORY
+
2
*
Constants
.
MEMORY_ARRAY
;
public
static
final
int
PAGE_NODE_EMPTY_MEMORY
=
PAGE_NODE_MEMORY
+
Constants
.
MEMORY_ARRAY
;
/**
* The estimated number of bytes used per child entry.
*/
public
static
final
int
PAGE_MEMORY_CHILD
=
16
;
/**
* The marker size of a very large page.
*/
...
...
h2/src/main/org/h2/mvstore/MVMapConcurrent.java
deleted
100644 → 0
浏览文件 @
98365b17
/*
* 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
.
mvstore
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.ObjectDataType
;
import
java.util.Map
;
/**
* A class used for backward compatibility.
*
* @param <K> the key type
* @param <V> the value type
*/
public
class
MVMapConcurrent
<
K
,
V
>
extends
MVMap
<
K
,
V
>
{
public
MVMapConcurrent
(
Map
<
String
,
Object
>
config
)
{
super
(
config
);
}
/**
* A builder for this class.
*
* @param <K> the key type
* @param <V> the value type
*/
public
static
class
Builder
<
K
,
V
>
extends
MVMap
.
Builder
<
K
,
V
>
{
/**
* Create a new builder with the default key and value data types.
*/
public
Builder
()
{
// ignore
}
/**
* Set the key data type.
*
* @param keyType the key type
* @return this
*/
public
Builder
<
K
,
V
>
keyType
(
DataType
keyType
)
{
setKeyType
(
keyType
);
return
this
;
}
/**
* Set the key data type.
*
* @param valueType the key type
* @return this
*/
public
Builder
<
K
,
V
>
valueType
(
DataType
valueType
)
{
setValueType
(
valueType
);
return
this
;
}
@Override
protected
MVMapConcurrent
<
K
,
V
>
create
(
Map
<
String
,
Object
>
config
)
{
return
new
MVMapConcurrent
<>(
config
);
}
}
}
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
5116b071
...
...
@@ -226,7 +226,7 @@ public final class MVStore {
private
Compressor
compressorHigh
;
p
ublic
final
UncaughtExceptionHandler
backgroundExceptionHandler
;
p
rivate
final
UncaughtExceptionHandler
backgroundExceptionHandler
;
private
volatile
long
currentVersion
;
...
...
@@ -235,8 +235,19 @@ public final class MVStore {
*/
private
long
lastStoredVersion
=
INITIAL_VERSION
;
/**
* Oldest store version in use. All version beyond this can be safely dropped
*/
private
final
AtomicLong
oldestVersionToKeep
=
new
AtomicLong
();
/**
* Collection of all versions used by currently open transactions.
*/
private
final
Deque
<
TxCounter
>
versions
=
new
LinkedList
<>();
/**
* Counter of open transactions for the latest (current) store version
*/
private
volatile
TxCounter
currentTxCounter
=
new
TxCounter
(
currentVersion
);
/**
...
...
@@ -2819,6 +2830,11 @@ public final class MVStore {
setOldestVersionToKeep
(
txCounter
!=
null
?
txCounter
.
version
:
currentTxCounter
.
version
);
}
/**
* Class TxCounter is a simple data structure to hold version of the store
* along with the counter of open transactions,
* which are still operating on this version.
*/
public
static
final
class
TxCounter
{
public
final
long
version
;
public
final
AtomicInteger
counter
=
new
AtomicInteger
();
...
...
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
5116b071
...
...
@@ -65,6 +65,18 @@ public abstract class Page implements Cloneable
*/
private
volatile
boolean
removedInMemory
;
/**
* The estimated number of bytes used per page object.
*/
private
static
final
int
PAGE_MEMORY
=
Constants
.
MEMORY_OBJECT
+
2
*
Constants
.
MEMORY_POINTER
+
Constants
.
MEMORY_ARRAY
+
17
;
protected
static
final
int
PAGE_NODE_MEMORY
=
PAGE_MEMORY
+
Constants
.
MEMORY_POINTER
+
8
+
Constants
.
MEMORY_ARRAY
;
protected
static
final
int
PAGE_LEAF_MEMORY
=
PAGE_MEMORY
+
Constants
.
MEMORY_POINTER
+
Constants
.
MEMORY_ARRAY
;
/**
* The estimated number of bytes used per child entry.
*/
protected
static
final
int
PAGE_MEMORY_CHILD
=
Constants
.
MEMORY_POINTER
+
16
;
// 16 = two longs
/**
* An empty object array.
*/
...
...
@@ -100,13 +112,13 @@ public abstract class Page implements Cloneable
*/
static
Page
createEmptyLeaf
(
MVMap
<?,
?>
map
)
{
Page
page
=
new
Leaf
(
map
,
EMPTY_OBJECT_ARRAY
,
EMPTY_OBJECT_ARRAY
);
page
.
initMemoryAccount
(
DataUtils
.
PAGE_LEAF_EMPTY
_MEMORY
);
page
.
initMemoryAccount
(
PAGE_LEAF
_MEMORY
);
return
page
;
}
public
static
Page
createEmptyNode
(
MVMap
<?,
?>
map
)
{
Page
page
=
new
NonLeaf
(
map
,
EMPTY_OBJECT_ARRAY
,
SINGLE_EMPTY
,
0
);
page
.
initMemoryAccount
(
DataUtils
.
PAGE_NODE_EMPTY
_MEMORY
);
page
.
initMemoryAccount
(
PAGE_NODE
_MEMORY
);
return
page
;
}
...
...
@@ -775,7 +787,7 @@ public abstract class Page implements Cloneable
protected
void
recalculateMemory
()
{
assert
isPersistent
();
int
mem
=
Constants
.
MEMORY_ARRAY
;
int
mem
=
0
;
DataType
keyType
=
map
.
getKeyType
();
for
(
Object
key
:
keys
)
{
mem
+=
Constants
.
MEMORY_POINTER
+
keyType
.
getMemory
(
key
);
...
...
@@ -999,7 +1011,7 @@ public abstract class Page implements Cloneable
totalCount
+=
childPage
.
getTotalCount
();
if
(
isPersistent
())
{
addMemory
(
Constants
.
MEMORY_POINTER
+
DataUtils
.
PAGE_MEMORY_CHILD
);
addMemory
(
PAGE_MEMORY_CHILD
);
}
}
...
...
@@ -1008,7 +1020,7 @@ public abstract class Page implements Cloneable
int
childCount
=
getRawChildPageCount
();
super
.
remove
(
index
);
if
(
isPersistent
())
{
addMemory
(-
(
Constants
.
MEMORY_POINTER
+
DataUtils
.
PAGE_MEMORY_CHILD
)
);
addMemory
(-
PAGE_MEMORY_CHILD
);
}
totalCount
-=
children
[
index
].
count
;
PageReference
newChildren
[]
=
new
PageReference
[
childCount
-
1
];
...
...
@@ -1116,8 +1128,8 @@ public abstract class Page implements Cloneable
@Override
protected
void
recalculateMemory
()
{
super
.
recalculateMemory
();
int
mem
=
DataUtils
.
PAGE_NODE_MEMORY
+
Constants
.
MEMORY_ARRA
Y
+
getRawChildPageCount
()
*
(
Constants
.
MEMORY_POINTER
+
DataUtils
.
PAGE_MEMORY_CHILD
)
;
int
mem
=
PAGE_NODE_MEMOR
Y
+
getRawChildPageCount
()
*
PAGE_MEMORY_CHILD
;
addMemory
(
mem
);
}
...
...
@@ -1310,7 +1322,7 @@ public abstract class Page implements Cloneable
@Override
protected
void
recalculateMemory
()
{
super
.
recalculateMemory
();
int
mem
=
DataUtils
.
PAGE_LEAF_MEMORY
+
Constants
.
MEMORY_ARRA
Y
;
int
mem
=
PAGE_LEAF_MEMOR
Y
;
DataType
valueType
=
map
.
getValueType
();
for
(
Object
value
:
values
)
{
mem
+=
valueType
.
getMemory
(
value
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论