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

File system nioMemFS: support concurrent reads

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