Package com.graphhopper.storage
Class CHStorage
java.lang.Object
com.graphhopper.storage.CHStorage
DataAccess-based storage for CH shortcuts. Stores shortcuts and CH levels sequentially using two DataAccess objects
and gives read/write access to the different shortcut and node fields.
This can be seen as an extension to a base graph: We assign a CH level to each node and add additional edges to the graph ('shortcuts'). The shortcuts need to be ordered in a certain way, but this is not enforced here.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
create
(int nodes, int expectedShortcuts) Creates a new storage.void
void
flush()
static CHStorage
boolean
getBwdAccess
(long shortcutPointer) long
boolean
getFwdAccess
(long shortcutPointer) int
getLastShortcut
(long nodePointer) int
getLevel
(long nodePointer) int
getNodeA
(long shortcutPointer) int
getNodeB
(long shortcutPointer) int
getNodes()
The number of nodes of this storage.int
int
getOrigEdgeKeyFirst
(long shortcutPointer) int
getOrigEdgeKeyLast
(long shortcutPointer) int
The number of shortcuts that were added to this storageint
getSkippedEdge1
(long shortcutPointer) int
getSkippedEdge2
(long shortcutPointer) double
getWeight
(long shortcutPointer) boolean
isClosed()
boolean
boolean
void
setLastShortcut
(long nodePointer, int shortcut) void
setLevel
(long nodePointer, int level) void
setLowShortcutWeightConsumer
(Consumer<CHStorage.LowWeightShortcut> lowWeightShortcutConsumer) Sets a callback called for shortcuts that are below the minimum weight.void
setOrigEdgeKeys
(long shortcutPointer, int origKeyFirst, int origKeyLast) void
setSkippedEdges
(long shortcutPointer, int edge1, int edge2) void
setWeight
(long shortcutPointer, double weight) int
shortcutEdgeBased
(int nodeA, int nodeB, int accessFlags, double weight, int skip1, int skip2, int origKeyFirst, int origKeyLast) int
shortcutNodeBased
(int nodeA, int nodeB, int accessFlags, double weight, int skip1, int skip2) Adds a shortcut to the storage.long
toNodePointer
(int node) To use the node getters/setters you need to convert node IDs to a nodePointer firstlong
toShortcutPointer
(int shortcut) To use the shortcut getters/setters you need to convert shortcut IDs to an shortcutPointer first
-
Constructor Details
-
CHStorage
-
-
Method Details
-
fromGraph
-
setLowShortcutWeightConsumer
public void setLowShortcutWeightConsumer(Consumer<CHStorage.LowWeightShortcut> lowWeightShortcutConsumer) Sets a callback called for shortcuts that are below the minimum weight. e.g. used to find/log mapping errors -
create
public void create(int nodes, int expectedShortcuts) Creates a new storage. Alternatively we could load an existing one usingloadExisting()
}. The number of nodes must be given here while the expected number of shortcuts can be given to prevent some memory allocations, but is not a requirement. When in doubt rather use a small value so the resulting files/byte arrays won't be unnecessarily large. todo: we could also trim down the shortcuts DataAccess when we are done adding shortcuts -
flush
public void flush() -
loadExisting
public boolean loadExisting() -
close
public void close() -
shortcutNodeBased
public int shortcutNodeBased(int nodeA, int nodeB, int accessFlags, double weight, int skip1, int skip2) Adds a shortcut to the storage. Shortcuts are stored in the same order they are added. The underlying DataAccess object grows automatically when adding more shortcuts. -
shortcutEdgeBased
public int shortcutEdgeBased(int nodeA, int nodeB, int accessFlags, double weight, int skip1, int skip2, int origKeyFirst, int origKeyLast) -
getNodes
public int getNodes()The number of nodes of this storage. -
getShortcuts
public int getShortcuts()The number of shortcuts that were added to this storage -
toNodePointer
public long toNodePointer(int node) To use the node getters/setters you need to convert node IDs to a nodePointer first -
toShortcutPointer
public long toShortcutPointer(int shortcut) To use the shortcut getters/setters you need to convert shortcut IDs to an shortcutPointer first -
isEdgeBased
public boolean isEdgeBased() -
getLastShortcut
public int getLastShortcut(long nodePointer) -
setLastShortcut
public void setLastShortcut(long nodePointer, int shortcut) -
getLevel
public int getLevel(long nodePointer) -
setLevel
public void setLevel(long nodePointer, int level) -
setWeight
public void setWeight(long shortcutPointer, double weight) -
setSkippedEdges
public void setSkippedEdges(long shortcutPointer, int edge1, int edge2) -
setOrigEdgeKeys
public void setOrigEdgeKeys(long shortcutPointer, int origKeyFirst, int origKeyLast) -
getNodeA
public int getNodeA(long shortcutPointer) -
getNodeB
public int getNodeB(long shortcutPointer) -
getFwdAccess
public boolean getFwdAccess(long shortcutPointer) -
getBwdAccess
public boolean getBwdAccess(long shortcutPointer) -
getWeight
public double getWeight(long shortcutPointer) -
getSkippedEdge1
public int getSkippedEdge1(long shortcutPointer) -
getSkippedEdge2
public int getSkippedEdge2(long shortcutPointer) -
getOrigEdgeKeyFirst
public int getOrigEdgeKeyFirst(long shortcutPointer) -
getOrigEdgeKeyLast
public int getOrigEdgeKeyLast(long shortcutPointer) -
getNodeOrderingProvider
-
debugPrint
public void debugPrint() -
getCapacity
public long getCapacity() -
getNumShortcutsExceedingWeight
public int getNumShortcutsExceedingWeight() -
toDetailsString
-
isClosed
public boolean isClosed()
-