Cannot Run Example from ReactiveMongo - scala

I am running reactivemongo 0.18.6 and am having an issue around the bulk Update as shown in the "Update a document" section of the documentation: http://reactivemongo.org/releases/0.1x/documentation/tutorial/write-documents.html
I copied word for word the example provided and keep getting the compilation error of
type mismatch;
found : Seq[reactivemongo.api.collections.bson.BSONCollection with Singleton#UpdateCommand.UpdateElement]
required: Iterable[_1.UpdateCommand.UpdateElement] where val _1: reactivemongo.api.collections.bson.BSONCollection

Related

value YpartialUnification is not a member of scala.tools.nsc.Settings

I'm trying to run scala cats in REPL. Following cat's instructions I have installed ammonite REPL and put following imports in predef.sc
nterp.configureCompiler(_.settings.YpartialUnification.value = true)
import $ivy.`org.typelevel::cats-core:2.2.0-M1`, cats.implicits._
I got this error when run amm.
predef.sc:1: value YpartialUnification is not a member of scala.tools.nsc.Settings
val res_0 = interp.configureCompiler(_.settings.YpartialUnification.value = true)
^
Compilation Failed
In Scala 2.13 partial unification is enabled by default and -Ypartial-unification flag has been removed by Partial unification unconditional; deprecate -Xexperimental #6309
Partial unification is now enabled unless -Xsource:2.12 is specified.
The -Ypartial-unification flag has been removed and the -Xexperimental
option, which is now redundant, has been deprecated.
thus the compiler no longer accepts -Ypartial-unification.

Scala Breeze does not find my file on a webserver, while Java does

I'm new to Scala, so there's probably something obvious I'm missing.
I've got a Scalatra webserver running, with a csv-file in the same folder as the Scalatra servlet. The webserver recognizes the file just find, and the following action:
get("/dependencies") {
val variable = params.get("variable")
new java.io.File("/path/to/files/my_csv_file.csv")
}
Works as intended and returns the csv-file as a http get request.
However, I want to use the Breeze-library to do some general operations on the csv data. When I try to load the csv file to Breezes csv reader:
val matrix=csvread(new file("/path/to/files/my_csv_file.csv"), ',')
The following error is returned by the server:
[error] /path/to/files/MyScalatraServlet.scala:23: not found: type file
[error] val matrix=csvread(new file("/path/to/files/"), ',')
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 1 s, completed 18.5.2017 18:32:23
Although not obvious from the code, Breezes linalg module, containing the csv module, has been imported in the beginning of the file.
import breeze.linalg._
Does anyone have ideas on why this error is happening? How come Breeze does not find the csv file?
That is a compilation error. I think following code would work:
val matrix = csvread(new java.io.File("/path/to/files/"), ',')
or
val matrix = csvread("/path/to/files/", ',')

flink: sortPartition(0, Order.ASCENDING ) error: "not found: value Order"

I am running the following code and getting "error: not found: value Order"
I am not able to figure out a reason. What am I doing wrong?
version : Flink v 0.9.1 (hadoop 1) not using hadoop: Local execution shell: scala shell
Scala-Flink> val data_avg = data_split.map{x=> ((x._1), (x._2._2/x._2._1))}.sortPartition(1, Order.ASCENDING).setParallelism(1)
<console>:16: error: not found: value Order
val data_avg = data_split.map{x=> ((x._1), (x._2._2/x._2._1))}.sortPartition(0, Order.ASCENDING).setParallelism(1)
The problem is that the enum Order is not automatically imported by Flink's Scala shell. Therefore, you have to add the following import manually.
import org.apache.flink.api.common.operators.Order

UUID Path Bindable - Play Framework

In my build.sbt I have
routesImport += "play.api.mvc.PathBindable.bindableUUID"
And in my routes I have:
GET /groups/:id controllers.GroupController.get(id)
And in my controller I have
class GroupController { ....
def get (id: UUID)
I am getting the following error for the above route
type mismatch;
found : String
required: java.util.UUID
How can used uuid in path in routes file in Play. I am using play 2.4.2 - scala 2.11.7
String is the default type for parameters in the routes file. To change this, you need to explicitly specify a type for the Id:
GET /groups/:id controllers.GroupController.get(id: java.util.UUID)
If you do that, you should find you can also delete the import of bindableUUID in your build file.

Scala + stax compile problem during deploy process

I developed an app in scala-ide (eclipse plugin), no errors or warnings. Now I'm trying to deploy it to the stax cloud:
$ stax deploy
But it fails to compile it:
compile:
[scalac] Compiling 2 source files to /home/gleontiev/workspace/rss2lj/webapp/WEB-INF/classes
error: error while loading FlickrUtils, Scala signature FlickrUtils has wrong version
expected: 4.1
found: 5.0
/home/gleontiev/workspace/rss2lj/src/scala/example/snippet/DisplaySnippet.scala:8: error: com.folone.logic.FlickrUtils does not have a constructor
val dispatcher = new FlickrUtils("8196243#N02")
^
error: error while loading Photo, Scala signature Photo has wrong version
expected: 4.1
found: 5.0
/home/gleontiev/workspace/rss2lj/src/scala/example/snippet/DisplaySnippet.scala:9: error: value link is not a member of com.folone.logic.Photo
val linksGetter = (p:Photo) => p.link
^
/home/gleontiev/workspace/rss2lj/src/scala/example/snippet/DisplaySnippet.scala:15: error: com.folone.logic.FlickrUtils does not have a constructor
val dispatcher = new FlickrUtils("8196243#N02")
^
/home/gleontiev/workspace/rss2lj/src/scala/example/snippet/DisplaySnippet.scala:16: error: value medium1 is not a member of com.folone.logic.Photo
val picsGetter = (p:Photo) => p.medium1
^
/home/gleontiev/workspace/rss2lj/src/scala/example/snippet/RefreshSnippet.scala:12: error: com.folone.logic.FlickrUtils does not have a constructor
val dispatcher = new FlickrUtils("8196243#N02")
^
7 errors found
ERROR: : The following error occurred while executing this line:
/home/gleontiev/workspace/rss2lj/build.xml:61: Compile failed with 7 errors; see the compiler error output for details.
I see two errors, it is complaining about: the first one is FlickrUtils class constructor, which is defined like this:
class FlickrUtils(val userId : String) {
//...
}
The second one is the fact, that two fields are missing from Photo class, which is:
class Photo (val photoId:String, val userId:String, val secret:String, val server:String) {
private val _medium1 = "/sizes/m/in/photostream"
val link = "http://flickr.com/photos/" + userId + "/" + photoId
val medium1 = link + _medium1
}
Seems like stax sdk uses the wrong comliler (?). How do I make it use the right one? If it is not, what is the problem here, and what are some ways to resolve it?
Edit: $ scala -version says
Scala code runner version 2.8.0.final -- Copyright 2002-2010, LAMP/EPFL
I tried compiling everything with scalac manually, puting everything to their places, and running stax deploy afterwards -- same result.
I actually resolved this by moving FlickrUtils and Photo classes to the packages, where snippets originally are, but I still don't get, why it was not able to compile and use them from the other package.