0

I have a function: Flux queryPerson() which queries database to generate the objects and return them in Flux. When I use .subscribe(), the app just run thru the code and exit. It doesn't wait for the results to come back for the query. But when I use .toStream() to block the stream, I can see the printouts. What am I doing wrong?

personRepository
    .queryPerson()
    .map(x -> x.getFirst().concat("ok"))
    .subscribe(i -> System.out.println(i))
    //.toStream().forEach(System.out::println)
;

Test if group means are statistically significantly different in R

*(I asked this question earlier, but it got migrated to stackexchange and was labeled 'unclear' and I couldn't edit it, so I'm going to try to clean up the question and make it more clear).

I have the following data frame and need to determine if there are statistically significant differences among the means of Test Groups, and repeat this for each Task Grouping. :

set.seed(123)

Task_Grouping <- sample(c("A","B","C"),500,replace=TRUE)
Test_Group <- sample(c("Green","Yellow","Orange"),500,replace=TRUE)
TotalTime <- rnorm(500, mean = 3, sd = 3)

mydataframe <- data.frame(Task_Grouping, Test_Group, TotalTime)

For example, for Task A, I need to see if there are significant differences in the means of the Test Groups (Green, Yellow, Orange).

I've tried the following code, but something is wrong since the p.value is the same for each Test Group combination among different Task Groupings (i.e. every p-value is 0.6190578):

results <- mydataframe %>%
  group_by(Task_Grouping) %>%
  do(tidy(pairwise.t.test(mydataframe$TotalTime, mydataframe$Test_Group,
                 p.adjust.method = "BH")))

I'm also not 100% sure if a pairwise.t.test is the correct statistical test to use. To rephrase, I need to see if the Test_Group means are statistically different from one another. And then I need to repeat this analysis for each Task Grouping.

4

1 回答 1

2

我假设您没有某种网络应用程序,而是一个命令行运行器或简单的 Java 应用程序。考虑到应用程序在异步任务之前完成是正常的。

。订阅

订阅是一种使用传入数据的异步方式,在您订阅 Flux 后,您会立即将控制权返回给调用线程。

这正是反应式编程的工作方式,你定义了行为,你有很好的抽象方式在其他线程和调用线程中运行它。

正如Flux 文档中所述

由于序列可以是异步的,这将立即将控制权返回给调用线程。这可以给人一种印象,例如在主线程或单元测试中执行时没有调用消费者。

.toStream

另一方面,使用.toStream你会收到一个 Java Stream,即使它的大小未知,你仍然像普通的 Java Stream 一样以同步方式迭代它。

更多解释可以在Flux 的 .toStream 文档中找到

于 2019-11-25T20:08:55.180 回答