提交 c5453323 authored 作者: Noel Grandin's avatar Noel Grandin

ConcurrentHashMap.newKeySet not Java7 compatible

上级 adec62cb
...@@ -1390,7 +1390,8 @@ public class MVStore { ...@@ -1390,7 +1390,8 @@ public class MVStore {
final class ChunkIdsCollector { final class ChunkIdsCollector {
private final Set<Integer> referencedChunks = ConcurrentHashMap.<Integer>newKeySet(); /** really a set */
private final ConcurrentHashMap<Integer, Integer> referencedChunks = new ConcurrentHashMap<>();
private final ChunkIdsCollector parent; private final ChunkIdsCollector parent;
private int mapId; private int mapId;
...@@ -1413,7 +1414,9 @@ public class MVStore { ...@@ -1413,7 +1414,9 @@ public class MVStore {
} }
public Set<Integer> getReferenced() { public Set<Integer> getReferenced() {
return referencedChunks; Set<Integer> set = new HashSet<>();
set.addAll(referencedChunks.keySet());
return set;
} }
public void visit(Page page, ThreadPoolExecutor executorService, AtomicInteger executingThreadCounter) { public void visit(Page page, ThreadPoolExecutor executorService, AtomicInteger executingThreadCounter) {
...@@ -1483,7 +1486,7 @@ public class MVStore { ...@@ -1483,7 +1486,7 @@ public class MVStore {
} }
private void registerChunk(int chunkId) { private void registerChunk(int chunkId) {
if (referencedChunks.add(chunkId) && parent != null) { if (referencedChunks.put(chunkId, 1) == null && parent != null) {
parent.registerChunk(chunkId); parent.registerChunk(chunkId);
} }
} }
...@@ -1491,7 +1494,7 @@ public class MVStore { ...@@ -1491,7 +1494,7 @@ public class MVStore {
private int[] getChunkIds() { private int[] getChunkIds() {
int chunkIds[] = new int[referencedChunks.size()]; int chunkIds[] = new int[referencedChunks.size()];
int index = 0; int index = 0;
for (int chunkId : referencedChunks) { for (Integer chunkId : referencedChunks.keySet()) {
chunkIds[index++] = chunkId; chunkIds[index++] = chunkId;
} }
return chunkIds; return chunkIds;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论