Class CHStorage

java.lang.Object
com.graphhopper.storage.CHStorage

public class CHStorage extends Object
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:
  • Constructor Details

    • CHStorage

      public CHStorage(Directory dir, String name, int segmentSize, boolean edgeBased)
  • Method Details

    • fromGraph

      public static CHStorage fromGraph(BaseGraph baseGraph, CHConfig chConfig)
    • 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 using loadExisting()}. 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

      public NodeOrderingProvider getNodeOrderingProvider()
    • debugPrint

      public void debugPrint()
    • getCapacity

      public long getCapacity()
    • getNumShortcutsExceedingWeight

      public int getNumShortcutsExceedingWeight()
    • toDetailsString

      public String toDetailsString()
    • isClosed

      public boolean isClosed()