提交 4ee7e5fe authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

File system nioMemFS: support concurrent reads

上级 9a663852
......@@ -93,6 +93,8 @@ Change Log
</li>
<li>MVStore: add feature to set the cache concurrency.
</li>
<li>File system nioMemFS: support concurrent reads.
</li>
<li>LIRS cache: improved hit rate because now added entries get hot if they
were in the non-resident part of the cache before.
</li>
......
......@@ -322,6 +322,22 @@ class FileNioMem extends FileBase {
return len;
}
@Override
public int read(ByteBuffer dst, long position) throws IOException {
int len = dst.remaining();
if (len == 0) {
return 0;
}
long newPos;
newPos = data.readWrite(position, dst, dst.position(), len, false);
len = (int) (newPos - position);
if (len <= 0) {
return -1;
}
dst.position(dst.position() + len);
return len;
}
@Override
public long position() {
return pos;
......@@ -634,9 +650,10 @@ class FileNioMemData {
block.position(blockOffset);
block.put(tmp);
} else {
block.position(blockOffset);
ByteBuffer tmp = block.slice();
tmp.limit(l);
// duplicate, so this can be done concurrently
ByteBuffer tmp = block.duplicate();
tmp.position(blockOffset);
tmp.limit(l + blockOffset);
int oldPosition = b.position();
b.position(off);
b.put(tmp);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论