Skip to content

Commit e7d88c3

Browse files
committed
v1.0.0 Async peer-server fixed. Implementation complete.
1 parent eed5179 commit e7d88c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+576
-754
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ You can then use the various Datomic systems depending on the Client api from Ja
1414

1515
Using the facade in a live Cloud setting has not yet been tested. But since dev-local is equivalent and works fine, Cloud should too.
1616

17-
Note that this library is an independent release not associated with Datomic/Cognitect.
1817

1918
## Java/Scala
2019

21-
Code is written in Scala but compiles to the same bytecode as Java.
20+
Most code is written in Scala but compiles to the same bytecode as Java.
2221

2322
Each language has been given its own exclusive namespace to ensure full compatibility and to accommodate for differences.
2423

@@ -161,7 +160,7 @@ Run the Java tests by right-clicking on the `test.java.datomicJava.client` packa
161160

162161
Run the Scala tests by right-clicking on the `test.scala.datomicScala.client` package in the project view (in IntelliJ) and choose Run -> Specs2 in 'client' (or run individual tests similarly).
163162

164-
Or run tests with sbt:
163+
Run tests with sbt:
165164
```
166165
sbt
167166
@@ -175,13 +174,15 @@ sbt:datomic-client-api-java-scala> testOnly datomicJava.client.api.*
175174
sbt:datomic-client-api-java-scala> testOnly datomicScala.client.api.*
176175
177176
// Tests for scala 2.12
178-
sbt:datomic-client-api-java-scala> ++2.12.13; testOnly datomicJava.client.api.*
179-
sbt:datomic-client-api-java-scala> ++2.12.13; testOnly datomicScala.client.api.*
177+
sbt:datomic-client-api-java-scala> ++2.12.14; testOnly datomicJava.client.api.*
178+
sbt:datomic-client-api-java-scala> ++2.12.14; testOnly datomicScala.client.api.*
180179
```
181180

181+
### Test caveats
182182

183-
#### Temporary limitation
184-
Due to a bug in the Peer Server async implementation, all asynchronous Peer Server tests won't pass since we can't build a Client with map data. Hopefully this will be solved soon, and then all asynchronous Peer Server tests should pass.
183+
Sometimes you'll need to re-start the peer-server to clear the cache. Then run the sbt tests twice to allow schema creation to propagate.
184+
185+
To run tests from IntelliJ, make sure that any previous sbt process of this project is not also running (kill it). Otherwise dev-local tests won't pass.
185186

186187

187188
## Use with your project
@@ -193,34 +194,34 @@ Add Java dependency in POM file:
193194
<dependency>
194195
<groupId>org.scalamolecule</groupId>
195196
<artifactId>datomic-client-api-java-scala</artifactId>
196-
<version>0.7.0</version>
197+
<version>1.0.0</version>
197198
</dependency>
198199
199200
<!-- If using dev-local -->
200201
<dependency>
201202
<groupId>com.datomic</groupId>
202203
<artifactId>dev-local</artifactId>
203-
<version>0.9.232</version>
204+
<version>0.9.235</version>
204205
</dependency>
205206
206207
<!-- If using peer-server -->
207208
<dependency>
208209
<groupId>com.datomic</groupId>
209210
<artifactId>datomic-pro</artifactId>
210-
<version>1.0.6269</version>
211+
<version>1.0.6319</version>
211212
</dependency>
212213
```
213214

214215
Add Scala dependency in sbt build file (crosscompiles to Scala 2.12 and 2.13):
215216
```
216217
libraryDependencies ++= Seq(
217-
"org.scalamolecule" %% "datomic-client-api-java-scala" % "0.7.0",
218+
"org.scalamolecule" %% "datomic-client-api-java-scala" % "1.0.0",
218219
219220
// If using dev-local
220-
"com.datomic" % "dev-local" % "0.9.232",
221+
"com.datomic" % "dev-local" % "0.9.235",
221222
222223
// If using peer-server
223-
"com.datomic" % "datomic-pro" % "1.0.6269"
224+
"com.datomic" % "datomic-pro" % "1.0.6319"
224225
)
225226
```
226227

build.sbt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import sbt.url
44

55
lazy val commonSettings = Seq(
66
name := "datomic-client-api-java-scala",
7-
version in ThisBuild := "0.7.0",
8-
crossScalaVersions := Seq("2.12.13", "2.13.5"),
9-
scalaVersion in ThisBuild := "2.13.5",
7+
ThisBuild / version := "1.0.0",
8+
crossScalaVersions := Seq("2.12.14", "2.13.6"),
9+
ThisBuild / scalaVersion := "2.13.6",
1010
organization := "org.scalamolecule",
1111
organizationName := "ScalaMolecule",
1212
organizationHomepage := Some(url("http://www.scalamolecule.org")),
@@ -22,8 +22,8 @@ lazy val commonSettings = Seq(
2222
("clojars" at "http://clojars.org/repo").withAllowInsecureProtocol(true),
2323
("ICM repository" at "http://maven.icm.edu.pl/artifactory/repo/").withAllowInsecureProtocol(true)
2424
),
25-
unmanagedSourceDirectories in Compile ++= {
26-
(unmanagedSourceDirectories in Compile).value.map { dir =>
25+
Compile / unmanagedSourceDirectories ++= {
26+
(Compile / unmanagedSourceDirectories).value.map { dir =>
2727
CrossVersion.partialVersion(scalaVersion.value) match {
2828
case Some((2, 13)) => file(dir.getPath ++ "-2.13+")
2929
case _ => file(dir.getPath ++ "-2.13-")
@@ -39,8 +39,8 @@ lazy val core = project.in(file("core"))
3939
"org.clojure" % "clojure" % "1.10.1",
4040
"org.clojure" % "tools.analyzer.jvm" % "1.1.0",
4141
"com.datomic" % "datomic-free" % "0.9.5697",
42-
"com.datomic" % "client-pro" % "0.9.66",
43-
"com.datomic" % "client-cloud" % "0.8.105",
42+
"com.datomic" % "client-pro" % "0.9.71",
43+
"com.datomic" % "client-cloud" % "0.8.113",
4444
"us.bpsm" % "edn-java" % "0.7.1",
4545
"co.fs2" %% "fs2-core" % "2.4.4",
4646
),
@@ -50,13 +50,13 @@ lazy val core = project.in(file("core"))
5050
Some("Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/")
5151
else
5252
Some("Sonatype OSS Staging" at "https://oss.sonatype.org/service/local/staging/deploy/maven2/")),
53-
publishArtifact in Test := false,
54-
scalacOptions in Compile in doc ++= Seq(
53+
Test / publishArtifact := false,
54+
Compile / doc / scalacOptions ++= Seq(
5555
"-doc-root-content", baseDirectory.value + "/src/main/scaladoc/rootdoc.txt",
5656
"-diagrams", "-groups",
5757
"-doc-version", version.value,
5858
"-doc-title", "Datomic Client api for Java/Scala",
59-
"-sourcepath", (baseDirectory in ThisBuild).value.toString,
59+
"-sourcepath", (ThisBuild / baseDirectory).value.toString,
6060
"-doc-source-url", s"https://github.com/scalamolecule/datomic-client-api-java-scala/tree/master€{FILE_PATH}.scala#L1"
6161
),
6262
pomIncludeRepository := (_ => false),
@@ -83,22 +83,22 @@ lazy val tests = project.in(file("tests"))
8383
publish / skip := true,
8484
publish := ((): Unit),
8585
publishLocal := ((): Unit),
86-
parallelExecution in Test := false,
86+
Test / parallelExecution := false,
8787
libraryDependencies ++= Seq(
8888
// To test against dev-local, please download cognitect-dev-tools from
8989
// https://cognitect.com/dev-tools and run `./install`
90-
"com.datomic" % "dev-local" % "0.9.232",
90+
"com.datomic" % "dev-local" % "0.9.235",
9191
// To test against peer-server, please download datomic-pro from
9292
// https://www.datomic.com/get-datomic.html and run `bin/maven-install`
93-
"com.datomic" % "datomic-pro" % "1.0.6269",
93+
"com.datomic" % "datomic-pro" % "1.0.6316",
9494
"org.specs2" %% "specs2-core" % "4.10.5" % Test,
9595
"com.novocode" % "junit-interface" % "0.11" % Test,
9696
"junit" % "junit" % "4.13" % Test,
9797
"org.hamcrest" % "hamcrest-junit" % "2.0.0.0" % Test
9898
),
9999
excludeDependencies += ExclusionRule("com.datomic", "datomic-free"),
100-
unmanagedSourceDirectories in Test ++= {
101-
(unmanagedSourceDirectories in Test).value.map { dir =>
100+
Test / unmanagedSourceDirectories ++= {
101+
(Test / unmanagedSourceDirectories).value.map { dir =>
102102
CrossVersion.partialVersion(scalaVersion.value) match {
103103
case Some((2, 13)) => file(dir.getPath ++ "-2.13+")
104104
case _ => file(dir.getPath ++ "-2.13-")

core/src/main/scala-2.13+/datomicJava/client/api/async/AsyncDatomic.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package datomicJava.client.api.async
22

33
import java.util.concurrent.CompletableFuture
44
import java.util.stream.Stream
5-
import java.util.{List => jList, Map => jMap}
6-
import clojure.lang.LazySeq
5+
import java.util.{List => jList, Map => jMap, Collection => jCollection}
76
import com.amazonaws.auth.AWSCredentialsProviderChain
87
import datomic.Util
98
import datomic.Util._
@@ -85,7 +84,7 @@ object AsyncDatomic extends ClojureBridge {
8584
CompletableFuture.supplyAsync { () =>
8685
Channel[Stream[_]](
8786
InvokeAsync.q(argMap),
88-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
87+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
8988
)
9089
}
9190
}
@@ -113,12 +112,12 @@ object AsyncDatomic extends ClojureBridge {
113112

114113
// Query as data structure or String + optional :offset, :limit, :timeout params
115114
// (see tests)
116-
def qseq(map: jMap[_, _])
115+
def qseq(argMap: jMap[_, _])
117116
: CompletableFuture[Channel[Stream[_]]] = {
118117
CompletableFuture.supplyAsync { () =>
119118
Channel[Stream[_]](
120-
datomicAsyncFn("qseq").invoke(map),
121-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
119+
InvokeAsync.qseq(argMap),
120+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
122121
)
123122
}
124123
}

core/src/main/scala-2.13+/datomicJava/client/api/async/AsyncDb.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ package datomicJava.client.api.async
33
import java.io.{Reader, StringReader}
44
import java.util.concurrent.CompletableFuture
55
import java.util.stream.{Stream => jStream}
6-
import java.util.{Date, List => jList, Map => jMap}
7-
import clojure.lang.LazySeq
6+
import java.util.{Date, List => jList, Map => jMap, Collection => jCollection}
87
import datomic.Util.readAll
98
import datomicClient._
109
import datomicClient.anomaly.CognitectAnomaly
@@ -262,7 +261,7 @@ case class AsyncDb(
262261
).chunk
263262
}.thenApply {
264263
case Right(indexPull) => Channel[jStream[_]](
265-
indexPull.asInstanceOf[LazySeq].stream()
264+
indexPull.asInstanceOf[jCollection[_]].stream()
266265
).chunk
267266
case Left(anomaly) => async.Left(anomaly)
268267
}

core/src/main/scala-2.13+/datomicScala/client/api/async/AsyncDatomic.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package datomicScala.client.api.async
22

33
import java.util.stream.{Stream => jStream}
4-
import java.util.{List => jList, Map => jMap}
4+
import java.util.{Collection => jCollection, List => jList, Map => jMap}
55
import cats.effect.IO
6-
import clojure.lang.LazySeq
6+
import clojure.lang.{LazySeq, PersistentVector}
77
import com.amazonaws.auth.AWSCredentialsProviderChain
88
import datomic.Util
99
import datomic.Util._
@@ -88,7 +88,10 @@ object AsyncDatomic extends ClojureBridge {
8888
: Future[LazyList[Either[CognitectAnomaly, jStream[_]]]] = Future {
8989
Channel[jStream[_]](
9090
InvokeAsync.q(argMap),
91-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
91+
Some {
92+
case v: PersistentVector => v.stream
93+
case v: LazySeq => v.stream
94+
}
9295
).lazyList
9396
}
9497

@@ -111,13 +114,13 @@ object AsyncDatomic extends ClojureBridge {
111114
}
112115

113116
// fs2 Stream implementation example
114-
// This allows the first the first chunk to be lazy
117+
// This allows the first chunk to be lazy
115118
// Usage is flexible but verbose
116119
def qStream(argMap: jMap[_, _])
117120
: fs2.Stream[IO, Either[CognitectAnomaly, jStream[_]]] = {
118121
Channel[jStream[_]](
119122
InvokeAsync.q(argMap),
120-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
123+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
121124
).myTerminatedStream
122125
}
123126

@@ -128,7 +131,7 @@ object AsyncDatomic extends ClojureBridge {
128131
: Future[LazyList[Either[CognitectAnomaly, jStream[_]]]] = Future {
129132
Channel[jStream[_]](
130133
InvokeAsync.qseq(argMap),
131-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
134+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
132135
).lazyList
133136
}
134137

core/src/main/scala-2.13+/datomicScala/client/api/async/AsyncDb.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package datomicScala.client.api.async
22

33
import java.io.{Reader, StringReader}
44
import java.util.stream.{Stream => jStream}
5-
import java.util.{Collections, Date, List => jList, Map => jMap}
5+
import java.util.{Collections, Date, List => jList, Map => jMap, Collection => jCollection}
66
import clojure.lang.LazySeq
77
import datomic.Util.readAll
88
import datomicClient._
@@ -224,7 +224,7 @@ case class AsyncDb(
224224
) {
225225
case Right(indexPull) =>
226226
Channel[jStream[_]](
227-
indexPull.asInstanceOf[LazySeq].stream()
227+
indexPull.asInstanceOf[jCollection[_]].stream()
228228
).lazyList.head
229229

230230
case Left(anomaly) => Left(anomaly)

core/src/main/scala-2.13-/datomicJava/client/api/async/AsyncDatomic.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package datomicJava.client.api.async
22

33
import java.util.concurrent.CompletableFuture
44
import java.util.stream.Stream
5-
import java.util.{List => jList, Map => jMap}
6-
import clojure.lang.LazySeq
5+
import java.util.{List => jList, Map => jMap, Collection => jCollection}
76
import com.amazonaws.auth.AWSCredentialsProviderChain
87
import datomic.Util
98
import datomic.Util._
@@ -85,7 +84,7 @@ object AsyncDatomic extends ClojureBridge {
8584
CompletableFuture.supplyAsync { () =>
8685
Channel[Stream[_]](
8786
InvokeAsync.q(argMap),
88-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
87+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
8988
)
9089
}
9190
}
@@ -120,7 +119,7 @@ object AsyncDatomic extends ClojureBridge {
120119
CompletableFuture.supplyAsync { () =>
121120
Channel[Stream[_]](
122121
datomicAsyncFn("qseq").invoke(map),
123-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
122+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
124123
)
125124
}
126125
}

core/src/main/scala-2.13-/datomicJava/client/api/async/AsyncDb.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ package datomicJava.client.api.async
33
import java.io.{Reader, StringReader}
44
import java.util.concurrent.CompletableFuture
55
import java.util.stream.{Stream => jStream}
6-
import java.util.{Date, List => jList, Map => jMap}
7-
import clojure.lang.LazySeq
6+
import java.util.{Date, List => jList, Map => jMap, Collection => jCollection}
87
import datomic.Util.readAll
98
import datomicClient._
109
import datomicClient.anomaly.CognitectAnomaly
@@ -261,7 +260,7 @@ case class AsyncDb(
261260
).chunk
262261
}.thenApply {
263262
case Right(indexPull) => Channel[jStream[_]](
264-
indexPull.asInstanceOf[LazySeq].stream()
263+
indexPull.asInstanceOf[jCollection[_]].stream()
265264
).chunk
266265
case Left(anomaly) => async.Left(anomaly)
267266
}

core/src/main/scala-2.13-/datomicScala/client/api/async/AsyncDatomic.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package datomicScala.client.api.async
22

33
import java.util.stream.{Stream => jStream}
4-
import java.util.{List => jList, Map => jMap}
4+
import java.util.{List => jList, Map => jMap, Collection => jCollection}
55
import cats.effect.IO
6-
import clojure.lang.LazySeq
76
import com.amazonaws.auth.AWSCredentialsProviderChain
87
import datomic.Util
98
import datomic.Util._
@@ -88,7 +87,7 @@ object AsyncDatomic extends ClojureBridge {
8887
: Future[Stream[Either[CognitectAnomaly, jStream[_]]]] = Future {
8988
Channel[jStream[_]](
9089
InvokeAsync.q(argMap),
91-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
90+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
9291
).lazyList
9392
}
9493

@@ -119,7 +118,7 @@ object AsyncDatomic extends ClojureBridge {
119118
: fs2.Stream[IO, Either[CognitectAnomaly, jStream[_]]] = {
120119
Channel[jStream[_]](
121120
InvokeAsync.q(argMap),
122-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
121+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
123122
).myTerminatedStream
124123
}
125124

@@ -130,7 +129,7 @@ object AsyncDatomic extends ClojureBridge {
130129
: Future[Stream[Either[CognitectAnomaly, jStream[_]]]] = Future {
131130
Channel[jStream[_]](
132131
InvokeAsync.qseq(argMap),
133-
Some((res: AnyRef) => res.asInstanceOf[LazySeq].stream)
132+
Some((res: AnyRef) => res.asInstanceOf[jCollection[_]].stream)
134133
).lazyList
135134
}
136135

core/src/main/scala-2.13-/datomicScala/client/api/async/AsyncDb.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package datomicScala.client.api.async
22

33
import java.io.{Reader, StringReader}
44
import java.util.stream.{Stream => jStream}
5-
import java.util.{Collections, Date, List => jList, Map => jMap}
6-
import clojure.lang.LazySeq
5+
import java.util.{Collections, Date, List => jList, Map => jMap, Collection => jCollection}
76
import datomic.Util.readAll
87
import datomicClient._
98
import datomicClient.anomaly.CognitectAnomaly
@@ -223,7 +222,7 @@ case class AsyncDb(
223222
) {
224223
case Right(indexPull) =>
225224
Channel[jStream[_]](
226-
indexPull.asInstanceOf[LazySeq].stream()
225+
indexPull.asInstanceOf[jCollection[_]].stream()
227226
).lazyList.head
228227

229228
case Left(anomaly) => Left(anomaly)

0 commit comments

Comments
 (0)