gpt4 book ai didi

scala - 如何调试 Scala Future?

转载 作者:行者123 更新时间:2023-12-04 16:14:33 25 4
gpt4 key购买 nike

如何在 Scala 中调试代码 Future ?

我正在使用 IntelliJ。

除了记录一切,我不知道如何。

有关如何进行的任何建议?

编辑1:

这是我得到的错误:

java.lang.IllegalAccessError: tried to access field org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.concepts$1 from class org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$GeneratedEvaluatorClass$3$1 at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$GeneratedEvaluatorClass$3$1.invoke(FileToCompile0.scala:173) at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(RelevantConceptsRecommendationService.scala:169) at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(RelevantConceptsRecommendationService.scala:166) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) java.lang.NoSuchFieldError: doc$1 at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$GeneratedEvaluatorClass$4$1.invoke(FileToCompile1.scala:173) at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(RelevantConceptsRecommendationService.scala:169) at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(RelevantConceptsRecommendationService.scala:166) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)



我的代码:
def filterResultsWithExtractionSettings(conceptResults: ConceptResults): ConceptResults = {

import system.dispatcher

val mylist: Iterable[Future[List[Concept]]] = for (fieldSettings <- fieldSettingsList if fieldSettings.maxConceptsExtraction > 0; doc <- conceptResults.document; concepts <- doc.concepts) yield {

Future {
val schemefiltered = concepts.withFilter(e => e.conceptSchemes.contains(fieldSettings.scheme)).flatMap(e=> List(e))

schemefiltered.size match {
case e if e > fieldSettings.maxConceptsExtraction => schemefiltered.take(fieldSettings.maxConceptsExtraction)
case _ => schemefiltered
}
}

}

val res = Await.result(Future.sequence(mylist), Duration.Inf).flatten.toList

val distinctRes = res.distinct

conceptResults.copy(document = Some(conceptResults.document.get.copy(concepts = Some(distinctRes))))

}

最佳答案

由于您使用的是 IntelliJ,您可以在 Future 中添加断点。您可以通过单击希望断点所在的文本行左侧的装订线来实现。

https://www.jetbrains.com/idea/help/creating-breakpoints.html

关于scala - 如何调试 Scala Future?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31525965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com