提交 0a5b618f authored 作者: Noel Grandin's avatar Noel Grandin

make the child ChunkIdsCollector objects local to the method

so we can use multiple children concurrently
上级 9069ba5c
...@@ -1379,7 +1379,6 @@ public class MVStore { ...@@ -1379,7 +1379,6 @@ public class MVStore {
private final Set<Integer> referencedChunks = new HashSet<>(); private final Set<Integer> referencedChunks = new HashSet<>();
private final ChunkIdsCollector parent; private final ChunkIdsCollector parent;
private ChunkIdsCollector child;
private int mapId; private int mapId;
ChunkIdsCollector(int mapId) { ChunkIdsCollector(int mapId) {
...@@ -1398,9 +1397,6 @@ public class MVStore { ...@@ -1398,9 +1397,6 @@ public class MVStore {
public void setMapId(int mapId) { public void setMapId(int mapId) {
this.mapId = mapId; this.mapId = mapId;
if (child != null) {
child.setMapId(mapId);
}
} }
public Set<Integer> getReferenced() { public Set<Integer> getReferenced() {
...@@ -1416,7 +1412,7 @@ public class MVStore { ...@@ -1416,7 +1412,7 @@ public class MVStore {
if (count == 0) { if (count == 0) {
return; return;
} }
ChunkIdsCollector childCollector = getChild(); final ChunkIdsCollector childCollector = new ChunkIdsCollector(this);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Page childPage = page.getChildPageIfLoaded(i); Page childPage = page.getChildPageIfLoaded(i);
if (childPage != null) { if (childPage != null) {
...@@ -1447,7 +1443,7 @@ public class MVStore { ...@@ -1447,7 +1443,7 @@ public class MVStore {
registerChunk(chunkId); registerChunk(chunkId);
} }
} else { } else {
ChunkIdsCollector childCollector = getChild(); final ChunkIdsCollector childCollector = new ChunkIdsCollector(this);
Page page; Page page;
if (cache != null && (page = cache.get(pos)) != null) { if (cache != null && (page = cache.get(pos)) != null) {
// there is a full page in cache, use it // there is a full page in cache, use it
...@@ -1473,15 +1469,6 @@ public class MVStore { ...@@ -1473,15 +1469,6 @@ public class MVStore {
} }
} }
private ChunkIdsCollector getChild() {
if (child == null) {
child = new ChunkIdsCollector(this);
} else {
child.referencedChunks.clear();
}
return child;
}
private void registerChunk(int chunkId) { private void registerChunk(int chunkId) {
if (referencedChunks.add(chunkId) && parent != null) { if (referencedChunks.add(chunkId) && parent != null) {
parent.registerChunk(chunkId); parent.registerChunk(chunkId);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论