Giter VIP home page Giter VIP logo

slothql's Issues

Statically merge queries

Given two queries

q1 = MATCH $pattern1 RETURN $result1
q2 = MATCH $pattern2 RETURN $result2

The merged query should be

q1q2 = MATCH $pattern1, $pattern2 RETURN $result1, $result2 

Introduce subtype choice arrows

While Split is a bundle of arrows with common source that represents a kind of product, similar coproduct representation Choose is needed.

Arrows composition is not completely associative

When mapping a composed arrow with a Functor, the associativity property does not comply.

Functor.map(sel3 ∘ (sel2 ∘ sel1)).to[DBArrow] // Compiles
Functor.map((sel3 ∘ sel2) ∘ sel1).to[DBArrow] // Does not compile

The problem appears because the mapping is defined for a composition sel2 ∘ sel1, not for the underlying arrows.

High-level expressions as arrows

Use arrows from #38.

  • High-level expressions: ScalaExpr
    • Id - identity arrow (self selection)
    • SelectField - expression representing selection of a field of an ADT (case class)
    • FMap - expression representing functor map operation
    • MBind - expression representing monadic bind / flatMap operation
    • SelectIn
      • select sequence index
      • select map key
      • (?) select Option / Either projection value
    • (?) expression for Either projections
    • (?) coproducts
    • execute expression

Cypher syntax: lists

Introduce syntax for cypher lists:

  • list constructor [ ..., ... ]
  • in expression
  • index selection
  • index range selection
  • + concatenation

Map high-level arrows to the intermediate-level ones with Functors

Define Functors for mapping ScalaExpr arrows to GraphPath.

  • IdInitial
  • SelectField depends on graph representation of selected field
    • NodeRelationTarget ∘ OutgoingRelation
    • RelationOutgoingRelation
    • PropertyPropSelection
  • FMap ⇒ ?
  • MBind ⇒ ?
  • SelectIn ⇒ ?

  • Arrow.Split ⇒ ?
  • Arrow.Composition ⇒ ?

Cannot define multiple transformations in a single polymorphic function (#30)

A problem with #30.

While transformations by different functions can be chained

object F1 extends Poly1{
    implicit def impl[A]: Case.Aux[Lit[A], Lit[A with X]] = at[Lit[A]](_.asInstanceOf[Lit[A with X]])
  }
object F2 extends Poly1{
    implicit def call[A, Func0 <: String, Params0 <: HList](
      implicit copy: Copy[Call.Aux[A, Func0, Params0], Witness.`'params`.Field[Lit[Float] :: Lit[Boolean] :: HNil] :: HNil]
    ): Case.Aux[Call.Aux[A, Func0, Params0], copy.Out] =
      at[Call.Aux[A, Func0, Params0]](copy(_, 'params ->> (Lit(1.2f) :: Lit(true) :: HNil) :: HNil))
  }

Transform(Transform(call, F2), F1)

A single polymorphic function, defining all the transformations, doesn't work because of diverging implicit expansion

object F3 extends Poly1 {
    implicit def call[A, Func0 <: String, Params0 <: HList](
      implicit copy: Copy[Call.Aux[A, Func0, Params0], Witness.`'params`.Field[Lit[Float] :: Lit[Boolean] :: HNil] :: HNil]
    ): Case.Aux[Call.Aux[A, Func0, Params0], copy.Out] =
      at[Call.Aux[A, Func0, Params0]](copy(_, 'params ->> (Lit(1.2f) :: Lit(true) :: HNil) :: HNil))
    implicit def lit[A]: Case.Aux[Lit[A], Lit[A with X]] = at[Lit[A]](_.asInstanceOf[Lit[A with X]])
  }

Transform(call, F3)
// diverging implicit expansion for type Transform[Call.Aux[String,String("foo"),shapeless.::[Lit[String],shapeless.::[Lit[String],shapeless.HNil]]],TestTransform.F3_2.type]
// starting with method noStringChildren in object TestTransform

Refactor `syntax.Match` macro

  • transform only outer CaseDef; right now the underlying CaseDefs are also modified
  • most of the Expr are no longer needed

Replace manifests by type/class tags

In Scala 2.10, scala.reflect.ClassManifest are deprecated, and it is planned to deprecate scala.reflect.Manifest in favor of TypeTags and ClassTags in an upcoming point release. Thus, it is advisable to migrate any Manifest-based APIs to use Tags.

scala-lang

Extensive typing of CypherFragments

CypherFragments should include full type information about their sub-fragments.

This information is to be used for static query analysis and manipulation.

Merge queries dynamically (#31) [temp]

Given two queries

q1 = MATCH $pattern1 RETURN $result1
q2 = MATCH $pattern2 RETURN $result2

The merged query should be

q1q2 = MATCH $pattern1, $pattern2 RETURN $result1, $result2 

Neo4j statements: separate templates and parameter values

The template is a string containing placeholders that are substituted with parameter values at runtime. While it is possible to run non-parameterized Cypher, good programming practice is to use parameters in Cypher statements. This allows for caching of statements within the Cypher engine, which is beneficial for performance.
(Neo4J developer manual)

Match syntax: Vertex/Edge 'extractors'

Vertex and Edge extractors now require outer parentheses in the pattern. It should not.

Now Should be
case (v@Vertex(...)) <(edge)- ... case v@Vertex(...) <(edge)- ...

Introduce an intermediate level: abstract graph

Functors should map high-level expressions to an intermediate level, not to cypher fragments directly.

This layer should describe the paths (arrows) within an abstract graph.
Those paths should then be mapped to cypher expressions.

This layer will also serve as a base for introducing gremlin-like syntax in the future.

  • Initial vertex selection
  • 'Move to' relation from node
    • Outgoing
    • Incoming
  • 'Move to' node from relation
    • Source
    • Target
  • Select property

Transformations do not work with hlists (in-depth) (#30)

Error:(296, 23) diverging implicit expansion for type com.abraxas.slothql.util.Transform[com.abraxas.slothql.Call.Aux[Int,String("parseInt"),shapeless.::[com.abraxas.slothql.Call.Aux[String,String("foo"),shapeless.::[com.abraxas.slothql.Lit[String],shapeless.::[com.abraxas.slothql.Lit[String],shapeless.HNil]]],shapeless.HNil]],com.abraxas.slothql.TestTransform.F2.type]
starting with method transformHCons in object Transform

Represent expressions as arrows

TBD: I'm not really confident with Category Theory, so I'll fill the description after a couple of discussions.

  • Arrows
    • Definition
    • Composition
      • syntax compose
      • syntax andThen
    • Unchaining - recursive decomposition
    • Pipes - arrows of tuples
      • Splitting - A ~> (B, C, D, E)
      • processing a single tuple element (A, B, C, D) ~> (A, E, C, D), similar to first/second
      • Joining - (A, B, C) ~> D
  • Functor - map arrows
    • generic functor for composition arrow
    • generic functor for split arrow

Selectors

Selector is an optic that preserves selection path at type-level.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.