Interface StorageNode<D,C,V>

Type Parameters:
D -
C -
V -
All Known Subinterfaces:
StorageNodeMutable<D,C,V>
All Known Implementing Classes:
StorageNodeAlt2, StorageNodeAlt3, StorageNodeAltBase, StorageNodeAltN, StorageNodeBase, StorageNodeCompoundBase, StorageNodeDictionary, StorageNodeDomainWrapping, StorageNodeForwarding, StorageNodeInnerMap, StorageNodeLeafComponentSet, StorageNodeLeafDomainList, StorageNodeLeafDomainSet, StorageNodeLeafMap, StorageNodeMutableForwarding, StorageNodeMutableForwardingBase, StorageNodeWrapperCodec

public interface StorageNode<D,C,V>
A StorageNode can express nested storage such as nested maps, lists and sets for tuples. A Storage may have alternative child structures to choose from. All alternatives are assumed to be in sync and contain the same instance data - but the nesting may differ. This class only provides methods for reading data. The base interface that allows for addition and removal of data is StorageNodeMutable
Author:
Claus Stadler 11/09/2020
  • Method Details

    • getChildren

      List<? extends StorageNode<D,C,?>> getChildren()
      Each node in the storage expression may have 0 or more children
      Returns:
    • isDelegate

      default boolean isDelegate()
      Attempt to access a store as a map. The StorageNode and the store must be of the appropriate types in order for this operation to succeed.
      Parameters:
      store -
      Returns:
    • getPublicDelegate

      default StorageNode<D,C,V> getPublicDelegate()
    • isAltNode

      default boolean isAltNode()
      Whether this storage node stores are a sequences of alternatives Experimental method; may be replaced by a generic getStoreType() method that returns e.g Alt.class, Set.class, etc.
      Returns:
    • isSetNode

      default boolean isSetNode()
      Whether this storage node stores are sets Experimental method; may be replaced by a generic getStoreType() method that returns e.g Alt.class, Set.class, etc.
      Returns:
    • isListNode

      default boolean isListNode()
      Whether this storage node stores are lists Experimental method; may be replaced by a generic getStoreType() method that returns e.g Alt.class, Set.class, etc.
      Returns:
    • isMapNode

      default boolean isMapNode()
      Whether this storage node stores are a maps Experimental method; may be replaced by a generic getStoreType() method that returns e.g Alt.class, Set.class, etc.
      Returns:
    • holdsDomainTuples

      default boolean holdsDomainTuples()
      Flag that when true indicates that this storage node's values are tuples of type D - i.e. "domain tuples".
      Returns:
    • getStoreAsMap

      default Map<?,?> getStoreAsMap(Object store)
    • getStoreAsList

      default List<?> getStoreAsList(Object store)
    • getStoreAsSet

      default Set<?> getStoreAsSet(Object store)
    • getKeyTupleIdxs

      int[] getKeyTupleIdxs()
      The component indexes by which this node indexes May be empty but never null
      Returns:
    • getTupleAccessor

      TupleBridge<D,C> getTupleAccessor()
      Future: Allow the storageNode to answer how efficiently it can answer the constraints in a given constraint list E.g. O(1) or O(log(n)) or O(n)
      Returns:
    • streamerForKeysAsComponent

      <T> Streamer<V,C> streamerForKeysAsComponent(T pattern, TupleAccessor<? super T, ? extends C> accessor)
      Compiles from a given pattern a function that can stream the matching keys from the appropriate store. The keys must be instances of the component type otherwise an exception is raised
      Returns:
    • streamerForKeysAsTuples

      <T> Streamer<V,List<C>> streamerForKeysAsTuples(T pattern, TupleAccessor<? super T, ? extends C> accessor)
      Compiles from a given pattern a function that can stream the matching keys from the appropriate store. The keys must be instances of the component type otherwise an exception is raised if getKeyTupleIdxs().length == 0 then returns a single tuple that projects no components
      Parameters:
      store -
      Returns:
    • streamerForKeys

      <T> Streamer<V,?> streamerForKeys(T pattern, TupleAccessor<? super T, ? extends C> accessor)
    • getKeyComponentRaw

      C getKeyComponentRaw(Object key, int idx)
      Obtain components from the internal representation of key that was used for indexing w.r.t. getKeyTupleIdxs().
      Parameters:
      key -
      idx - In the range 0 to
      invalid @link
      {@link getKeyTupleIdxs().length
      } (exclusive) If a key has no components calling this method will always raise IndexOutOfBoundsException
      Returns:
    • chooseSubStore

      Object chooseSubStore(V store, int subStoreIdx)
    • chooseSubStoreRaw

      default Object chooseSubStoreRaw(Object store, int subStoreIdx)
    • streamerForValues

      <T> Streamer<V,?> streamerForValues(T pattern, TupleAccessor<? super T, ? extends C> accessor)
      Returns an object that can extract the stream of values at an index node under constraints map: { entry.value | entry in map and entry.key matches condition} leafSet: set.entries.stream() A leaf set does not have any keys that could affect the result stream
      Type Parameters:
      T -
      Parameters:
      pattern -
      accessor -
      Returns:
    • streamerForKeyAndSubStoreAlts

      <T> Streamer<V, ? extends Map.Entry<?,?>> streamerForKeyAndSubStoreAlts(T pattern, TupleAccessor<? super T, ? extends C> accessor)
      The streamer returns entry that hold a tuple-like key and conceptually alternatives of sub-stores The tuple components of the key can be accessed using getKeyComponentRaw(Object, int) There are as many components as the length of getKeyTupleIdxs() If there is 0 components then any invocation of getKeyComponentRaw(Object, int) will fail with a UnsupportedOperationException. To extract a specific alternative from the substore use chooseSubStore(Object, int). If getChildren() is not empty then there are as many substore indices as there are children If there are no children then there is an implicit single sub store with index 0
      Type Parameters:
      T -
      Parameters:
      pattern -
      accessor -
      Returns:
    • streamEntries

      <T> Stream<?> streamEntries(V store, T tupleLike, TupleAccessor<? super T, ? extends C> tupleAccessor)
      Stream all entries under equality constraints obtained from a tuple-like pattern
      Type Parameters:
      T -
      Parameters:
      store -
      tupleLike -
      tupleAccessor -
      Returns:
    • streamEntriesRaw

      default <T> Stream<?> streamEntriesRaw(Object store, T tupleLike, TupleAccessor<? super T, ? extends C> tupleAccessor)
    • streamEntriesRaw

      default Stream<?> streamEntriesRaw(Object store)
      Generic method to stream the content - mainly for debugging
      Returns:
    • streamEntries

      default Stream<?> streamEntries(V store)