Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3a92ea32
提交
3a92ea32
authored
11月 04, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A persistent multi-version map: a utility to store and read streams
上级
b568eadd
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
192 行增加
和
129 行删除
+192
-129
TestStreamStore.java
h2/src/test/org/h2/test/store/TestStreamStore.java
+62
-12
StreamStore.java
h2/src/tools/org/h2/dev/store/btree/StreamStore.java
+130
-117
没有找到文件。
h2/src/test/org/h2/test/store/TestStreamStore.java
浏览文件 @
3a92ea32
...
@@ -21,7 +21,7 @@ import org.h2.util.IOUtils;
...
@@ -21,7 +21,7 @@ import org.h2.util.IOUtils;
import
org.h2.util.New
;
import
org.h2.util.New
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
// import org.junit.Test;
// import org.junit.Test;
//import static org.junit.Assert.*;
//
import static org.junit.Assert.*;
/**
/**
* Test the stream store.
* Test the stream store.
...
@@ -39,12 +39,62 @@ public class TestStreamStore extends TestBase {
...
@@ -39,12 +39,62 @@ public class TestStreamStore extends TestBase {
@Override
@Override
public
void
test
()
throws
IOException
{
public
void
test
()
throws
IOException
{
testDetectIllegalId
();
testTreeStructure
();
testFormat
();
testFormat
();
testWithExistingData
();
testWithExistingData
();
testWithFullMap
();
testWithFullMap
();
testLoop
();
testLoop
();
}
}
public
void
testDetectIllegalId
()
throws
IOException
{
Map
<
Long
,
byte
[]>
map
=
New
.
hashMap
();
StreamStore
store
=
new
StreamStore
(
map
);
try
{
store
.
length
(
new
byte
[]{
3
,
0
,
0
});
fail
();
}
catch
(
IllegalArgumentException
e
)
{
// expected
}
try
{
store
.
remove
(
new
byte
[]{
3
,
0
,
0
});
fail
();
}
catch
(
IllegalArgumentException
e
)
{
// expected
}
map
.
put
(
0L
,
new
byte
[]{
3
,
0
,
0
});
InputStream
in
=
store
.
get
(
new
byte
[]{
2
,
1
,
0
});
try
{
in
.
read
();
fail
();
}
catch
(
IllegalArgumentException
e
)
{
// expected
}
}
public
void
testTreeStructure
()
throws
IOException
{
final
AtomicInteger
reads
=
new
AtomicInteger
();
Map
<
Long
,
byte
[]>
map
=
new
HashMap
<
Long
,
byte
[]>()
{
private
static
final
long
serialVersionUID
=
1L
;
public
byte
[]
get
(
Object
k
)
{
reads
.
incrementAndGet
();
return
super
.
get
(
k
);
}
};
StreamStore
store
=
new
StreamStore
(
map
);
store
.
setMinBlockSize
(
10
);
store
.
setMaxBlockSize
(
100
);
byte
[]
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
10000
]));
InputStream
in
=
store
.
get
(
id
);
assertEquals
(
0
,
in
.
read
());
assertEquals
(
3
,
reads
.
get
());
}
public
void
testFormat
()
throws
IOException
{
public
void
testFormat
()
throws
IOException
{
Map
<
Long
,
byte
[]>
map
=
New
.
hashMap
();
Map
<
Long
,
byte
[]>
map
=
New
.
hashMap
();
StreamStore
store
=
new
StreamStore
(
map
);
StreamStore
store
=
new
StreamStore
(
map
);
...
@@ -55,26 +105,26 @@ public class TestStreamStore extends TestBase {
...
@@ -55,26 +105,26 @@ public class TestStreamStore extends TestBase {
byte
[]
id
;
byte
[]
id
;
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
200
]));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
200
]));
int
todoInefficient
;
assertEquals
(
200
,
store
.
length
(
id
))
;
assertEquals
(
"
ffffffff0fb40102870100140286
01"
,
StringUtils
.
convertBytesToHex
(
id
));
assertEquals
(
"
02c80188
01"
,
StringUtils
.
convertBytesToHex
(
id
));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
0
]));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
0
]));
assertEquals
(
""
,
StringUtils
.
convertBytesToHex
(
id
));
assertEquals
(
""
,
StringUtils
.
convertBytesToHex
(
id
));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
1
]));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
1
]));
assertEquals
(
"0100"
,
StringUtils
.
convertBytesToHex
(
id
));
assertEquals
(
"0
00
100"
,
StringUtils
.
convertBytesToHex
(
id
));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
3
]));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
3
]));
assertEquals
(
"03000000"
,
StringUtils
.
convertBytesToHex
(
id
));
assertEquals
(
"0
00
3000000"
,
StringUtils
.
convertBytesToHex
(
id
));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
10
]));
id
=
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
10
]));
assertEquals
(
"0
00a0288
01"
,
StringUtils
.
convertBytesToHex
(
id
));
assertEquals
(
"0
10a89
01"
,
StringUtils
.
convertBytesToHex
(
id
));
byte
[]
combined
=
StringUtils
.
convertHexToBytes
(
"0
10a020b0
c"
);
byte
[]
combined
=
StringUtils
.
convertHexToBytes
(
"0
001aa0002bbc
c"
);
assertEquals
(
3
,
store
.
length
(
combined
));
assertEquals
(
3
,
store
.
length
(
combined
));
InputStream
in
=
store
.
get
(
combined
);
InputStream
in
=
store
.
get
(
combined
);
assertEquals
(
1
,
in
.
skip
(
1
));
assertEquals
(
1
,
in
.
skip
(
1
));
assertEquals
(
0x
0
b
,
in
.
read
());
assertEquals
(
0x
b
b
,
in
.
read
());
assertEquals
(
1
,
in
.
skip
(
1
));
assertEquals
(
1
,
in
.
skip
(
1
));
}
}
...
@@ -137,10 +187,10 @@ public class TestStreamStore extends TestBase {
...
@@ -137,10 +187,10 @@ public class TestStreamStore extends TestBase {
};
};
StreamStore
store
=
new
StreamStore
(
map
);
StreamStore
store
=
new
StreamStore
(
map
);
store
.
setMinBlockSize
(
1
0
);
store
.
setMinBlockSize
(
2
0
);
store
.
setMaxBlockSize
(
2
0
);
store
.
setMaxBlockSize
(
10
0
);
store
.
setNextKey
(
0
);
store
.
setNextKey
(
0
);
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
2
0
]));
store
.
put
(
new
ByteArrayInputStream
(
new
byte
[
10
0
]));
assertEquals
(
1
,
map
.
size
());
assertEquals
(
1
,
map
.
size
());
assertEquals
(
64
,
tests
.
get
());
assertEquals
(
64
,
tests
.
get
());
assertEquals
(
Long
.
MAX_VALUE
/
2
+
1
,
store
.
getNextKey
());
assertEquals
(
Long
.
MAX_VALUE
/
2
+
1
,
store
.
getNextKey
());
...
@@ -153,6 +203,7 @@ public class TestStreamStore extends TestBase {
...
@@ -153,6 +203,7 @@ public class TestStreamStore extends TestBase {
assertEquals
(
256
,
store
.
getMinBlockSize
());
assertEquals
(
256
,
store
.
getMinBlockSize
());
store
.
setNextKey
(
0
);
store
.
setNextKey
(
0
);
assertEquals
(
0
,
store
.
getNextKey
());
assertEquals
(
0
,
store
.
getNextKey
());
test
(
store
,
10
,
20
,
1000
);
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
test
(
store
,
0
,
128
,
i
);
test
(
store
,
0
,
128
,
i
);
test
(
store
,
10
,
128
,
i
);
test
(
store
,
10
,
128
,
i
);
...
@@ -161,7 +212,6 @@ public class TestStreamStore extends TestBase {
...
@@ -161,7 +212,6 @@ public class TestStreamStore extends TestBase {
test
(
store
,
0
,
128
,
i
);
test
(
store
,
0
,
128
,
i
);
test
(
store
,
10
,
128
,
i
);
test
(
store
,
10
,
128
,
i
);
}
}
test
(
store
,
10
,
20
,
1000
);
}
}
private
void
test
(
StreamStore
store
,
int
minBlockSize
,
int
maxBlockSize
,
int
length
)
throws
IOException
{
private
void
test
(
StreamStore
store
,
int
minBlockSize
,
int
maxBlockSize
,
int
length
)
throws
IOException
{
...
...
h2/src/tools/org/h2/dev/store/btree/StreamStore.java
浏览文件 @
3a92ea32
...
@@ -25,13 +25,12 @@ import org.h2.util.IOUtils;
...
@@ -25,13 +25,12 @@ import org.h2.util.IOUtils;
* searches the next free entry using a binary search (0 to Long.MAX_VALUE).
* searches the next free entry using a binary search (0 to Long.MAX_VALUE).
* <p>
* <p>
* The format of the binary id is: An empty id represents 0 bytes of data.
* The format of the binary id is: An empty id represents 0 bytes of data.
* In-place data is encoded as the size (a variable size int), then the data. A
* In-place data is encoded as 0, the size (a variable size int), then the data.
* stored block is encoded as 0, the length of the block (a variable size long),
* A stored block is encoded as 1, the length of the block (a variable size
* the length of the key (a variable size int), then the key. If the key large,
* int), then the key (a variable size long). Multiple ids can be concatenated
* it is stored itself. This is encoded as -1 (a variable size int), the total
* to concatenate the data. If the id is large, it is stored itself, which is
* length (a variable size long), the length of the key (a variable size int),
* encoded as 2, the total length (a variable size long), and the key of the
* and the key that points to the id. Multiple ids can be concatenated to
* block that contains the id (a variable size long).
* concatenate the data.
*/
*/
public
class
StreamStore
{
public
class
StreamStore
{
...
@@ -84,48 +83,64 @@ public class StreamStore {
...
@@ -84,48 +83,64 @@ public class StreamStore {
* @return the id (potentially an empty array)
* @return the id (potentially an empty array)
*/
*/
public
byte
[]
put
(
InputStream
in
)
throws
IOException
{
public
byte
[]
put
(
InputStream
in
)
throws
IOException
{
ByteArrayOutputStream
id
Stream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
id
=
new
ByteArrayOutputStream
();
long
length
=
0
;
int
level
=
0
;
while
(
true
)
{
while
(
true
)
{
ByteArrayOutputStream
outBuffer
=
new
ByteArrayOutputStream
();
if
(
put
(
id
,
in
,
level
))
{
int
len
=
(
int
)
IOUtils
.
copy
(
in
,
outBuffer
,
maxBlockSize
);
if
(
len
==
0
)
{
break
;
break
;
}
}
if
(
id
.
size
()
>
maxBlockSize
/
2
)
{
id
=
putIndirectId
(
id
);
level
++;
}
}
if
(
id
.
size
()
>
minBlockSize
*
2
)
{
id
=
putIndirectId
(
id
);
}
return
id
.
toByteArray
();
}
private
boolean
put
(
ByteArrayOutputStream
id
,
InputStream
in
,
int
level
)
throws
IOException
{
if
(
level
>
0
)
{
ByteArrayOutputStream
id2
=
new
ByteArrayOutputStream
();
while
(
true
)
{
boolean
eof
=
put
(
id2
,
in
,
level
-
1
);
if
(
id2
.
size
()
>
maxBlockSize
/
2
)
{
id2
=
putIndirectId
(
id2
);
id2
.
writeTo
(
id
);
return
eof
;
}
else
if
(
eof
)
{
id2
.
writeTo
(
id
);
return
true
;
}
}
}
ByteArrayOutputStream
buffer
=
new
ByteArrayOutputStream
();
int
len
=
(
int
)
IOUtils
.
copy
(
in
,
buffer
,
maxBlockSize
);
if
(
len
==
0
)
{
return
true
;
}
boolean
eof
=
len
<
maxBlockSize
;
boolean
eof
=
len
<
maxBlockSize
;
byte
[]
data
=
outBuffer
.
toByteArray
();
byte
[]
data
=
buffer
.
toByteArray
();
ByteArrayOutputStream
idBlock
=
new
ByteArrayOutputStream
();
if
(
len
<
minBlockSize
)
{
if
(
len
<
minBlockSize
)
{
DataUtils
.
writeVarInt
(
idBlock
,
len
);
id
.
write
(
0
);
idBlock
.
write
(
data
);
DataUtils
.
writeVarInt
(
id
,
len
);
id
.
write
(
data
);
}
else
{
}
else
{
long
key
=
writeBlock
(
data
);
id
.
write
(
1
);
DataUtils
.
writeVarInt
(
idBlock
,
0
);
DataUtils
.
writeVarInt
(
id
,
len
);
DataUtils
.
writeVarLong
(
idBlock
,
len
);
DataUtils
.
writeVarLong
(
id
,
writeBlock
(
data
));
int
keyLen
=
DataUtils
.
getVarLongLen
(
key
);
DataUtils
.
writeVarInt
(
idBlock
,
keyLen
);
DataUtils
.
writeVarLong
(
idBlock
,
key
);
}
if
(
idStream
.
size
()
>
0
)
{
int
idSize
=
idStream
.
size
()
+
idBlock
.
size
();
if
(
idSize
>
maxBlockSize
||
(
eof
&&
idSize
>
minBlockSize
))
{
data
=
idStream
.
toByteArray
();
idStream
.
reset
();
long
key
=
writeBlock
(
data
);
DataUtils
.
writeVarInt
(
idStream
,
-
1
);
DataUtils
.
writeVarLong
(
idStream
,
length
);
int
keyLen
=
DataUtils
.
getVarLongLen
(
key
);
DataUtils
.
writeVarInt
(
idStream
,
keyLen
);
DataUtils
.
writeVarLong
(
idStream
,
key
);
}
}
return
eof
;
}
}
length
+=
len
;
idBlock
.
writeTo
(
idStream
);
private
ByteArrayOutputStream
putIndirectId
(
ByteArrayOutputStream
id
)
throws
IOException
{
if
(
eof
)
{
byte
[]
data
=
id
.
toByteArray
();
break
;
id
=
new
ByteArrayOutputStream
();
}
id
.
write
(
2
);
}
DataUtils
.
writeVarLong
(
id
,
length
(
data
));
return
idStream
.
toByteArray
();
DataUtils
.
writeVarLong
(
id
,
writeBlock
(
data
));
return
id
;
}
}
private
long
writeBlock
(
byte
[]
data
)
{
private
long
writeBlock
(
byte
[]
data
)
{
...
@@ -164,29 +179,27 @@ public class StreamStore {
...
@@ -164,29 +179,27 @@ public class StreamStore {
public
void
remove
(
byte
[]
id
)
{
public
void
remove
(
byte
[]
id
)
{
ByteBuffer
idBuffer
=
ByteBuffer
.
wrap
(
id
);
ByteBuffer
idBuffer
=
ByteBuffer
.
wrap
(
id
);
while
(
idBuffer
.
hasRemaining
())
{
while
(
idBuffer
.
hasRemaining
())
{
removeBlock
(
idBuffer
);
switch
(
idBuffer
.
get
())
{
}
case
0
:
}
int
len
=
DataUtils
.
readVarInt
(
idBuffer
);
idBuffer
.
position
(
idBuffer
.
position
()
+
len
);
private
void
removeBlock
(
ByteBuffer
idBuffer
)
{
break
;
int
lenInPlace
=
DataUtils
.
readVarInt
(
idBuffer
);
case
1
:
if
(
lenInPlace
>
0
)
{
DataUtils
.
readVarInt
(
idBuffer
);
idBuffer
.
position
(
idBuffer
.
position
()
+
lenInPlace
);
long
k
=
DataUtils
.
readVarLong
(
idBuffer
);
return
;
map
.
remove
(
k
);
}
break
;
case
2
:
DataUtils
.
readVarLong
(
idBuffer
);
DataUtils
.
readVarLong
(
idBuffer
);
int
lenId
=
DataUtils
.
readVarInt
(
idBuffer
);
long
k2
=
DataUtils
.
readVarLong
(
idBuffer
);
byte
[]
key
=
new
byte
[
lenId
];
idBuffer
.
get
(
key
);
if
(
lenInPlace
<
0
)
{
// recurse
// recurse
remove
(
readBlock
(
key
));
remove
(
map
.
get
(
k2
));
map
.
remove
(
k2
);
break
;
default
:
throw
new
IllegalArgumentException
(
"Unsupported id"
);
}
}
removeBlock
(
key
);
}
}
private
void
removeBlock
(
byte
[]
key
)
{
map
.
remove
(
getKey
(
key
));
}
}
/**
/**
...
@@ -200,21 +213,25 @@ public class StreamStore {
...
@@ -200,21 +213,25 @@ public class StreamStore {
ByteBuffer
idBuffer
=
ByteBuffer
.
wrap
(
id
);
ByteBuffer
idBuffer
=
ByteBuffer
.
wrap
(
id
);
long
length
=
0
;
long
length
=
0
;
while
(
idBuffer
.
hasRemaining
())
{
while
(
idBuffer
.
hasRemaining
())
{
length
+=
readLength
(
idBuffer
);
switch
(
idBuffer
.
get
())
{
}
case
0
:
return
length
;
int
len
=
DataUtils
.
readVarInt
(
idBuffer
);
idBuffer
.
position
(
idBuffer
.
position
()
+
len
);
length
+=
len
;
break
;
case
1
:
length
+=
DataUtils
.
readVarInt
(
idBuffer
);
DataUtils
.
readVarLong
(
idBuffer
);
break
;
case
2
:
length
+=
DataUtils
.
readVarLong
(
idBuffer
);
DataUtils
.
readVarLong
(
idBuffer
);
break
;
default
:
throw
new
IllegalArgumentException
(
"Unsupported id"
);
}
}
private
static
long
readLength
(
ByteBuffer
idBuffer
)
{
int
lenInPlace
=
DataUtils
.
readVarInt
(
idBuffer
);
if
(
lenInPlace
>
0
)
{
idBuffer
.
position
(
idBuffer
.
position
()
+
lenInPlace
);
return
lenInPlace
;
}
}
long
len
=
DataUtils
.
readVarLong
(
idBuffer
);
return
length
;
int
lenId
=
DataUtils
.
readVarInt
(
idBuffer
);
idBuffer
.
position
(
idBuffer
.
position
()
+
lenId
);
return
len
;
}
}
/**
/**
...
@@ -227,32 +244,15 @@ public class StreamStore {
...
@@ -227,32 +244,15 @@ public class StreamStore {
public
boolean
isInPlace
(
byte
[]
id
)
{
public
boolean
isInPlace
(
byte
[]
id
)
{
ByteBuffer
idBuffer
=
ByteBuffer
.
wrap
(
id
);
ByteBuffer
idBuffer
=
ByteBuffer
.
wrap
(
id
);
while
(
idBuffer
.
hasRemaining
())
{
while
(
idBuffer
.
hasRemaining
())
{
if
(
!
isInPlace
(
idBuffer
)
)
{
if
(
idBuffer
.
get
()
!=
0
)
{
return
false
;
return
false
;
}
}
int
len
=
DataUtils
.
readVarInt
(
idBuffer
);
idBuffer
.
position
(
idBuffer
.
position
()
+
len
);
}
}
return
true
;
return
true
;
}
}
private
static
boolean
isInPlace
(
ByteBuffer
idBuffer
)
{
int
lenInPlace
=
DataUtils
.
readVarInt
(
idBuffer
);
if
(
lenInPlace
>
0
)
{
idBuffer
.
position
(
idBuffer
.
position
()
+
lenInPlace
);
return
true
;
}
return
false
;
}
byte
[]
readBlock
(
byte
[]
key
)
{
return
map
.
get
(
getKey
(
key
));
}
private
static
Long
getKey
(
byte
[]
key
)
{
int
todoRemove
;
ByteBuffer
buff
=
ByteBuffer
.
wrap
(
key
);
return
DataUtils
.
readVarLong
(
buff
);
}
/**
/**
* Open an input stream to read data.
* Open an input stream to read data.
*
*
...
@@ -263,6 +263,10 @@ public class StreamStore {
...
@@ -263,6 +263,10 @@ public class StreamStore {
return
new
Stream
(
this
,
id
);
return
new
Stream
(
this
,
id
);
}
}
byte
[]
getBlock
(
long
key
)
{
return
map
.
get
(
key
);
}
/**
/**
* A stream backed by a map.
* A stream backed by a map.
*/
*/
...
@@ -340,29 +344,39 @@ public class StreamStore {
...
@@ -340,29 +344,39 @@ public class StreamStore {
private
ByteArrayInputStream
nextBuffer
()
{
private
ByteArrayInputStream
nextBuffer
()
{
while
(
idBuffer
.
hasRemaining
())
{
while
(
idBuffer
.
hasRemaining
())
{
int
lenInPlace
=
DataUtils
.
readVarInt
(
idBuffer
);
switch
(
idBuffer
.
get
())
{
if
(
lenInPlace
>
0
)
{
case
0
:
{
if
(
skip
>=
lenInPlace
)
{
int
len
=
DataUtils
.
readVarInt
(
idBuffer
);
skip
-=
lenInPlace
;
if
(
skip
>=
len
)
{
idBuffer
.
position
(
idBuffer
.
position
()
+
lenInPlace
);
skip
-=
len
;
idBuffer
.
position
(
idBuffer
.
position
()
+
len
);
continue
;
continue
;
}
}
int
p
=
(
int
)
(
idBuffer
.
position
()
+
skip
);
int
p
=
(
int
)
(
idBuffer
.
position
()
+
skip
);
int
l
=
(
int
)
(
len
InPlace
-
skip
);
int
l
=
(
int
)
(
len
-
skip
);
idBuffer
.
position
(
p
+
l
);
idBuffer
.
position
(
p
+
l
);
return
new
ByteArrayInputStream
(
idBuffer
.
array
(),
p
,
l
);
return
new
ByteArrayInputStream
(
idBuffer
.
array
(),
p
,
l
);
}
}
long
length
=
DataUtils
.
readVarLong
(
idBuffer
);
case
1
:
{
int
lenId
=
DataUtils
.
readVarInt
(
idBuffer
);
int
len
=
DataUtils
.
readVarInt
(
idBuffer
);
if
(
skip
>=
length
)
{
long
key
=
DataUtils
.
readVarLong
(
idBuffer
);
skip
-=
length
;
if
(
skip
>=
len
)
{
idBuffer
.
position
(
idBuffer
.
position
()
+
lenId
);
skip
-=
len
;
continue
;
}
byte
[]
data
=
store
.
getBlock
(
key
);
int
s
=
(
int
)
skip
;
skip
=
0
;
return
new
ByteArrayInputStream
(
data
,
s
,
data
.
length
-
s
);
}
case
2
:
{
long
len
=
DataUtils
.
readVarInt
(
idBuffer
);
long
key
=
DataUtils
.
readVarLong
(
idBuffer
);
if
(
skip
>=
len
)
{
skip
-=
len
;
continue
;
continue
;
}
}
byte
[]
key
=
new
byte
[
lenId
];
byte
[]
k
=
store
.
getBlock
(
key
);
idBuffer
.
get
(
key
);
if
(
lenInPlace
<
0
)
{
byte
[]
k
=
store
.
readBlock
(
key
);
ByteBuffer
newBuffer
=
ByteBuffer
.
allocate
(
k
.
length
+
idBuffer
.
limit
()
-
idBuffer
.
position
());
ByteBuffer
newBuffer
=
ByteBuffer
.
allocate
(
k
.
length
+
idBuffer
.
limit
()
-
idBuffer
.
position
());
newBuffer
.
put
(
k
);
newBuffer
.
put
(
k
);
newBuffer
.
put
(
idBuffer
);
newBuffer
.
put
(
idBuffer
);
...
@@ -370,10 +384,9 @@ public class StreamStore {
...
@@ -370,10 +384,9 @@ public class StreamStore {
idBuffer
=
newBuffer
;
idBuffer
=
newBuffer
;
return
nextBuffer
();
return
nextBuffer
();
}
}
byte
[]
data
=
store
.
readBlock
(
key
);
default
:
int
s
=
(
int
)
skip
;
throw
new
IllegalArgumentException
(
"Unsupported id"
);
skip
=
0
;
}
return
new
ByteArrayInputStream
(
data
,
s
,
data
.
length
-
s
);
}
}
return
null
;
return
null
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论