Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
922e3a7b
提交
922e3a7b
authored
4月 01, 2014
作者:
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 {
...
@@ -32,6 +32,12 @@ public class TransactionStore {
* Whether the concurrent maps should be used.
* Whether the concurrent maps should be used.
*/
*/
private
static
final
boolean
CONCURRENT
=
false
;
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.
* The store.
...
@@ -1533,23 +1539,29 @@ public class TransactionStore {
...
@@ -1533,23 +1539,29 @@ public class TransactionStore {
@Override
@Override
public
void
read
(
ByteBuffer
buff
,
Object
[]
obj
,
public
void
read
(
ByteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
int
len
,
boolean
key
)
{
// Read the operationIds
if
(
PACK_DATA
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
// Read the operationIds
VersionedValue
v
=
new
VersionedValue
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
v
.
operationId
=
DataUtils
.
readVarLong
(
buff
);
VersionedValue
v
=
new
VersionedValue
();
obj
[
i
]
=
v
;
v
.
operationId
=
DataUtils
.
readVarLong
(
buff
);
}
obj
[
i
]
=
v
;
// Read the null/not-null indicators.
}
final
byte
[]
notNullIndicators
=
new
byte
[(
len
+
7
)
/
8
];
// Read the null/not-null indicators.
buff
.
get
(
notNullIndicators
,
0
,
notNullIndicators
.
length
);
final
byte
[]
notNullIndicators
=
new
byte
[(
len
+
7
)
/
8
];
// Read the child values.
buff
.
get
(
notNullIndicators
,
0
,
notNullIndicators
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
// Read the child values.
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
x
=
notNullIndicators
[
i
/
8
]
&
0xff
;
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
x
=
x
>>
(
i
%
8
);
int
x
=
notNullIndicators
[
i
/
8
]
&
0xff
;
x
=
x
&
1
;
x
=
x
>>
(
i
%
8
);
if
(
x
==
1
)
{
x
=
x
&
1
;
v
.
value
=
valueType
.
read
(
buff
);
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 {
...
@@ -1567,35 +1579,41 @@ public class TransactionStore {
@Override
@Override
public
void
write
(
WriteBuffer
buff
,
Object
[]
obj
,
public
void
write
(
WriteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
int
len
,
boolean
key
)
{
// Write the operationIds
if
(
PACK_DATA
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
// Write the operationIds
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
buff
.
putVarLong
(
v
.
operationId
);
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
;
}
}
byteIdx
++;
// Write the not-null-indicators as a bit-packed array
if
(
byteIdx
==
8
)
{
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
);
buff
.
put
((
byte
)
x
);
byteIdx
=
0
;
x
=
0
;
}
}
// Write the child values.
}
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(
byteIdx
!=
0
)
{
VersionedValue
v
=
(
VersionedValue
)
obj
[
i
];
buff
.
put
((
byte
)
x
);
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
];
}
else
{
if
(
v
.
value
!=
null
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
valueType
.
write
(
buff
,
v
.
value
);
write
(
buff
,
obj
[
i
]
);
}
}
}
}
}
}
...
@@ -1662,56 +1680,68 @@ public class TransactionStore {
...
@@ -1662,56 +1680,68 @@ public class TransactionStore {
@Override
@Override
public
void
read
(
ByteBuffer
buff
,
Object
[]
obj
,
public
void
read
(
ByteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
int
len
,
boolean
key
)
{
// Read the not-null-indicators.
if
(
PACK_DATA2
)
{
final
byte
[]
notNullIndicators
=
new
byte
[(
len
*
arrayLength
+
7
)
/
8
];
// Read the not-null-indicators.
buff
.
get
(
notNullIndicators
,
0
,
notNullIndicators
.
length
);
final
byte
[]
notNullIndicators
=
new
byte
[(
len
*
arrayLength
+
7
)
/
8
];
// Read the values.
buff
.
get
(
notNullIndicators
,
0
,
notNullIndicators
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
// Read the values.
Object
[]
array
=
new
Object
[
arrayLength
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
obj
[
i
]
=
array
;
Object
[]
array
=
new
Object
[
arrayLength
];
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
obj
[
i
]
=
array
;
int
x
=
notNullIndicators
[(
i
*
arrayLength
+
j
)
/
8
]
&
0xff
;
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
x
=
x
>>
((
i
*
arrayLength
+
j
)
%
8
);
int
x
=
notNullIndicators
[(
i
*
arrayLength
+
j
)
/
8
]
&
0xff
;
x
=
x
&
1
;
x
=
x
>>
((
i
*
arrayLength
+
j
)
%
8
);
if
(
x
==
1
)
{
x
=
x
&
1
;
array
[
j
]
=
elementTypes
[
j
].
read
(
buff
);
if
(
x
==
1
)
{
array
[
j
]
=
elementTypes
[
j
].
read
(
buff
);
}
}
}
}
}
}
else
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
obj
[
i
]
=
read
(
buff
);
}
}
}
}
}
@Override
@Override
public
void
write
(
WriteBuffer
buff
,
Object
[]
obj
,
public
void
write
(
WriteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
int
len
,
boolean
key
)
{
// Write the null/not-null indicators as a bit-packed array
if
(
PACK_DATA2
)
{
int
x
=
0
;
// Write the null/not-null indicators as a bit-packed array
int
byteIdx
=
0
;
int
x
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
byteIdx
=
0
;
Object
[]
array
=
(
Object
[])
obj
[
i
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
Object
[]
array
=
(
Object
[])
obj
[
i
];
if
(
array
[
j
]
!=
null
)
{
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
x
|=
1
<<
byteIdx
;
if
(
array
[
j
]
!=
null
)
{
}
x
|=
1
<<
byteIdx
;
byteIdx
++;
}
if
(
byteIdx
==
8
)
{
byteIdx
++;
buff
.
put
((
byte
)
x
);
if
(
byteIdx
==
8
)
{
byteIdx
=
0
;
buff
.
put
((
byte
)
x
);
x
=
0
;
byteIdx
=
0
;
x
=
0
;
}
}
}
}
}
}
if
(
byteIdx
!=
0
)
{
if
(
byteIdx
!=
0
)
{
buff
.
put
((
byte
)
x
);
buff
.
put
((
byte
)
x
);
}
}
// Write the values.
// Write the values.
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Object
[]
array
=
(
Object
[])
obj
[
i
];
Object
[]
array
=
(
Object
[])
obj
[
i
];
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++)
{
for
(
int
j
=
0
;
j
<
arrayLength
;
j
++
)
{
if
(
array
[
j
]
!=
null
)
{
if
(
array
[
j
]
!=
null
)
{
elementTypes
[
j
].
write
(
buff
,
array
[
j
]);
elementTypes
[
j
].
write
(
buff
,
array
[
j
]);
}
}
}
}
}
}
else
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
write
(
buff
,
obj
[
i
]);
}
}
}
}
}
...
...
h2/src/test/org/h2/test/store/TestTransactionStore.java
浏览文件 @
922e3a7b
...
@@ -46,10 +46,10 @@ public class TestTransactionStore extends TestBase {
...
@@ -46,10 +46,10 @@ public class TestTransactionStore extends TestBase {
@Override
@Override
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
FileUtils
.
createDirectories
(
getBaseDir
());
FileUtils
.
createDirectories
(
getBaseDir
());
testCountWithOpenTransactions
();
//
testCountWithOpenTransactions();
testConcurrentUpdate
();
//
testConcurrentUpdate();
testRepeatedChange
();
//
testRepeatedChange();
testTransactionAge
();
//
testTransactionAge();
testStopWhileCommitting
();
testStopWhileCommitting
();
testGetModifiedMaps
();
testGetModifiedMaps
();
testKeyIterator
();
testKeyIterator
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论