Skip to content

Commit

Permalink
v0.18.4 Aggregates for card-many attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcgrue committed May 13, 2019
1 parent fdcec2e commit 46393b7
Show file tree
Hide file tree
Showing 15 changed files with 640 additions and 126 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ lazy val yourProject = project.in(file("app"))
Resolver.sonatypeRepo("releases")
),
libraryDependencies ++= Seq(
"org.scalamolecule" %% "molecule" % "0.18.3",
"org.scalamolecule" %% "molecule" % "0.18.4",
"com.datomic" % "datomic-free" % "0.9.5697"
),
moleculeSchemas := Seq("app") // paths to your schema definition files...
)
```
Molecule 0.18.3 for Scala 2.12.8 is available at
Molecule 0.18.4 for Scala 2.12.8 is available at
[Sonatype](https://oss.sonatype.org/content/repositories/releases/org/scalamolecule/molecule_2.12/).


Expand Down
9 changes: 4 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sbt.compilerPlugin
lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq(
organization := "org.scalamolecule",
version := "0.18.3",
version := "0.18.4",
scalaVersion := "2.12.8",
scalacOptions := Seq(
"-feature",
Expand All @@ -18,8 +18,7 @@ lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq(
// ,"-Ydebug"
),
resolvers ++= Seq(
"datomic" at "http://files.datomic.com/maven", // free
// "datomic" at "https://my.datomic.com/repo", // pro
"datomic" at "http://files.datomic.com/maven",
"clojars" at "http://clojars.org/repo",
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots"),
Expand All @@ -29,8 +28,6 @@ lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"com.datomic" % "datomic-free" % "0.9.5697",
// "com.datomic" % "datomic-pro" % "0.9.5783",
// "com.datomic" % "client-pro" % "0.8.20",
"org.specs2" %% "specs2-core" % "4.2.0" % "test",
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch)
),
Expand Down Expand Up @@ -105,6 +102,7 @@ lazy val publishSettings = Seq(
licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
scmInfo := Some(ScmInfo(url("https://github.com/scalamolecule/molecule"), "scm:git:[email protected]:scalamolecule/molecule.git")),
credentials += Credentials(Path.userHome / ".sbt" / ".credentials"),
credentials += Credentials(Path.userHome / ".sbt" / "1.0" / "sonatype.sbt"),
pomExtra :=
<developers>
<developer>
Expand All @@ -116,6 +114,7 @@ lazy val publishSettings = Seq(
)

lazy val noPublishSettings = Seq(
skip in publish := true,
publish := ((): Unit),
publishLocal := ((): Unit),
publishArtifact in(Compile, packageDoc) := false,
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/scala/molecule/api/get/GetList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ trait GetList[Tpl] extends GetArray[Tpl] { self: Molecule[Tpl] =>
buf.toList
}

def getListOf[T](implicit conn: Conn): List[T] = ???

/** Get `List` of n rows as tuples matching molecule.

/** Get `List` of n rows as tuples matching molecule.
* <br><br>
* Only n rows are type-casted.
* {{{
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/molecule/ast/query.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package molecule.ast
import java.net.URI
import java.util.{Date, UUID}
import molecule.transform.Query2String
import molecule.util.Helpers

Expand Down
8 changes: 0 additions & 8 deletions core/src/main/scala/molecule/factory/Molecule_Factory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ trait Molecule_Factory2 {
*
* @group molecule
* @param dsl User-defined DSL structure modelling the molecule
* @tparam Ns1 Internal builder pattern type
* @tparam Ns2 Internal builder pattern type
* @tparam In1_1 Internal builder pattern type
* @tparam In1_2 Internal builder pattern type
* @tparam A Type of output attribute 1 (`name`: String)
* @return Molecule of arity-1 typed to first attribute (Molecule01[A])
*/
Expand All @@ -79,10 +75,6 @@ trait Molecule_Factory2 {
*
* @group molecule
* @param dsl User-defined DSL structure modelling the molecule
* @tparam Ns2 Internal builder pattern type
* @tparam Ns3 Internal builder pattern type
* @tparam In1_2 Internal builder pattern type
* @tparam In1_3 Internal builder pattern type
* @tparam A Type of output attribute 1 (`name`: String)
* @tparam B Type of output attribute 2 (`age`: Int)
* @return Molecule of arity-2 typed to two attributes (Molecule02[A, B])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ trait Molecule_In_1_Factory2 {
*
* @group input1
* @param dsl User-defined DSL structure modelling the input molecule
* @tparam In1_1 Internal builder pattern type
* @tparam In1_2 Internal builder pattern type
* @tparam In2_1 Internal builder pattern type
* @tparam In2_2 Internal builder pattern type
* @tparam I1 Type of input attribute 1 (`age`: Int)
* @tparam A Type of output attribute 1 (`name`: String)
* @return Input molecule ready to be resolved
Expand All @@ -86,10 +82,6 @@ trait Molecule_In_1_Factory2 {
* }}}
* @group input1
* @param dsl User-defined DSL structure modelling the input molecule
* @tparam In1_2 Internal builder pattern type
* @tparam In1_3 Internal builder pattern type
* @tparam In2_2 Internal builder pattern type
* @tparam In2_3 Internal builder pattern type
* @tparam I1 Type of input attribute 1 (`age`: Int)
* @tparam A Type of output attribute 1 (`name`: String)
* @tparam B Type of output attribute 2 (`score`: Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ trait Molecule_In_2_Factory2 {
*
* @group input2
* @param dsl User-defined DSL structure modelling the input molecule
* @tparam In2_1 Internal builder pattern type
* @tparam In2_2 Internal builder pattern type
* @tparam In3_1 Internal builder pattern type
* @tparam In3_2 Internal builder pattern type
* @tparam I1 Type of input attribute 1 (`age`: Int)
* @tparam I2 Type of input attribute 2 (`score`: Int)
* @tparam A Type of output attribute 1 (`name`: String)
Expand Down Expand Up @@ -89,10 +85,6 @@ trait Molecule_In_2_Factory2 {
* }}}
* @group input2
* @param dsl User-defined DSL structure modelling the input molecule
* @tparam In2_2 Internal builder pattern type
* @tparam In2_3 Internal builder pattern type
* @tparam In3_2 Internal builder pattern type
* @tparam In3_3 Internal builder pattern type
* @tparam I1 Type of input attribute 1 (`age`: Int)
* @tparam I2 Type of input attribute 2 (`score`: Int)
* @tparam A Type of output attribute 1 (`name`: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ trait Molecule_In_3_Factory2 {
*
* @group input3
* @param dsl User-defined DSL structure modelling the input molecule
* @tparam In3_1 Internal builder pattern type
* @tparam In3_2 Internal builder pattern type
* @tparam In4_1 Internal builder pattern type
* @tparam In4_2 Internal builder pattern type
* @tparam I1 Type of input attribute 1 (`age`: Int)
* @tparam I2 Type of input attribute 2 (`score`: Int)
* @tparam I3 Type of input attribute 3 (`flags`: Int)
Expand Down Expand Up @@ -90,10 +86,6 @@ trait Molecule_In_3_Factory2 {
* }}}
* @group input3
* @param dsl User-defined DSL structure modelling the input molecule
* @tparam In3_2 Internal builder pattern type
* @tparam In3_3 Internal builder pattern type
* @tparam In4_2 Internal builder pattern type
* @tparam In4_3 Internal builder pattern type
* @tparam I1 Type of input attribute 1 (`age`: Int)
* @tparam I2 Type of input attribute 2 (`score`: Int)
* @tparam I3 Type of input attribute 3 (`flags`: Int)
Expand Down
68 changes: 55 additions & 13 deletions core/src/main/scala/molecule/macros/Cast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ private[molecule] trait Cast extends TreeOps {
case "java.net.URI" => (i: Int) => q"castAggrListVector[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrListVector[java.util.UUID](row, $i)"
}
def castAggrListVectorMany(tpe: String): Int => Tree = tpe match {
case "Int" => (i: Int) => q"castAggrListVectorManyInt(row, $i)"
case "Long" => (i: Int) => q"castAggrListVectorMany[Long](row, $i)"
case "Float" => (i: Int) => q"castAggrListVectorManyFloat(row, $i)"
case "Double" => (i: Int) => q"castAggrListVectorMany[Double](row, $i)"
case "String" => (i: Int) => q"castAggrListVectorMany[String](row, $i)"
case "BigInt" => (i: Int) => q"castAggrListVectorManyBigInt(row, $i)"
case "BigDecimal" => (i: Int) => q"castAggrListVectorManyBigDecimal(row, $i)"
case "java.util.Date" => (i: Int) => q"castAggrListVectorMany[java.util.Date](row, $i)"
case "Boolean" => (i: Int) => q"castAggrListVectorMany[Boolean](row, $i)"
case "java.net.URI" => (i: Int) => q"castAggrListVectorMany[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrListVectorMany[java.util.UUID](row, $i)"
}

def castAggrListHashSet(tpe: String): Int => Tree = tpe match {
case "Int" => (i: Int) => q"castAggrListHashSetInt(row, $i)"
case "Long" => (i: Int) => q"castAggrListHashSet[Long](row, $i)"
Expand All @@ -72,6 +86,20 @@ private[molecule] trait Cast extends TreeOps {
case "java.net.URI" => (i: Int) => q"castAggrListHashSet[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrListHashSet[java.util.UUID](row, $i)"
}
def castAggrListHashSetMany(tpe: String): Int => Tree = tpe match {
case "Int" => (i: Int) => q"castAggrListHashSetManyInt(row, $i)"
case "Long" => (i: Int) => q"castAggrListHashSetMany[Long](row, $i)"
case "Float" => (i: Int) => q"castAggrListHashSetManyFloat(row, $i)"
case "Double" => (i: Int) => q"castAggrListHashSetMany[Double](row, $i)"
case "String" => (i: Int) => q"castAggrListHashSetMany[String](row, $i)"
case "BigInt" => (i: Int) => q"castAggrListHashSetManyBigInt(row, $i)"
case "BigDecimal" => (i: Int) => q"castAggrListHashSetManyBigDecimal(row, $i)"
case "java.util.Date" => (i: Int) => q"castAggrListHashSetMany[java.util.Date](row, $i)"
case "Boolean" => (i: Int) => q"castAggrListHashSetMany[Boolean](row, $i)"
case "java.net.URI" => (i: Int) => q"castAggrListHashSetMany[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrListHashSetMany[java.util.UUID](row, $i)"
}

def castAggrListLazySeq(tpe: String): Int => Tree = tpe match {
case "Int" => (i: Int) => q"castAggrListLazySeqInt(row, $i)"
case "Long" => (i: Int) => q"castAggrListLazySeq[Long](row, $i)"
Expand All @@ -85,6 +113,19 @@ private[molecule] trait Cast extends TreeOps {
case "java.net.URI" => (i: Int) => q"castAggrListLazySeq[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrListLazySeq[java.util.UUID](row, $i)"
}
def castAggrListLazySeqMany(tpe: String): Int => Tree = tpe match {
case "Int" => (i: Int) => q"castAggrListLazySeqManyInt(row, $i)"
case "Long" => (i: Int) => q"castAggrListLazySeqMany[Long](row, $i)"
case "Float" => (i: Int) => q"castAggrListLazySeqManyFloat(row, $i)"
case "Double" => (i: Int) => q"castAggrListLazySeqMany[Double](row, $i)"
case "String" => (i: Int) => q"castAggrListLazySeqMany[String](row, $i)"
case "BigInt" => (i: Int) => q"castAggrListLazySeqManyBigInt(row, $i)"
case "BigDecimal" => (i: Int) => q"castAggrListLazySeqManyBigDecimal(row, $i)"
case "java.util.Date" => (i: Int) => q"castAggrListLazySeqMany[java.util.Date](row, $i)"
case "Boolean" => (i: Int) => q"castAggrListLazySeqMany[Boolean](row, $i)"
case "java.net.URI" => (i: Int) => q"castAggrListLazySeqMany[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrListLazySeqMany[java.util.UUID](row, $i)"
}

def castAggrInt: Int => Tree = (i: Int) => q"row.get($i).asInstanceOf[Int]"
def castAggrDouble: Int => Tree = (i: Int) => q"row.get($i).asInstanceOf[Double]"
Expand All @@ -102,6 +143,19 @@ private[molecule] trait Cast extends TreeOps {
case "java.net.URI" => (i: Int) => q"castOne[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castOne[java.util.UUID](row, $i)"
}
def castAggrMany(tpe: String): Int => Tree = tpe match {
case "Int" => (i: Int) => q"castAggrManyInt(row, $i)"
case "Long" => (i: Int) => q"castAggrMany[Long](row, $i)"
case "Float" => (i: Int) => q"castAggrManyFloat(row, $i)"
case "Double" => (i: Int) => q"castAggrMany[Double](row, $i)"
case "String" => (i: Int) => q"castAggrMany[String](row, $i)"
case "BigInt" => (i: Int) => q"castAggrManyBigInt(row, $i)"
case "BigDecimal" => (i: Int) => q"castAggrManyBigDecimal(row, $i)"
case "java.util.Date" => (i: Int) => q"castAggrMany[java.util.Date](row, $i)"
case "Boolean" => (i: Int) => q"castAggrMany[Boolean](row, $i)"
case "java.net.URI" => (i: Int) => q"castAggrMany[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrMany[java.util.UUID](row, $i)"
}

def castAggrVector(tpe: String): Int => Tree = tpe match {
case "Int" => (i: Int) => q"castAggrVectorInt(row, $i)"
Expand All @@ -116,19 +170,7 @@ private[molecule] trait Cast extends TreeOps {
case "java.net.URI" => (i: Int) => q"castAggrVector[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrVector[java.util.UUID](row, $i)"
}
def castAggrLazySeq(tpe: String): Int => Tree = tpe match {
case "Int" => (i: Int) => q"castAggrLazySeqInt(row, $i)"
case "Long" => (i: Int) => q"castAggrLazySeq[Long](row, $i)"
case "Float" => (i: Int) => q"castAggrLazySeqFloat(row, $i)"
case "Double" => (i: Int) => q"castAggrLazySeq[Double](row, $i)"
case "String" => (i: Int) => q"castAggrLazySeq[String](row, $i)"
case "BigInt" => (i: Int) => q"castAggrLazySeqBigInt(row, $i)"
case "BigDecimal" => (i: Int) => q"castAggrLazySeqBigDecimal(row, $i)"
case "java.util.Date" => (i: Int) => q"castAggrLazySeq[java.util.Date](row, $i)"
case "Boolean" => (i: Int) => q"castAggrLazySeq[Boolean](row, $i)"
case "java.net.URI" => (i: Int) => q"castAggrLazySeq[java.net.URI](row, $i)"
case "java.util.UUID" => (i: Int) => q"castAggrLazySeq[java.util.UUID](row, $i)"
}


val castOptionalAttr: richTree => Int => Tree = (t: richTree) =>
if (t.card == 1) {
Expand Down
Loading

0 comments on commit 46393b7

Please sign in to comment.