Class GraphMemFactory

java.lang.Object
org.apache.jena.graph.GraphMemFactory

public class GraphMemFactory extends Object
A factory class for creating memory Graphs.

Apache Jena is migrating to term semantics graph for consistency across all in-memory and persistent storage graphs.

All the graphs that this factory creates are not thread-safe. Note that if the memory Graph is structurally modified at any time after the iterator has been created by any of the find* or stream* methods, the iterator may throw a ConcurrentModificationException if continued with it after this modification. This may happen even if the queried data does not relate directly to the modified data (i.e. when triple search pattern does not match added or deleted triple).

The good practice is to explicitly close any ExtendedIterator immediately after a read operation. For GraphMem implementations ExtendedIterator's materializing methods (such as ExtendedIterator.toList()) could be used safely without explicit close. The same is true for Java Stream's terminal operations.

  • Method Details

    • setDftGraphSameTerm

      @Deprecated(forRemoval=true) public static void setDftGraphSameTerm(boolean value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      To be removed.
      Set the default mode for in-memory graphs : same term (true) or same value (false).

      This is initially set with system property "jena:graphSameTerm" with the system default is same value (Jena4).

      This affects createDefaultGraph().

    • dftGraphSameTerm

      @Deprecated(forRemoval=true) public static boolean dftGraphSameTerm()
      Deprecated, for removal: This API element is subject to removal in a future version.
      To be removed.
      Get the default mode for in-memory for graphs : same term (true) or same value (false).

      This is used by createDefaultGraph().

    • createDefaultGraph

      public static Graph createDefaultGraph()
      Answer a memory-based graph. This is the system default.
    • createGraphMem

      @Deprecated(forRemoval=true) public static Graph createGraphMem()
      Deprecated, for removal: This API element is subject to removal in a future version.
      To be renamed. Use createGraphMemForModel(). The function will be re-purposed for the default same-term memory graph.
    • createGraphMemForModel

      public static Graph createGraphMemForModel()
      This function will track the preferred general purpose graph for the Model API.
    • createDefaultGraphSameValue

      public static Graph createDefaultGraphSameValue()
      Answer a memory-based graph with "same value" semantics used in Jena2, Jena3 and Jena4 for in-memory graphs. Jena5 changed to "same term" semantics. This method will continue to provide a "same value" graph. This is used for the Model API.
    • createDefaultGraphSameTerm

      public static Graph createDefaultGraphSameTerm()
      Answer a memory-based graph with "same term" semantics This method will continue to provide the preferred general purpose "same term" graph.
    • createGraphMemBasic

      public static Graph createGraphMemBasic()
      A graph that stores triples in memory. This class is not thread-safe.

      • This graph provides term equality.
      • Iterator over this graph does not provide Iterator.remove

      It has improved performance compared to GraphMem with a simpler implementation, primarily due to not providing support for Iterator.remove().

      See GraphMem2Legacy for details.

    • createGraphMem2Basic

      @Deprecated(forRemoval=true) public static Graph createGraphMem2Basic()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • createGraphMem2

      public static Graph createGraphMem2()
      A graph that stores triples in memory. This class is not thread-safe.

      • This graph provides term equality.
      • Iterator over this graph does not provide Iterator.remove

      This graph implementation provides improved performance with a minor increase in memory usage.

      See GraphMem2Fast for details.

    • createGraphMemRoaring

      public static Graph createGraphMemRoaring()
      A graph that stores triples in memory. This class is not thread-safe.

      • This graph provides term equality.
      • Iterator over this graph does not provide Iterator.remove

      GraphMem2Roaring is focused on handling large in-memory graphs. It uses Roaring bitmaps for indexing.

      See GraphMem2Roaring for details.

    • createGraphMem2Roaring

      @Deprecated(forRemoval=true) public static Graph createGraphMem2Roaring()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • empty

      public static Graph empty()
      Immutable graph with no triples