Class StorageNodeDictionary<D1,​C1,​D2,​C2,​V,​X extends StorageNodeMutable<D2,​C2,​V>>

  • All Implemented Interfaces:
    StorageNode<D1,​C1,​V>, StorageNodeMutable<D1,​C1,​V>

    public class StorageNodeDictionary<D1,​C1,​D2,​C2,​V,​X extends StorageNodeMutable<D2,​C2,​V>>
    extends Object
    implements StorageNodeMutable<D1,​C1,​V>
    A wrapper for a storage node that adds a dictionary for the components Can be used to map e.g. Nodes to Integers or canonical instances Maybe this fits better on a TupleAccessor? The issue with storage nodes is that they are stateless. So if we wanted to wrap an exiting structure with a dictionary we would end up with: Dictionary, Map Probably it would not be too bad because we could still easily get the nested map structure out Actually, why shouldn't the storage node have a state? StorageNode intStorage; TupleAccessor intAccessor; TupleAccessor tripleAccessor = TupleAccessorTriple.INSTANCE StorageNodeDictionary tripleStorageWrapper = StorageNodeDictionary.wrap(intStorage, nodeAccessor, (dict, c) -> dict.size(), intAccessor) BiMap tripleStorageWrapper.getDictionary();
    Author:
    raven
    • Field Detail

      • dictionary

        protected com.google.common.collect.BiMap<C1,​C2> dictionary
      • sourceTupleAccessor

        protected org.aksw.commons.tuple.TupleAccessor<D1,​C1> sourceTupleAccessor
      • targetTupleAccessor

        protected org.aksw.commons.tuple.TupleAccessor<D2,​C2> targetTupleAccessor
    • Constructor Detail

      • StorageNodeDictionary

        public StorageNodeDictionary​(X delegate,
                                     com.google.common.collect.BiMap<C1,​C2> dictionary,
                                     org.aksw.commons.tuple.TupleAccessor<D1,​C1> sourceTupleAccessor,
                                     org.aksw.commons.tuple.TupleAccessor<D2,​C2> targetTupleAccessor)
    • Method Detail

      • makeEntry

        protected C2 makeEntry​(C1 c1)
      • mapSourceToTarget

        public D2 mapSourceToTarget​(D1 sourceTuple)
      • mapTargetToSource

        public D1 mapTargetToSource​(D2 targetTuple)
      • getKeyTupleIdxs

        public int[] getKeyTupleIdxs()
        Description copied from interface: StorageNode
        The component indexes by which this node indexes May be empty but never null
        Specified by:
        getKeyTupleIdxs in interface StorageNode<D1,​C1,​D2>
        Returns:
      • getTupleAccessor

        public org.aksw.commons.tuple.TupleAccessor<D1,​C1> getTupleAccessor()
        Description copied from interface: StorageNode
        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)
        Specified by:
        getTupleAccessor in interface StorageNode<D1,​C1,​D2>
        Returns:
      • streamerForKeysAsComponent

        public <T> Streamer<V,​C1> streamerForKeysAsComponent​(T pattern,
                                                                   org.aksw.commons.tuple.TupleAccessorCore<? super T,​? extends C1> accessor)
        Description copied from interface: StorageNode
        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
        Specified by:
        streamerForKeysAsComponent in interface StorageNode<D1,​C1,​D2>
        Returns:
      • streamerForKeysAsTuples

        public <T> Streamer<V,​List<C1>> streamerForKeysAsTuples​(T pattern,
                                                                      org.aksw.commons.tuple.TupleAccessorCore<? super T,​? extends C1> accessor)
        Description copied from interface: StorageNode
        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
        Specified by:
        streamerForKeysAsTuples in interface StorageNode<D1,​C1,​D2>
        Returns:
      • streamerForKeys

        public <T> Streamer<V,​?> streamerForKeys​(T pattern,
                                                       org.aksw.commons.tuple.TupleAccessorCore<? super T,​? extends C1> accessor)
        Specified by:
        streamerForKeys in interface StorageNode<D1,​C1,​D2>
      • streamerForValues

        public <T> Streamer<V,​?> streamerForValues​(T pattern,
                                                         org.aksw.commons.tuple.TupleAccessorCore<? super T,​? extends C1> accessor)
        Description copied from interface: StorageNode
        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
        Specified by:
        streamerForValues in interface StorageNode<D1,​C1,​D2>
        Returns:
      • streamEntries

        public <T> java.util.stream.Stream<?> streamEntries​(V store,
                                                            T tupleLike,
                                                            org.aksw.commons.tuple.TupleAccessorCore<? super T,​? extends C1> tupleAccessor)
        Description copied from interface: StorageNode
        Stream all entries under equality constraints obtained from a tuple-like pattern
        Specified by:
        streamEntries in interface StorageNode<D1,​C1,​D2>
        Returns: