Class StorageComposers


  • public class StorageComposers
    extends Object
    A collection of static methods for composing storage structures such as arbitrarily nested maps
    Author:
    Claus Stadler 11/09/2020
    • Constructor Detail

      • StorageComposers

        public StorageComposers()
    • Method Detail

      • leafSet

        public static <D,​C,​S extends Set<D>> StorageNodeMutable<D,​C,​S> leafSet​(SetSupplier setSupplier,
                                                                                                       org.aksw.commons.tuple.TupleAccessor<D,​C> tupleAccessor)
      • leafComponentSet

        public static <D,​C,​S extends Set<C>> StorageNodeMutable<D,​C,​S> leafComponentSet​(int tupleIdx,
                                                                                                                SetSupplier setSupplier,
                                                                                                                org.aksw.commons.tuple.TupleAccessor<D,​C> tupleAccessor)
      • leafList

        public static <D,​C> StorageNodeMutable<D,​C,​List<D>> leafList​(ListSupplier listSupplier,
                                                                                       org.aksw.commons.tuple.TupleAccessor<D,​C> tupleAccessor)
      • leafMap

        public static <D,​C,​S extends Map<C,​D>> StorageNodeMutable<D,​C,​S> leafMap​(int tupleIdx,
                                                                                                               MapSupplier mapSupplier,
                                                                                                               org.aksw.commons.tuple.TupleAccessor<D,​C> tupleAccessor)
      • altN

        public static <D,​C> StorageNodeMutable<D,​C,​?> altN​(List<? extends StorageNodeMutable<D,​C,​?>> children)
        Generic construction for composition from multiple composers Breaks strong typing in contrast to static alternatives{1, 2, ...} constructions that could e.g. yield Map> types
        Type Parameters:
        D -
        C -
        V -
        Parameters:
        tupleIdx -
        mapSupplier -
        child -
        Returns:
      • postProcessAdd

        public static <D,​C,​V> StorageNodeMutable<D,​C,​V> postProcessAdd​(StorageNodeMutable<D,​C,​V> delegate,
                                                                                               java.util.function.BiConsumer<V,​D> postProcessor)
        A wrapper for a StorageNodeMutable.add(Object, Object) that allows for running a post processing action after a regular insert.
        Type Parameters:
        D -
        C -
        V -
        Parameters:
        delegate -
        postProcessor -
        Returns:
      • wrapWithCanonicalization

        public static <D,​C,​V,​X extends StorageNodeMutable<D,​C,​V>> StorageNodeWrapperCodec<D,​C,​V,​X> wrapWithCanonicalization​(X delegate)
        Canonicalization maps all equivalent tuples and components w.r.t. .equals() to canonical instances such that '==' becomes sufficient for equality checks.
        Type Parameters:
        D -
        C -
        V -
        X -
        Parameters:
        delegate -
        Returns:
      • wrapWithDictionary

        public static <D1,​C1,​D2,​C2,​V,​X extends StorageNodeMutable<D2,​C2,​V>> StorageNodeMutable<D1,​C1,​V> wrapWithDictionary​(X delegate,
                                                                                                                                                                                 org.aksw.commons.tuple.TupleAccessor<D1,​C1> sourceTupleAccessor)
        DON'T USE ; maintain a TupleCodec separately instead
        Type Parameters:
        D1 - The source domain tuple type, e.g. Triple
        C1 - The source domain component type, e.g. Node
        D2 - The target domain tuple type, e.g. int[]
        C2 - The target domain component type, e.g. Integer
        V - The type of the store structure being wrapped; must be based on D2 and C2
        X - The type of the storage being wrapped