Class GraphMem2

All Implemented Interfaces:
org.apache.jena.atlas.lib.Copyable<GraphMem2>, Graph, GraphWithPerform
Direct Known Subclasses:
GraphMem2Fast, GraphMem2Legacy, GraphMem2Roaring

public class GraphMem2 extends GraphMemBase implements GraphWithPerform, org.apache.jena.atlas.lib.Copyable<GraphMem2>
A graph that stores triples in memory. This class is not thread-safe. All triples are stored in a TripleStore.

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

  • 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 interface: Graph
      returns this Graph's capabilities
      Specified by:
      getCapabilities in interface Graph
      Overrides:
      getCapabilities in class GraphBase
    • copy

      public GraphMem2 copy()
      Creates a copy of this graph. Since the triples and nodes are immutable, the copy contains the same triples and nodes as this graph. Modifications to the copy will not affect this graph.
      Specified by:
      copy in interface org.apache.jena.atlas.lib.Copyable<GraphMem2>
      Returns:
      independent copy of the current graph