Package hydra.pg

Class Merging


  • public class Merging
    extends java.lang.Object
    Utilities for combining multiple vertex or edge types into a single "merged" vertex or edge type, and correspondingly encoding and decoding vertices and edges of these types.
    • Constructor Detail

      • Merging

        public Merging()
    • Method Detail

      • createVertexAdapter

        public static <T,​V> Either<java.lang.String,​StatelessAdapter<java.util.List<VertexType<T>>,​VertexType<T>,​Vertex<V>,​Vertex<V>>> createVertexAdapter​(java.util.List<VertexType<T>> types,
                                                                                                                                                                                         Merging.IdAdapters<T,​V> idAdapters,
                                                                                                                                                                                         boolean unifyIdenticalTypes)
        Create a vertex adapter based on a list of vertex types and given id adapters.
        Type Parameters:
        T - the type parameter for vertex types
        V - the value type for vertex properties
        Parameters:
        types - the list of vertex types to merge
        idAdapters - the id adapters for encoding/decoding vertex and edge ids
        unifyIdenticalTypes - whether to unify identical property types across vertex types
        Returns:
        an Either containing a stateless adapter for the merged vertex type, or an error
      • createEdgeAdapter

        public static <T,​V> Either<java.lang.String,​StatelessAdapter<java.util.List<EdgeType<T>>,​EdgeType<T>,​Edge<V>,​Edge<V>>> createEdgeAdapter​(java.util.List<EdgeType<T>> types,
                                                                                                                                                                               Merging.IdAdapters<T,​V> idAdapters,
                                                                                                                                                                               boolean unifyIdenticalTypes)
        Create an edge adapter based on a list of edge types and given id adapters.
        Type Parameters:
        T - the type parameter for edge types
        V - the value type for edge properties
        Parameters:
        types - the list of edge types to merge
        idAdapters - the id adapters for encoding/decoding vertex and edge ids
        unifyIdenticalTypes - whether to unify identical property types across edge types
        Returns:
        an Either containing a stateless adapter for the merged edge type, or an error
      • stringIdAdapters

        public static <T,​V> Merging.IdAdapters<T,​V> stringIdAdapters​(T stringType,
                                                                                 java.util.function.Function<V,​Either<java.lang.String,​java.lang.String>> fromLiteral,
                                                                                 java.util.function.Function<java.lang.String,​V> toLiteral)
        Create string-based id adapters for merging vertex and edge types.
        Type Parameters:
        T - the type parameter for id types
        V - the value type for ids
        Parameters:
        stringType - the string type to use for merged ids
        fromLiteral - function to extract a string from a literal value
        toLiteral - function to create a literal value from a string
        Returns:
        id adapters configured for string-based ids