Class LegacyTripleStore

java.lang.Object
org.apache.jena.mem.store.legacy.LegacyTripleStore
All Implemented Interfaces:
org.apache.jena.atlas.lib.Copyable<TripleStore>, TripleStore

public class LegacyTripleStore extends Object implements TripleStore
Successor of GraphTripleStoreMem that uses term-equality instead of literal value equality. This implementation also does not support Iterator.remove().

Inner structure: - three NodeToTriplesMapMem instances for each of the three triple fields (subject, predicate, object) - each of these maps is a HashCommonMap with Node keys and JenaSet values. - for up to 9 triples with the same subject, predicate or object, the JenaSet is a ArrayBunch, otherwise it is a HashedTripleBunch.

Additional optimizations: - because we know that if a triple exists in one of the maps, it also exists in the other two, we can use the JenaSet.addUnchecked(java.lang.Object) and JenaMapSetCommon.removeUnchecked(java.lang.Object) methods to avoid unnecessary checks.

  • Constructor Details

    • LegacyTripleStore

      public LegacyTripleStore()
  • Method Details

    • add

      public void add(Triple triple)
      Description copied from interface: TripleStore
      Add a triple to the store. Does nothing if the triple is already present.
      Specified by:
      add in interface TripleStore
      Parameters:
      triple - the triple to add
    • remove

      public void remove(Triple triple)
      Description copied from interface: TripleStore
      Remove a triple from the store. Does nothing if the triple is not present.
      Specified by:
      remove in interface TripleStore
      Parameters:
      triple - the triple to remove
    • clear

      public void clear()
      Description copied from interface: TripleStore
      Remove all triples from the store. After this call, TripleStore.isEmpty() returns true and any associated indices are emptied.
      Specified by:
      clear in interface TripleStore
    • countTriples

      public int countTriples()
      Description copied from interface: TripleStore
      Returns the number of triples in the store.
      Specified by:
      countTriples in interface TripleStore
      Returns:
      the number of triples
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: TripleStore
      Returns true if the store contains no triples.
      Specified by:
      isEmpty in interface TripleStore
      Returns:
      true if empty
    • contains

      public boolean contains(Triple tripleMatch)
      Description copied from interface: TripleStore
      Returns true if the store contains any triple matching the given pattern. The pattern may contain wildcards (e.g. Node.ANY).
      Specified by:
      contains in interface TripleStore
      Parameters:
      tripleMatch - the triple pattern to match
      Returns:
      true if at least one matching triple exists
    • stream

      public Stream<Triple> stream()
      Description copied from interface: TripleStore
      Returns a Stream of all triples in the store. The returned stream supports BaseStream.parallel().
      Specified by:
      stream in interface TripleStore
      Returns:
      a stream over every triple in this store
    • stream

      public Stream<Triple> stream(Triple tripleMatch)
      Description copied from interface: TripleStore
      Returns a Stream of every triple in the store matching the given pattern. The returned stream supports BaseStream.parallel().
      Specified by:
      stream in interface TripleStore
      Parameters:
      tripleMatch - the triple pattern to match (may contain wildcards)
      Returns:
      a stream over the matching triples
    • find

      public ExtendedIterator<Triple> find(Triple tripleMatch)
      Description copied from interface: TripleStore
      Returns an ExtendedIterator over every triple in the store matching the given pattern.
      Specified by:
      find in interface TripleStore
      Parameters:
      tripleMatch - the triple pattern to match (may contain wildcards)
      Returns:
      an iterator over the matching triples
    • copy

      public LegacyTripleStore copy()
      Description copied from interface: TripleStore
      Returns an independent copy of this store. Since Nodes and Triples are immutable, the copy may share node and triple instances with the original; only the container/index data structures are duplicated so that mutations in either store do not affect the other.
      Specified by:
      copy in interface org.apache.jena.atlas.lib.Copyable<TripleStore>
      Specified by:
      copy in interface TripleStore
      Returns:
      an independent copy of this store