我正在尝试使用 couchbase 异步存储桶 n1ql 查询,如下所示:
我在下面有一个可以运行的非编译代码示例:(注意我必须使用scala:2.11.7)
https://scastie.scala-lang.org/nkWOuCORRbKbzieEK2D8yA
couchbaseBucket.async().query(N1qlQuery.simple(s"SELECT META(${couchbaseBucket.name()}).id FROM diy WHERE META(${couchbaseBucket.name()}).id LIKE MyKeysPrefix%;"))
.flatMap(_.rows()) // missing parameter type for expanded function ((x$12) => x$12.rows())
.map(result => result.asInstanceOf[AsyncN1qlQueryRow].value().toMap)
.toList
.timeout(10, TimeUnit.SECONDS)
.toBlocking
.single()
我排成一排:.flatMap(_.rows())
缺少扩展函数的参数类型 ((x$12) => x$12.rows())
我尝试将其更新为:
.flatMap(rows => rows.rows())
然后我得到:
缺少参数类型
所以我尝试更新为:
.flatMap((rows: AsyncN1qlQueryResult) => rows.rows())
然后我得到:
具有替代方法的重载方法值 flatMap:
overloaded method value flatMap with alternatives:
[error] [U, R](x$1: rx.functions.Func1[_ >: com.couchbase.client.java.query.AsyncN1qlQueryResult, _ <: rx.Observable[_ <: U]], x$2: rx.functions.Func2[_ >: com.couchbase.client.java.query.AsyncN1qlQueryResult, _ >: U, _ <: R], x$3: Int)rx.Observable[R] <and>
[error] [U, R](x$1: rx.functions.Func1[_ >: com.couchbase.client.java.query.AsyncN1qlQueryResult, _ <: rx.Observable[_ <: U]], x$2: rx.functions.Func2[_ >: com.couchbase.client.java.query.AsyncN1qlQueryResult, _ >: U, _ <: R])rx.Observable[R] <and>
[error] [R](x$1: rx.functions.Func1[_ >: com.couchbase.client.java.query.AsyncN1qlQueryResult, _ <: rx.Observable[_ <: R]], x$2: rx.functions.Func1[_ >: Throwable, _ <: rx.Observable[_ <: R]], x$3: rx.functions.Func0[_ <: rx.Observable[_ <: R]], x$4: Int)rx.Observable[R] <and>
[error] [R](x$1: rx.functions.Func1[_ >: com.couchbase.client.java.query.AsyncN1qlQueryResult, _ <: rx.Observable[_ <: R]], x$2: rx.functions.Func1[_ >: Throwable, _ <: rx.Observable[_ <: R]], x$3: rx.functions.Func0[_ <: rx.Observable[_ <: R]])rx.Observable[R] <and>
[error] [R](x$1: rx.functions.Func1[_ >: com.couchbase.client.java.query.AsyncN1qlQueryResult, _ <: rx.Observable[_ <: R]], x$2: Int)rx.Observable[R] <and>
[error] [R](x$1: rx.functions.Func1[_ >: com.couchbase.client.java.query.AsyncN1qlQueryResult, _ <: rx.Observable[_ <: R]])rx.Observable[R]
[error] cannot be applied to (com.couchbase.client.java.query.AsyncN1qlQueryResult => rx.Observable[com.couchbase.client.java.query.AsyncN1qlQueryRow])
[error] .flatMap((rows: AsyncN1qlQueryResult) => rows.rows())
[error] ^
[error] one error found
在这一点上,我被这个错误震惊了,我不知道如何修复它......我该如何修复它?