Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala错误转换类型不匹配;发现:()⇒;需要迭代器[Long]:scala.collection.immutable.Iterable[?]_Scala_Akka_Akka Http_Akka Stream - Fatal编程技术网

Scala错误转换类型不匹配;发现:()⇒;需要迭代器[Long]:scala.collection.immutable.Iterable[?]

Scala错误转换类型不匹配;发现:()⇒;需要迭代器[Long]:scala.collection.immutable.Iterable[?],scala,akka,akka-http,akka-stream,Scala,Akka,Akka Http,Akka Stream,我有一个函数 ` ` 该函数是从 ` ` 行“source”给出了一个错误 Scala错误转换类型不匹配;发现:()⇒ 需要迭代器[Long]:scala.collection.immutable.Iterable[?] 我从 根据您的版本,您可能需要Source.fromIterator Source.fromIterator(() => AkkaStreamTwitterHelper.getFollowers(userId).get.toIterator) 通过使用getFoll

我有一个函数

`

`

该函数是从

`

`

行“source”给出了一个错误

Scala错误转换类型不匹配;发现:()⇒ 需要迭代器[Long]:scala.collection.immutable.Iterable[?]

我从


根据您的版本,您可能需要
Source.fromIterator

Source.fromIterator(() =>
  AkkaStreamTwitterHelper.getFollowers(userId).get.toIterator)

通过使用
getFollowers(userId).get.toIterable.iterator
您得到了一个函数,它返回一个interator:
()=>迭代器,而不是迭代器本身。您需要应用此函数(只需将其更改为
getFollowers(userId).get.toIterable.iterator()

谢谢,这修复了错误,只是将相同的错误移到了第行。mapConcat(identity())。错误更改为“迭代器[Long]不接受参数”
Source(() =>
 AkkaStreamTwitterHelper.getFollowers(userId).get.toIterable.iterator)
  .grouped(100)
  .map(x => AkkaStreamTwitterHelper.lookupUsers(x.toList))
  .mapConcat(identity(_))
  .runForeach(x => output.offer(x.getScreenName))
  .onComplete({
    case _ =>
      Console.println(s"Fetched ${output.size()} profiles")
      val endTime = System.nanoTime()
      Console.println(s"Time taken: ${(endTime - startTime)/1000000000.00}s")
      system.terminate()
      Runtime.getRuntime.exit(0)
  }) (ec)
}
Source.fromIterator(() =>
  AkkaStreamTwitterHelper.getFollowers(userId).get.toIterator)