Package org.aksw.commons.index.core
Class StorageNodeInnerMap<D,C,K,V,M extends Map<K,V>>
- java.lang.Object
-
- org.aksw.commons.index.core.StorageNodeBase<D,C,M>
-
- org.aksw.commons.index.core.StorageNodeInnerMap<D,C,K,V,M>
-
- Type Parameters:
D- The domain type of tupleC- The component type of the domain tupleK- The key type of the map; depends on one or more componentsV- The value type of the map which is
- All Implemented Interfaces:
StorageNode<D,C,M>,StorageNodeMutable<D,C,M>
public class StorageNodeInnerMap<D,C,K,V,M extends Map<K,V>> extends StorageNodeBase<D,C,M>
- Author:
- Claus Stadler 11/09/2020
-
-
Field Summary
Fields Modifier and Type Field Description protected StorageNodeMutable<D,C,V>childprotected TupleValueFunction<C,K>keyFunctionprotected org.aksw.commons.tuple.TupleAccessorCore<? super K,? extends C>keyToComponentprotected MapSuppliermapSupplier-
Fields inherited from class org.aksw.commons.index.core.StorageNodeBase
tupleAccessor, tupleIdxs
-
-
Constructor Summary
Constructors Constructor Description StorageNodeInnerMap(int[] tupleIdxs, org.aksw.commons.tuple.TupleAccessor<D,C> tupleAccessor, StorageNodeMutable<D,C,V> child, MapSupplier mapSupplier, TupleValueFunction<C,K> keyFunction, org.aksw.commons.tuple.TupleAccessorCore<? super K,? extends C> keyToComponent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(M map, D tupleLike)ObjectchooseSubStore(M store, int subStoreIdx)voidclear(M store)Clear a store's content.List<StorageNode<D,C,?>>getChildren()Each node in the storage expression may have 0 or more childrenCgetKeyComponent(K key, int idx)CgetKeyComponentRaw(Object key, int idx)Obtain components from the internal representation of key that was used for indexing w.r.t.MgetStoreAsMap(Object store)booleanisEmpty(M map)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.MnewStore()static <T,C>
Object[]projectTupleToArray(int[] tupleIdxs, T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<T,C> tupleAccessor)booleanremove(M map, D tupleLike)<T> java.util.stream.Stream<Map.Entry<K,?>>streamEntries(M map, T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)Stream all entries under equality constraints obtained from a tuple-like pattern<T> Streamer<M,Map.Entry<K,V>>streamerForEntriesUnderConstraints(T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)<T> Streamer<M,Map.Entry<K,V>>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 usingStorageNode.getKeyComponentRaw(Object, int)There are as many components as the length ofStorageNode.getKeyTupleIdxs()If there is 0 components then any invocation ofStorageNode.getKeyComponentRaw(Object, int)will fail with aUnsupportedOperationException.<T> Streamer<M,K>streamerForKeys(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)<T> Streamer<M,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<M,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<M,K>streamerForKeysUnderConstraints(T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)<T> Streamer<M,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<T> Streamer<M,V>streamerForValuesUnderConstraints(T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)StringtoString()KtupleToKey(D tupleLike)-
Methods inherited from class org.aksw.commons.index.core.StorageNodeBase
getKeyTupleIdxs, getTupleAccessor
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.aksw.commons.index.core.StorageNode
chooseSubStoreRaw, getKeyTupleIdxs, getPublicDelegate, getStoreAsList, getStoreAsSet, getTupleAccessor, holdsDomainTuples, isAltNode, isDelegate, isListNode, isSetNode, streamEntries, streamEntriesRaw, streamEntriesRaw
-
Methods inherited from interface org.aksw.commons.index.core.StorageNodeMutable
addRaw, clearRaw, isEmptyRaw, removeRaw
-
-
-
-
Field Detail
-
child
protected StorageNodeMutable<D,C,V> child
-
mapSupplier
protected MapSupplier mapSupplier
-
keyFunction
protected TupleValueFunction<C,K> keyFunction
-
keyToComponent
protected org.aksw.commons.tuple.TupleAccessorCore<? super K,? extends C> keyToComponent
-
-
Constructor Detail
-
StorageNodeInnerMap
public StorageNodeInnerMap(int[] tupleIdxs, org.aksw.commons.tuple.TupleAccessor<D,C> tupleAccessor, StorageNodeMutable<D,C,V> child, MapSupplier mapSupplier, TupleValueFunction<C,K> keyFunction, org.aksw.commons.tuple.TupleAccessorCore<? super K,? extends C> keyToComponent)
-
-
Method Detail
-
getChildren
public List<StorageNode<D,C,?>> getChildren()
Description copied from interface:StorageNodeEach node in the storage expression may have 0 or more children- Returns:
-
clear
public void clear(M store)
Description copied from interface:StorageNodeMutableClear a store's content. Cascades to any sub-stores.
-
streamEntries
public <T> java.util.stream.Stream<Map.Entry<K,?>> streamEntries(M map, T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)
Description copied from interface:StorageNodeStream all entries under equality constraints obtained from a tuple-like pattern- Returns:
-
tupleToKey
public K tupleToKey(D tupleLike)
-
isMapNode
public boolean isMapNode()
Description copied from interface:StorageNodeWhether 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.- Specified by:
isMapNodein interfaceStorageNode<D,C,K>- Returns:
-
getStoreAsMap
public M getStoreAsMap(Object store)
- Specified by:
getStoreAsMapin interfaceStorageNode<D,C,K>
-
isEmpty
public boolean isEmpty(M map)
- Specified by:
isEmptyin interfaceStorageNodeMutable<D,C,K>
-
projectTupleToArray
public static <T,C> Object[] projectTupleToArray(int[] tupleIdxs, T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<T,C> tupleAccessor)
-
streamerForKeysUnderConstraints
public <T> Streamer<M,K> streamerForKeysUnderConstraints(T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)
-
streamerForValuesUnderConstraints
public <T> Streamer<M,V> streamerForValuesUnderConstraints(T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)
-
streamerForEntriesUnderConstraints
public <T> Streamer<M,Map.Entry<K,V>> streamerForEntriesUnderConstraints(T tupleLike, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> tupleAccessor)
-
streamerForKeysAsComponent
public <T> Streamer<M,C> streamerForKeysAsComponent(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)
Description copied from interface:StorageNodeCompiles 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- Specified by:
streamerForKeysAsComponentin interfaceStorageNode<D,C,K>- Returns:
-
streamerForValues
public <T> Streamer<M,V> streamerForValues(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)
Description copied from interface:StorageNodeReturns 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- Specified by:
streamerForValuesin interfaceStorageNode<D,C,K>- Returns:
-
streamerForKeysAsTuples
public <T> Streamer<M,List<C>> streamerForKeysAsTuples(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)
Description copied from interface:StorageNodeCompiles 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- Specified by:
streamerForKeysAsTuplesin interfaceStorageNode<D,C,K>- Returns:
-
streamerForKeys
public <T> Streamer<M,K> streamerForKeys(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)
- Specified by:
streamerForKeysin interfaceStorageNode<D,C,K>
-
streamerForKeyAndSubStoreAlts
public <T> Streamer<M,Map.Entry<K,V>> streamerForKeyAndSubStoreAlts(T pattern, org.aksw.commons.tuple.TupleAccessorCore<? super T,? extends C> accessor)
Description copied from interface:StorageNodeThe streamer returns entry that hold a tuple-like key and conceptually alternatives of sub-stores The tuple components of the key can be accessed usingStorageNode.getKeyComponentRaw(Object, int)There are as many components as the length ofStorageNode.getKeyTupleIdxs()If there is 0 components then any invocation ofStorageNode.getKeyComponentRaw(Object, int)will fail with aUnsupportedOperationException. To extract a specific alternative from the substore useStorageNode.chooseSubStore(Object, int). IfStorageNode.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- Specified by:
streamerForKeyAndSubStoreAltsin interfaceStorageNode<D,C,K>- Returns:
-
getKeyComponentRaw
public C getKeyComponentRaw(Object key, int idx)
Description copied from interface:StorageNodeObtain components from the internal representation of key that was used for indexing w.r.t.StorageNode.getKeyTupleIdxs().- Specified by:
getKeyComponentRawin interfaceStorageNode<D,C,K>idx- In the range 0 to {@link getKeyTupleIdxs().length} (exclusive) If a key has no components calling this method will always raiseIndexOutOfBoundsException- Returns:
-
getKeyComponent
public C getKeyComponent(K key, int idx)
-
chooseSubStore
public Object chooseSubStore(M store, int subStoreIdx)
- Specified by:
chooseSubStorein interfaceStorageNode<D,C,K>
-
-