Class GraphMem2

All Implemented Interfaces:
Graph, GraphWithPerform
Direct Known Subclasses:
GraphMem2Fast, GraphMem2Legacy, GraphMem2Roaring

public class GraphMem2 extends GraphMemBase implements GraphWithPerform
A graph that stores triples in memory. This class is not thread-safe. All triples are stored in a TripleStore.

Implementation mus always comply to term-equality semantics. The characteristics of the implementations always have handlesLiteralTyping() == false.

  • Constructor Details

    • GraphMem2

      public GraphMem2(TripleStore tripleStore)
  • Method Details

    • destroy

      public void destroy()
      Subclasses over-ride this method to release any resources they no longer need once fully closed.
    • clear

      public void clear()
      Remove all the statements from this graph.
      Specified by:
      clear in interface Graph
      Overrides:
      clear in class GraphBase
    • performAdd

      public void performAdd(Triple t)
      Add a triple to the graph without notifying. The default implementation throws an AddDeniedException; subclasses must override if they want to be able to add triples.
      Specified by:
      performAdd in interface GraphWithPerform
      Overrides:
      performAdd in class GraphBase
      Parameters:
      t - triple to add
    • performDelete

      public void performDelete(Triple t)
      Remove a triple from the triple store. The default implementation throws a DeleteDeniedException; subclasses must override if they want to be able to remove triples.
      Specified by:
      performDelete in interface GraphWithPerform
      Overrides:
      performDelete in class GraphBase
      Parameters:
      t - triple to delete
    • stream

      public Stream<Triple> stream()
      Returns a Stream of all triples in the graph. Note: BaseStream.parallel() is supported.
      Specified by:
      stream in interface Graph
      Returns:
      a stream of triples in this graph.
    • stream

      public Stream<Triple> stream(Node sm, Node pm, Node om)
      Returns a Stream of Triples matching a pattern. Note: BaseStream.parallel() is supported.
      Specified by:
      stream in interface Graph
      Parameters:
      sm - subject node match pattern
      pm - predicate node match pattern
      om - object node match pattern
      Returns:
      a stream of triples in this graph matching the pattern.
    • graphBaseFind

      public ExtendedIterator<Triple> graphBaseFind(Triple tripleMatch)
      Returns an ExtendedIterator of all triples in the graph matching the given triple match.
    • graphBaseContains

      public boolean graphBaseContains(Triple tripleMatch)
      Answer true if the graph contains any triple matching t. The default implementation uses find and checks to see if the iterator is non-empty.
      Parameters:
      tripleMatch - triple match pattern, which may be contained
    • graphBaseSize

      public int graphBaseSize()
      Answer the number of triples in this graph. Default implementation counts its way through the results of a findAll. Subclasses must override if they want size() to be efficient.
    • getCapabilities

      public Capabilities getCapabilities()
      Description copied from class: GraphBase
      Answer the capabilities of this graph; the default is an AllCapabilities object (the same one each time, not that it matters - Capabilities should be immutable).
      Specified by:
      getCapabilities in interface Graph
      Overrides:
      getCapabilities in class GraphBase