Interface TripleStore

All Superinterfaces:
org.apache.jena.atlas.lib.Copyable<TripleStore>
All Known Implementing Classes:
FastTripleStore, IndexedSetTripleStore, LegacyTripleStore, RoaringTripleStore

public interface TripleStore extends org.apache.jena.atlas.lib.Copyable<TripleStore>
Storage abstraction used by the mem2 in-memory graph implementations. A TripleStore is a set-like collection of Triples that also supports pattern-based lookup (find(org.apache.jena.graph.Triple), stream(Triple), contains(org.apache.jena.graph.Triple)). Implementations are expected to be efficient for the lookup patterns described in MatchPattern.

Implementations are not required to be thread-safe.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Triple triple)
    Add a triple to the store.
    void
    Remove all triples from the store.
    boolean
    contains(Triple tripleMatch)
    Returns true if the store contains any triple matching the given pattern.
    Returns an independent copy of this store.
    int
    Returns the number of triples in the store.
    find(Triple tripleMatch)
    Returns an ExtendedIterator over every triple in the store matching the given pattern.
    boolean
    Returns true if the store contains no triples.
    void
    remove(Triple triple)
    Remove a triple from the store.
    Returns a Stream of all triples in the store.
    stream(Triple tripleMatch)
    Returns a Stream of every triple in the store matching the given pattern.
  • Method Details

    • add

      void add(Triple triple)
      Add a triple to the store. Does nothing if the triple is already present.
      Parameters:
      triple - the triple to add
    • remove

      void remove(Triple triple)
      Remove a triple from the store. Does nothing if the triple is not present.
      Parameters:
      triple - the triple to remove
    • clear

      void clear()
      Remove all triples from the store. After this call, isEmpty() returns true and any associated indices are emptied.
    • countTriples

      int countTriples()
      Returns the number of triples in the store.
      Returns:
      the number of triples
    • isEmpty

      boolean isEmpty()
      Returns true if the store contains no triples.
      Returns:
      true if empty
    • contains

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

      Stream<Triple> stream()
      Returns a Stream of all triples in the store. The returned stream supports BaseStream.parallel().
      Returns:
      a stream over every triple in this store
    • stream

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

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

      TripleStore copy()
      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>
      Returns:
      an independent copy of this store