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.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcreate(int nodes, int expectedShortcuts) Creates a new storage.voidvoidflush()static CHStoragebooleangetBwdAccess(long shortcutPointer) longbooleangetFwdAccess(long shortcutPointer) intgetLastShortcut(long nodePointer) intgetLevel(long nodePointer) intgetMB()intgetNodeA(long shortcutPointer) intgetNodeB(long shortcutPointer) intgetNodes()The number of nodes of this storage.intintgetOrigEdgeKeyFirst(long shortcutPointer) intgetOrigEdgeKeyLast(long shortcutPointer) intThe number of shortcuts that were added to this storageintgetSkippedEdge1(long shortcutPointer) intgetSkippedEdge2(long shortcutPointer) doublegetWeight(long shortcutPointer) booleanisClosed()booleanbooleanvoidsetLastShortcut(long nodePointer, int shortcut) voidsetLevel(long nodePointer, int level) voidsetLowShortcutWeightConsumer(Consumer<CHStorage.LowWeightShortcut> lowWeightShortcutConsumer) Sets a callback called for shortcuts that are below the minimum weight.voidsetOrigEdgeKeys(long shortcutPointer, int origKeyFirst, int origKeyLast) voidsetSkippedEdges(long shortcutPointer, int edge1, int edge2) voidsetWeight(long shortcutPointer, double weight) intshortcutEdgeBased(int nodeA, int nodeB, int accessFlags, double weight, int skip1, int skip2, int origKeyFirst, int origKeyLast) intshortcutNodeBased(int nodeA, int nodeB, int accessFlags, double weight, int skip1, int skip2) Adds a shortcut to the storage.longtoNodePointer(int node) To use the node getters/setters you need to convert node IDs to a nodePointer firstlongtoShortcutPointer(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() -
getMB
public int getMB() -
getNumShortcutsExceedingWeight
public int getNumShortcutsExceedingWeight() -
toDetailsString
-
isClosed
public boolean isClosed()
-