Class SPARQLStar2CypherTranslatorImpl

java.lang.Object
se.liu.ida.hefquin.engine.wrappers.lpg.impl.SPARQLStar2CypherTranslatorImpl
All Implemented Interfaces:
SPARQLStar2CypherTranslator

public class SPARQLStar2CypherTranslatorImpl extends Object implements SPARQLStar2CypherTranslator
  • Constructor Details

    • SPARQLStar2CypherTranslatorImpl

      public SPARQLStar2CypherTranslatorImpl()
  • Method Details

    • translateBGP

      public SPARQL2CypherTranslationResult translateBGP(Set<org.apache.jena.graph.Triple> bgp, LPG2RDFConfiguration conf, boolean naive)
      Description copied from interface: SPARQLStar2CypherTranslator
      Translates each individual triple pattern in the given BGP, and then combines the individual translations into one Cypher query that represents the whole BGP. This method statically analyzes the BGP to obtain insight on the boundedness properties of the variables in the BGP to prune unuseful subqueries.
      Specified by:
      translateBGP in interface SPARQLStar2CypherTranslator
      naive - if naive translation is required.
    • translateTriplePattern

      public SPARQL2CypherTranslationResult translateTriplePattern(org.apache.jena.graph.Triple tp, LPG2RDFConfiguration conf)
      Description copied from interface: SPARQLStar2CypherTranslator
      Translates the given Triple Pattern into a Cypher query, using a given LPG2RDFConfiguration. This method returns a CypherQuery object and a SPARQL-to-Cypher variable mapping. If the Triple Pattern has a shape for which the configuration-specific RDF-star view of the LPG is guaranteed to obtain no matching triples, this method returns null.
      Specified by:
      translateTriplePattern in interface SPARQLStar2CypherTranslator
    • translateTriplePattern

      public SPARQL2CypherTranslationResult translateTriplePattern(org.apache.jena.graph.Triple tp, LPG2RDFConfiguration conf, CypherVarGenerator generator, Set<org.apache.jena.graph.Node> certainNodes, Set<org.apache.jena.graph.Node> certainEdgeLabels, Set<org.apache.jena.graph.Node> certainNodeLabels, Set<org.apache.jena.graph.Node> certainPropertyNames, Set<org.apache.jena.graph.Node> certainPropertyValues)
      Description copied from interface: SPARQLStar2CypherTranslator
      Translates a triple pattern to a Cypher query, using restricted rules based on the different boundedness properties the variables might have
      Specified by:
      translateTriplePattern in interface SPARQLStar2CypherTranslator
    • handleTriplePattern

      protected static CypherQuery handleTriplePattern(org.apache.jena.graph.Triple tp, LPG2RDFConfiguration configuration, CypherVarGenerator gen, Set<org.apache.jena.graph.Node> certainNodes, Set<org.apache.jena.graph.Node> certainEdgeLabels, Set<org.apache.jena.graph.Node> certainNodeLabels, Set<org.apache.jena.graph.Node> certainPropertyNames, Set<org.apache.jena.graph.Node> certainPropertyValues)
      This method handles the translation of a given triple pattern, distinguishing the cases where the triple pattern is nested or non-nested. If the triple pattern is non-nested, this method returns the direct translation of it. If the triple pattern is nested, it first translates the embedded triple pattern, and then adds conditions, iterators or return statements depending on the case.
    • translateTriplePattern

      protected static CypherQuery translateTriplePattern(org.apache.jena.graph.Triple tp, LPG2RDFConfiguration configuration, CypherVarGenerator gen, Set<org.apache.jena.graph.Node> certainNodes, Set<org.apache.jena.graph.Node> certainEdgeLabels, Set<org.apache.jena.graph.Node> certainNodeLabels, Set<org.apache.jena.graph.Node> certainPropertyNames, Set<org.apache.jena.graph.Node> certainPropertyValues, boolean isEdgeCompatible)
      This method translates non-nested triple patterns into Cypher, leveraging knowledge of properties that the variables in the triple pattern may hold like boundedness to given LPG elements or edge-compatibility.
    • getVarPropertyLiteral

      protected static CypherQuery getVarPropertyLiteral(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen, Set<org.apache.jena.graph.Node> certainNodes)
    • getVarLabelClass

      protected static CypherQuery getVarLabelClass(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getVarRelationshipNode

      protected static CypherQuery getVarRelationshipNode(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getNodeLabelVar

      protected static CypherQuery getNodeLabelVar(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getNodePropertyVar

      protected static CypherQuery getNodePropertyVar(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getNodeRelationshipVar

      protected static CypherQuery getNodeRelationshipVar(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getNodeVarNode

      protected static CypherQuery getNodeVarNode(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getNodeVarLiteral

      protected static CypherQuery getNodeVarLiteral(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getNodeVarLabel

      protected static CypherQuery getNodeVarLabel(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getVarLabelVar

      protected static CypherQuery getVarLabelVar(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getVarRelationshipVar

      protected static CypherQuery getVarRelationshipVar(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getVarPropertyVar

      protected static CypherQuery getVarPropertyVar(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen, Set<org.apache.jena.graph.Node> certainNodes)
    • getVarVarLabel

      protected static CypherQuery getVarVarLabel(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getVarVarNode

      protected static CypherQuery getVarVarNode(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen)
    • getVarVarLiteral

      protected static CypherQuery getVarVarLiteral(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen, Set<org.apache.jena.graph.Node> certainNodes)
    • getNodeVarVar

      protected static CypherQuery getNodeVarVar(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen, Set<org.apache.jena.graph.Node> certainNodes, Set<org.apache.jena.graph.Node> certainNodeLabels, Set<org.apache.jena.graph.Node> certainPropertyNames, Set<org.apache.jena.graph.Node> certainPropertyValues, Set<org.apache.jena.graph.Node> certainEdgeLabels, boolean isEdgeCompatible)
    • getVarVarVar

      protected static CypherQuery getVarVarVar(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, LPG2RDFConfiguration configuration, CypherVarGenerator gen, Set<org.apache.jena.graph.Node> certainNodes, Set<org.apache.jena.graph.Node> certainNodeLabels, Set<org.apache.jena.graph.Node> certainPropertyNames, Set<org.apache.jena.graph.Node> certainPropertyValues, Set<org.apache.jena.graph.Node> certainEdgeLabels, boolean isEdgeCompatible)
    • rewriteJoins

      public CypherMatchQuery rewriteJoins(CypherMatchQuery query)
      Description copied from interface: SPARQLStar2CypherTranslator
      Receives a CypherMatchQuery and rewrites explicit variable joins in the WHERE clause as implicit joins in the MATCH clauses. Then, it removes redundant MATCH clauses. e.g. query MATCH (a)-[b]->(c) MATCH (x) WHERE a=x RETURN x is rewritten as MATCH (a)-[b]->(c) RETURN a
      Specified by:
      rewriteJoins in interface SPARQLStar2CypherTranslator
    • mergePaths

      public List<MatchClause> mergePaths(List<MatchClause> matchClauses)
      Description copied from interface: SPARQLStar2CypherTranslator
      Receives a list of MatchClause and merges compatible clauses into longer paths. e.g., if receives (x)-[a]->(y) and (z)-[b]->(y) returns (z)-[b]->(y)<-[a]-(x).
      Specified by:
      mergePaths in interface SPARQLStar2CypherTranslator
    • getNumberOfVarOccurrences

      public static int getNumberOfVarOccurrences(org.apache.jena.graph.Triple tp)
      Returns the number of elements of the given triple pattern that are variables.