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 isStorageNodeMutable- Author:
- Claus Stadler 11/09/2020
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ObjectchooseSubStore(V store, int subStoreIdx)default ObjectchooseSubStoreRaw(Object store, int subStoreIdx)List<? extends StorageNode<D,C,?>>getChildren()Each node in the storage expression may have 0 or more childrenCgetKeyComponentRaw(Object key, int idx)Obtain components from the internal representation of key that was used for indexing w.r.t.int[]getKeyTupleIdxs()The component indexes by which this node indexes May be empty but never nulldefault StorageNode<D,C,V>getPublicDelegate()default List<?>getStoreAsList(Object store)default Map<?,?>getStoreAsMap(Object store)default Set<?>getStoreAsSet(Object store)org.aksw.commons.tuple.TupleAccessor<D,C>getTupleAccessor()Future: Allow the storageNode to answer how efficiently it can answer the constraints in a given constraint list E.g.default booleanholdsDomainTuples()Flag that when true indicates that this storage node's values are tuples of type D - i.e.default booleanisAltNode()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.default booleanisDelegate()Attempt to access a store as a map.default booleanisListNode()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.default booleanisMapNode()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.default booleanisSetNode()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.default java.util.stream.Stream<?>streamEntries(V store)<T> java.util.stream.Stream<?>streamEntries(V store, T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)Stream all entries under equality constraints obtained from a tuple-like patterndefault java.util.stream.Stream<?>streamEntriesRaw(Object store)Generic method to stream the content - mainly for debuggingdefault <T> java.util.stream.Stream<?>streamEntriesRaw(Object store, T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)<T> Streamer<V,? extends Map.Entry<?,?>>streamerForKeyAndSubStoreAlts(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? 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.<T> Streamer<V,?>streamerForKeys(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)<T> Streamer<V,C>streamerForKeysAsComponent(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)Compiles from a given pattern a function that can stream the matching keys from the appropriate store.<T> Streamer<V,List<C>>streamerForKeysAsTuples(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)Compiles from a given pattern a function that can stream the matching keys from the appropriate store.<T> Streamer<V,?>streamerForValues(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? 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 Detail
-
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:
-
getKeyTupleIdxs
int[] getKeyTupleIdxs()
The component indexes by which this node indexes May be empty but never null- Returns:
-
getTupleAccessor
org.aksw.commons.tuple.TupleAccessor<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, org.aksw.commons.tuple.TupleAccessorCore<? 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, org.aksw.commons.tuple.TupleAccessorCore<? 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, org.aksw.commons.tuple.TupleAccessorCore<? 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 {@link getKeyTupleIdxs().length} (exclusive) If a key has no components calling this method will always raiseIndexOutOfBoundsException- Returns:
-
streamerForValues
<T> Streamer<V,?> streamerForValues(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? 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, org.aksw.commons.tuple.TupleAccessorCore<? 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> java.util.stream.Stream<?> streamEntries(V store, T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? 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> java.util.stream.Stream<?> streamEntriesRaw(Object store, T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)
-
streamEntriesRaw
default java.util.stream.Stream<?> streamEntriesRaw(Object store)
Generic method to stream the content - mainly for debugging- Returns:
-
streamEntries
default java.util.stream.Stream<?> streamEntries(V store)
-
-