co.teapot.tempest.graph

MemMappedDynamicDirectedGraph

Related Docs: object MemMappedDynamicDirectedGraph | package graph

class MemMappedDynamicDirectedGraph extends DynamicDirectedGraph

A graph which stores edge data in a memory mapped file. There is no object overhead per node: the memory used for with both in-neighbor and out-neighbor access is 8 bytes per edge and 24 bytes per node. Loading is very fast because no parsing of text is required. Loading time is exactly the time it takes the operating system to page data from disk into memory. Nodes are numbered sequentially from 0 to maxNodeId, and when a node id greater than maxNodeId is added, empty nodes are created as needed (i.e. nodeCount == maxNodeId + 1).

If given an empty file, this class creates a new empty graph which will store new nodes and edges in that file. If a MemMappedDynamicDirectedGraph is later created from the same file, it will contain the added nodes and edges. Graphs can also converted to dynamic binary format using MemMappedDynamicDirectedGraphConverter, then loaded using this class.

Concurrent reading threads are safe, but concurrent reading and writing is not currently supported.

If parameter syncAllWrites is true, all writes are immediately written to disk during each addEdges call. If syncAllWrites is set to false, write performance will improve, but the graph may be in an inconsistent state if the OS crashes or the machine loses power.

The binary format is currently subject to change.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. MemMappedDynamicDirectedGraph
  2. DynamicDirectedGraph
  3. DirectedGraph
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MemMappedDynamicDirectedGraph(file: File, syncAllWrites: Boolean = false)

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. def addEdge(id1: Int, id2: Int): Unit

    Adds the given edge to the graph, increasing the number of nodes if needed.

    Adds the given edge to the graph, increasing the number of nodes if needed.

    Definition Classes
    MemMappedDynamicDirectedGraphDynamicDirectedGraph
  5. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def defaultNeighbors(id: Int): IndexedSeq[Int]

    Called by other methods when given an id that doesn't exist in this graph.

    Called by other methods when given an id that doesn't exist in this graph. By default it throws an exception, but implementations can override it to return an IndexedSeq which is the neighbor seq of non-existing nodes (typically an empty IndexedSeq).

    Definition Classes
    DirectedGraph
  8. def edgeCount: Long

    The number of edges in this graph.

    The number of edges in this graph.

    Definition Classes
    MemMappedDynamicDirectedGraphDirectedGraph
  9. def ensureValidId(id: Long): Unit

    Increases maxNodeId and creates neighborless nodes as needed to ensure the given id is a valid id.

  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  12. def existsNode(id: Int): Boolean

  13. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  15. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  16. def inDegree(id: Int): Int

    Returns the number of in-neighbors of the given id.

    Returns the number of in-neighbors of the given id.

    Definition Classes
    MemMappedDynamicDirectedGraphDirectedGraph
  17. def inDegreeOr0(id: Int): Int

    Returns the in-degree of the given node id, or 0 if the node id does not exist.

    Returns the in-degree of the given node id, or 0 if the node id does not exist.

    Definition Classes
    DirectedGraph
  18. def inNeighbor(id: Int, i: Int): Int

    Returns the ith in-neighbor of the node with the given id.

    Returns the ith in-neighbor of the node with the given id. Throws IndexOutOfBoundsException unless 0 <= i < inDegree(id).

    Definition Classes
    DirectedGraph
  19. def inNeighborList(id: Int): List[Integer]

    Returns the in-neighbors of the given id as a java.util.List.

    Returns the in-neighbors of the given id as a java.util.List.

    Definition Classes
    DirectedGraph
  20. def inNeighbors(id: Int): IndexedSeq[Int]

    Returns the in-neighbors of the given id.

    Returns the in-neighbors of the given id.

    Definition Classes
    MemMappedDynamicDirectedGraphDirectedGraph
  21. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  22. def loadToRam(): Unit

    Loads the underlying memory mapped file to RAM (if it isn't already in RAM), to improve the speed of subsequent reads.

  23. def maxNodeId: Int

    The largest node id in this graph (or an upper bound on it).

    The largest node id in this graph (or an upper bound on it).

    Definition Classes
    MemMappedDynamicDirectedGraphDirectedGraph
  24. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  25. def nodeCount: Int

    Returns the nodeCount if it is defined.

    Returns the nodeCount if it is defined. Otherwise throws an UnsupportedOperationException.

    Definition Classes
    DirectedGraph
  26. def nodeCountOption: Option[Int]

    The number of nodes in this graph.

    The number of nodes in this graph. May return None if it is expensive to compute (for example, for the union of two graphs).

    Definition Classes
    MemMappedDynamicDirectedGraphDirectedGraph
  27. def nodeIds: Iterable[Int]

    All nodeIds that exist in the graph.

    All nodeIds that exist in the graph.

    Definition Classes
    MemMappedDynamicDirectedGraphDirectedGraph
  28. final def notify(): Unit

    Definition Classes
    AnyRef
  29. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  30. def outDegree(id: Int): Int

    Returns the number of out-neighbors of the given id.

    Returns the number of out-neighbors of the given id.

    Definition Classes
    MemMappedDynamicDirectedGraphDirectedGraph
  31. def outDegreeOr0(id: Int): Int

    Returns the out-degree of the given node id, or 0 if the node id does not exist.

    Returns the out-degree of the given node id, or 0 if the node id does not exist.

    Definition Classes
    DirectedGraph
  32. def outNeighbor(id: Int, i: Int): Int

    Returns the ith out-neighbor of the node with the given id.

    Returns the ith out-neighbor of the node with the given id. Throws IndexOutOfBoundsException unless 0 <= i < outDegree(id).

    Definition Classes
    DirectedGraph
  33. def outNeighborList(id: Int): List[Integer]

    Returns the out-neighbors of the given id as a java.util.List.

    Returns the out-neighbors of the given id as a java.util.List.

    Definition Classes
    DirectedGraph
  34. def outNeighbors(id: Int): IndexedSeq[Int]

    Returns the out-neighbors of the given id.

    Returns the out-neighbors of the given id.

    Definition Classes
    MemMappedDynamicDirectedGraphDirectedGraph
  35. def setInDegreeCapacity(id: Int, inDegree: Int): Unit

  36. def setOutDegreeCapacity(id: Int, outDegree: Int): Unit

  37. def syncToDisk(): Unit

    Syncs all data to disk and blocks until that completes.

  38. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  39. def toString(): String

    Definition Classes
    DirectedGraph → AnyRef → Any
  40. def transposeView: DirectedGraph

    Returns a view of the transpose of this graph.

    Returns a view of the transpose of this graph.

    Definition Classes
    DirectedGraph
  41. def uniformRandomInNeighbor(id: Int, random: Random = Random.self): Int

    Definition Classes
    DirectedGraph
  42. def uniformRandomOutNeighbor(id: Int, random: Random = Random.self): Int

    Definition Classes
    DirectedGraph
  43. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def getNodeById(id: Int): Option[NodeWrapper]

    Returns the node with the given id or else None if the given node does not exist in this graph.

    Returns the node with the given id or else None if the given node does not exist in this graph. Deprecated: to decrease the number of objects used, get node neighbors and degrees directly through the graph.

    Definition Classes
    DirectedGraph
    Annotations
    @deprecated
    Deprecated

    (Since version 1.0) Rather than using Node objects, use graph method directly

Inherited from DynamicDirectedGraph

Inherited from DirectedGraph

Inherited from AnyRef

Inherited from Any

Ungrouped