Skip to content

Commit

Permalink
Allow subclasses of InMemoryGraphImpl to specify an initial capacity.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 371115514
  • Loading branch information
justinhorvitz authored and copybara-github committed Apr 29, 2021
1 parent b87e94d commit 3ea1ffc
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class InMemoryGraphImpl implements InMemoryGraph {

protected final ConcurrentMap<SkyKey, NodeEntry> nodeMap = new ConcurrentHashMap<>(1024);
protected final ConcurrentMap<SkyKey, NodeEntry> nodeMap;
private final boolean keepEdges;

@VisibleForTesting
Expand All @@ -43,7 +43,12 @@ public InMemoryGraphImpl() {
}

public InMemoryGraphImpl(boolean keepEdges) {
this(keepEdges, /*initialCapacity=*/ 1 << 10);
}

protected InMemoryGraphImpl(boolean keepEdges, int initialCapacity) {
this.keepEdges = keepEdges;
this.nodeMap = new ConcurrentHashMap<>(initialCapacity);
}

@Override
Expand Down Expand Up @@ -120,9 +125,4 @@ public Map<SkyKey, NodeEntry> getAllValues() {
public Map<SkyKey, ? extends NodeEntry> getAllValuesMutable() {
return nodeMap;
}

@VisibleForTesting
protected ConcurrentMap<SkyKey, ? extends NodeEntry> getNodeMap() {
return nodeMap;
}
}

0 comments on commit 3ea1ffc

Please sign in to comment.