Skip to content

Commit

Permalink
chore: refrain from using deprecated method
Browse files Browse the repository at this point in the history
Address issue reported by sonarcloud by replacing calls to `com.graphhopper.storage.Directory#find(java.lang.String)` by `com.graphhopper.storage.Directory#create(java.lang.String)`
  • Loading branch information
aoles committed May 22, 2024
1 parent 6c4583a commit 5ded0a3
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class CellStorage implements Storable<CellStorage> {
*/
public CellStorage(int nodeCount, Directory dir, IsochroneNodeStorage isochroneNodeStorage) {
this.isochroneNodeStorage = isochroneNodeStorage;
cells = dir.find("cells");
cells = dir.create("cells");
byteCount = 4;
this.nodeCount = nodeCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class IsochroneNodeStorage implements Storable<IsochroneNodeStorage> {
private final IntSet cellIdsSet = new IntHashSet();

public IsochroneNodeStorage(int nodeCount, Directory dir) {
isochroneNodes = dir.find("isochronenodes");
isochroneNodes = dir.create("isochronenodes");
this.nodeCount = nodeCount;
// 5 bytes per node for its cell id.
// 1 byte for isBordernode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class BorderNodeDistanceStorage implements Storable<BorderNodeDistanceSto
public BorderNodeDistanceStorage(Directory dir, Weighting weighting, IsochroneNodeStorage isochroneNodeStorage, int nodeCount) {
final String name = FileUtility.weightingToFileName(weighting);
this.isochroneNodeStorage = isochroneNodeStorage;
borderNodes = dir.find("bordernodes_" + name);
borderNodes = dir.create("bordernodes_" + name);
this.weighting = weighting;
byteCount = 12; //adj bordernode id (int 4B) and distance (double 8B)
this.nodeCount = nodeCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public EccentricityStorage(Directory dir, Weighting weighting, IsochroneNodeStor
//A map of nodeId to pointer is stored in the first block.
//The second block stores 2 values for each pointer, full reachability and eccentricity
final String name = FileUtility.weightingToFileName(weighting);
eccentricities = dir.find("eccentricities_" + name);
eccentricities = dir.create("eccentricities_" + name);
this.weighting = weighting;
this.isochroneNodeStorage = isochroneNodeStorage;
this.nodeCount = nodeCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_borders");
this.orsEdges = dir.create("ext_borders");
}

/**
Expand All @@ -117,7 +117,7 @@ public void init() {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");
Directory d = new RAMDirectory();
this.orsEdges = d.find("");
this.orsEdges = d.create("");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_csv");
this.orsEdges = dir.create("ext_csv");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_greenindex");
this.orsEdges = dir.create("ext_greenindex");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ext_hgv storage must be initialized only once.");

this.orsEdges = dir.find("ext_hgv");
this.orsEdges = dir.create("ext_hgv");
}

private int nextBlockEntryIndex(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_hillindex");
this.orsEdges = dir.create("ext_hillindex");
}

public HillIndexGraphStorage create(long initBytes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_noiselevel");
this.orsEdges = dir.create("ext_noiselevel");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_osmids");
this.orsEdges = dir.create("ext_osmids");
}

/**
Expand All @@ -36,7 +36,7 @@ public void init() {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");
Directory d = new RAMDirectory();
this.orsEdges = d.find("");
this.orsEdges = d.create("");
}

public OsmIdGraphStorage create(long initBytes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public void init() {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");
Directory d = new RAMDirectory();
this.edges = d.find("");
this.edges = d.create("");
}

public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ext_road_access_restrictions storage must be initialized only once.");

this.edges = dir.find("ext_road_access_restrictions");
this.edges = dir.create("ext_road_access_restrictions");
}

public void setEdgeValue(int edgeId, int restriction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_shadowindex");
this.orsEdges = dir.create("ext_shadowindex");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public SpeedStorage(FlagEncoder flagEncoder) {

@Override
public void init(Graph graph, Directory directory) {
this.speedData = directory.find("ext_speeds_" + this.flagEncoder.toString());
this.speedData = directory.create("ext_speeds_" + this.flagEncoder.toString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ext_tolls storage must be initialized only once.");

this.edges = dir.find("ext_tolls");
this.edges = dir.create("ext_tolls");
}

protected final int nextBlockEntryIndex(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdgesProperties = dir.find("ext_traffic_edge_properties");
this.orsEdgesTrafficLinkLookup = dir.find("ext_traffic_edges_traffic_lookup");
this.orsSpeedPatternLookup = dir.find("ext_traffic_pattern_lookup");
this.orsEdgesProperties = dir.create("ext_traffic_edge_properties");
this.orsEdgesTrafficLinkLookup = dir.create("ext_traffic_edges_traffic_lookup");
this.orsSpeedPatternLookup = dir.create("ext_traffic_pattern_lookup");
}

/**
Expand All @@ -454,9 +454,9 @@ public void init() {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");
Directory d = new RAMDirectory();
this.orsEdgesProperties = d.find("");
this.orsEdgesTrafficLinkLookup = d.find("");
this.orsSpeedPatternLookup = d.find("");
this.orsEdgesProperties = d.create("");
this.orsEdgesTrafficLinkLookup = d.create("");
this.orsSpeedPatternLookup = d.create("");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ext_traildifficulty storage must be initialized only once.");

this.edges = dir.find("ext_traildifficulty");
this.edges = dir.create("ext_traildifficulty");
}

protected final int nextBlockEntryIndex(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_waycategory");
this.orsEdges = dir.create("ext_waycategory");
}

public WayCategoryGraphStorage create(long initBytes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_waysurface");
this.orsEdges = dir.create("ext_waysurface");
}

/**
Expand All @@ -51,7 +51,7 @@ public void init() {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");
Directory d = new RAMDirectory();
this.orsEdges = d.find("");
this.orsEdges = d.create("");
}

protected final int nextBlockEntryIndex(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void init(Graph graph, Directory dir) {
if (edgesCount > 0)
throw new AssertionError("The ORS storage must be initialized only once.");

this.orsEdges = dir.find("ext_wheelchair");
this.orsEdges = dir.create("ext_wheelchair");
}

public WheelchairAttributesGraphStorage create(long initBytes) {
Expand Down

0 comments on commit 5ded0a3

Please sign in to comment.