Package org.aksw.commons.index.core
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 Summary
Modifier and TypeMethodDescriptionchooseSubStore(V store, int subStoreIdx) default ObjectchooseSubStoreRaw(Object store, int subStoreIdx) List<? extends StorageNode<D,C, ?>> Each node in the storage expression may have 0 or more childrengetKeyComponentRaw(Object key, int idx) Obtain components from the internal representation of key that was used for indexing w.r.t.int[]The component indexes by which this node indexes May be empty but never nulldefault StorageNode<D,C, V> default List<?>getStoreAsList(Object store) default Map<?,?> getStoreAsMap(Object store) default Set<?>getStoreAsSet(Object store) Future: Allow the storageNode to answer how efficiently it can answer the constraints in a given constraint list E.g.default booleanFlag that when true indicates that this storage node's values are tuples of type D - i.e.default booleanWhether 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.default booleanAttempt to access a store as a map.default booleanWhether 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.default booleanWhether 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.default booleanWhether 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.default Stream<?>streamEntries(V store) <T> Stream<?>streamEntries(V store, T tupleLike, TupleAccessor<? super T, ? extends C> tupleAccessor) Stream all entries under equality constraints obtained from a tuple-like patterndefault Stream<?>streamEntriesRaw(Object store) Generic method to stream the content - mainly for debuggingdefault <T> Stream<?>streamEntriesRaw(Object store, T tupleLike, TupleAccessor<? super T, ? extends C> tupleAccessor) 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 usinggetKeyComponentRaw(Object, int)There are as many components as the length ofgetKeyTupleIdxs()If there is 0 components then any invocation ofgetKeyComponentRaw(Object, int)will fail with aUnsupportedOperationException.streamerForKeys(T pattern, TupleAccessor<? super T, ? extends C> accessor) 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.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.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
-
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
-
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
-
getStoreAsList
-
getStoreAsSet
-
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
-
getKeyComponentRaw
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 {@link getKeyTupleIdxs().length} (exclusive) If a key has no components calling this method will always raiseIndexOutOfBoundsException- Returns:
-
chooseSubStore
-
chooseSubStoreRaw
-
streamerForValues
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 usinggetKeyComponentRaw(Object, int)There are as many components as the length ofgetKeyTupleIdxs()If there is 0 components then any invocation ofgetKeyComponentRaw(Object, int)will fail with aUnsupportedOperationException. To extract a specific alternative from the substore usechooseSubStore(Object, int). IfgetChildren()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
Generic method to stream the content - mainly for debugging- Returns:
-
streamEntries
-