我遇到了奇怪的问题scala mongo driver
。当我执行以下部分时:
val doc:org.mongodb.scala.Document = org.mongodb.scala.Document(
"junctionId" -> junctionId,
"efficiencyArray" -> efficiencyMap.map(p=> org.mongodb.scala.Document(
"minute" -> p._1,
"efficiency" -> p._2,
"debugStuff" -> net.liftweb.json.Serialization.write(p._3)
)),
"totalCarCount" -> totalCarCount
)
它给了我以下错误:
Error:(182, 22) type mismatch;
found : (String, Float)
required: org.mongodb.scala.bson.BsonMagnets.CanBeBsonElement
"efficiency" -> p._2,
但是当我执行以下操作时:
val doc:org.mongodb.scala.Document = org.mongodb.scala.Document(
"junctionId" -> junctionId,
"efficiencyArray" -> efficiencyMap.map(p=> org.mongodb.scala.Document(
"minute" -> p._1,
"efficiency" -> 2.555,
"debugStuff" -> net.liftweb.json.Serialization.write(p._3)
)),
"totalCarCount" -> totalCarCount
)
有用。不过我p._2
的是Float
。
那么这里的问题是什么?
Scala version: 2.11.8
mongo-scala-driver version: 2.1.0
更新:
我将p._2
类型从Float
to更改Double
为有效。仍然很奇怪。