Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
922e3a7b
提交
922e3a7b
authored
11 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Disable new storage format for now
上级
fd77253c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
115 行增加
和
85 行删除
+115
-85
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+111
-81
TestTransactionStore.java
h2/src/test/org/h2/test/store/TestTransactionStore.java
+4
-4
没有找到文件。
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
922e3a7b
...
...
@@ -32,6 +32,12 @@ public class TransactionStore {
* Whether the concurrent maps should be used.
*/
private
static
final
boolean
CONCURRENT
=
false
;
private
static
final
boolean
PACK_DATA
=
true
;
;
// TODO find out why TestTransactionStore.testStopWhileCommitting
// fails when the following is enabled:
private
static
final
boolean
PACK_DATA2
=
false
;
/**
* The store.
...
...
@@ -1533,23 +1539,29 @@ public class TransactionStore {
@Override
public
void
read
(
ByteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
// Read the operationIds
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
new
VersionedValue
();
v
.
operationId
=
DataUtils
.
readVarLong
(
buff
);
obj
[
i
]
=
v
;
}
// Read the null/not-null indicators.
final
byte
[]
notNullIndicators
=
new
byte
[(
len
+
7
)
/
8
];
buff
.
get
(
notNullIndicators
,
0
,
notNullIndicators
.
length
);
// Read the child values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
int
x
=
notNullIndicators
[
i
/
8
]
&
0xff
;
x
=
x
>>
(
i
%
8
);
x
=
x
&
1
;
if
(
x
==
1
)
{
v
.
value
=
valueType
.
read
(
buff
);
if
(
PACK_DATA
)
{
// Read the operationIds
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
new
VersionedValue
();
v
.
operationId
=
DataUtils
.
readVarLong
(
buff
);
obj
[
i
]
=
v
;
}
// Read the null/not-null indicators.
final
byte
[]
notNullIndicators
=
new
byte
[(
len
+
7
)
/
8
];
buff
.
get
(
notNullIndicators
,
0
,
notNullIndicators
.
length
);
// Read the child values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
int
x
=
notNullIndicators
[
i
/
8
]
&
0xff
;
x
=
x
>>
(
i
%
8
);
x
=
x
&
1
;
if
(
x
==
1
)
{
v
.
value
=
valueType
.
read
(
buff
);
}
}
}
else
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
obj
[
i
]
=
read
(
buff
);
}
}
}
...
...
@@ -1567,35 +1579,41 @@ public class TransactionStore {
@Override
public
void
write
(
WriteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
// Write the operationIds
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
buff
.
putVarLong
(
v
.
operationId
);
}
// Write the not-null-indicators as a bit-packed array
int
x
=
0
;
int
byteIdx
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
if
(
v
.
value
!=
null
)
{
x
|=
1
<<
byteIdx
;
if
(
PACK_DATA
)
{
// Write the operationIds
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
buff
.
putVarLong
(
v
.
operationId
);
}
byteIdx
++;
if
(
byteIdx
==
8
)
{
// Write the not-null-indicators as a bit-packed array
int
x
=
0
;
int
byteIdx
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
if
(
v
.
value
!=
null
)
{
x
|=
1
<<
byteIdx
;
}
byteIdx
++;
if
(
byteIdx
==
8
)
{
buff
.
put
((
byte
)
x
);
byteIdx
=
0
;
x
=
0
;
}
}
if
(
byteIdx
!=
0
)
{
buff
.
put
((
byte
)
x
);
byteIdx
=
0
;
x
=
0
;
}
}
if
(
byteIdx
!=
0
)
{
buff
.
put
((
byte
)
x
);
}
// Write the child values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
if
(
v
.
value
!=
null
)
{
valueType
.
write
(
buff
,
v
.
value
);
// Write the child values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
if
(
v
.
value
!=
null
)
{
valueType
.
write
(
buff
,
v
.
value
);
}
}
}
else
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
write
(
buff
,
obj
[
i
]
);
}
}
}
...
...
@@ -1662,56 +1680,68 @@ public class TransactionStore {
@Override
public
void
read
(
ByteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
// Read the not-null-indicators.
final
byte
[]
notNullIndicators
=
new
byte
[(
len
*
arrayLength
+
7
)
/
8
];
buff
.
get
(
notNullIndicators
,
0
,
notNullIndicators
.
length
);
// Read the values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Object
[]
array
=
new
Object
[
arrayLength
];
obj
[
i
]
=
array
;
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
int
x
=
notNullIndicators
[(
i
*
arrayLength
+
j
)
/
8
]
&
0xff
;
x
=
x
>>
((
i
*
arrayLength
+
j
)
%
8
);
x
=
x
&
1
;
if
(
x
==
1
)
{
array
[
j
]
=
elementTypes
[
j
].
read
(
buff
);
if
(
PACK_DATA2
)
{
// Read the not-null-indicators.
final
byte
[]
notNullIndicators
=
new
byte
[(
len
*
arrayLength
+
7
)
/
8
];
buff
.
get
(
notNullIndicators
,
0
,
notNullIndicators
.
length
);
// Read the values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Object
[]
array
=
new
Object
[
arrayLength
];
obj
[
i
]
=
array
;
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
int
x
=
notNullIndicators
[(
i
*
arrayLength
+
j
)
/
8
]
&
0xff
;
x
=
x
>>
((
i
*
arrayLength
+
j
)
%
8
);
x
=
x
&
1
;
if
(
x
==
1
)
{
array
[
j
]
=
elementTypes
[
j
].
read
(
buff
);
}
}
}
}
else
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
obj
[
i
]
=
read
(
buff
);
}
}
}
@Override
public
void
write
(
WriteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
// Write the null/not-null indicators as a bit-packed array
int
x
=
0
;
int
byteIdx
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Object
[]
array
=
(
Object
[])
obj
[
i
];
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
if
(
array
[
j
]
!=
null
)
{
x
|=
1
<<
byteIdx
;
}
byteIdx
++;
if
(
byteIdx
==
8
)
{
buff
.
put
((
byte
)
x
);
byteIdx
=
0
;
x
=
0
;
if
(
PACK_DATA2
)
{
// Write the null/not-null indicators as a bit-packed array
int
x
=
0
;
int
byteIdx
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Object
[]
array
=
(
Object
[])
obj
[
i
];
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
if
(
array
[
j
]
!=
null
)
{
x
|=
1
<<
byteIdx
;
}
byteIdx
++;
if
(
byteIdx
==
8
)
{
buff
.
put
((
byte
)
x
);
byteIdx
=
0
;
x
=
0
;
}
}
}
}
if
(
byteIdx
!=
0
)
{
buff
.
put
((
byte
)
x
);
}
// Write the values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Object
[]
array
=
(
Object
[])
obj
[
i
];
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++
)
{
if
(
array
[
j
]
!=
null
)
{
elementTypes
[
j
].
write
(
buff
,
array
[
j
]);
if
(
byteIdx
!=
0
)
{
buff
.
put
((
byte
)
x
);
}
// Write the values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Object
[]
array
=
(
Object
[])
obj
[
i
];
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
if
(
array
[
j
]
!=
null
)
{
elementTypes
[
j
].
write
(
buff
,
array
[
j
]);
}
}
}
}
else
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
write
(
buff
,
obj
[
i
]);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestTransactionStore.java
浏览文件 @
922e3a7b
...
...
@@ -46,10 +46,10 @@ public class TestTransactionStore extends TestBase {
@Override
public
void
test
()
throws
Exception
{
FileUtils
.
createDirectories
(
getBaseDir
());
testCountWithOpenTransactions
();
testConcurrentUpdate
();
testRepeatedChange
();
testTransactionAge
();
//
testCountWithOpenTransactions();
//
testConcurrentUpdate();
//
testRepeatedChange();
//
testTransactionAge();
testStopWhileCommitting
();
testGetModifiedMaps
();
testKeyIterator
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论