|
|
|
Как используется combiner в Stream#reduce ?
|
|||
|---|---|---|---|
|
#18+
Собсно читал вот этот топик: http://stackoverflow.com/q/22808485/2674303 Один из вариантов сигнатуры метода reduce выглядит следующим образом: Код: java 1. 2. 3. По представленной выше ссылке я понял, что combiner не вызывается для не параллельных стримов. У меня вопрос немного другой. Как combiner используется когда у нас параллельный стрим и как вообще весь reduce происходит. В чем concept ? P.S. Исходники не поддаются моему пониманию. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.09.2015, 22:08 |
|
||
|
Как используется combiner в Stream#reduce ?
|
|||
|---|---|---|---|
|
#18+
questioner, Насколько я понял. Результаты в каждом потоке объединятся через accumulator, после чего результаты из разных потоков объединяются через combiner. http://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html#Reduction Here, the identity element is both an initial seed value for the reduction and a default result if there are no input elements. The accumulator function takes a partial result and the next element, and produces a new partial result. The combiner function combines two partial results to produce a new partial result. (The combiner is necessary in parallel reductions, where the input is partitioned, a partial accumulation computed for each partition, and then the partial results are combined to produce a final result.) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.09.2015, 22:37 |
|
||
|
Как используется combiner в Stream#reduce ?
|
|||
|---|---|---|---|
|
#18+
chabapokquestioner, Насколько я понял. Результаты в каждом потоке объединятся через accumulator, после чего результаты из разных потоков объединяются через combiner. http://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html#Reduction Here, the identity element is both an initial seed value for the reduction and a default result if there are no input elements. The accumulator function takes a partial result and the next element, and produces a new partial result. The combiner function combines two partial results to produce a new partial result. (The combiner is necessary in parallel reductions, where the input is partitioned, a partial accumulation computed for each partition, and then the partial results are combined to produce a final result.) Спасибо) очень похоже на правду ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.09.2015, 00:49 |
|
||
|
|

start [/forum/topic.php?fid=59&fpage=117&tid=2124893]: |
0ms |
get settings: |
5ms |
get forum list: |
8ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
25ms |
get topic data: |
6ms |
get forum data: |
1ms |
get page messages: |
22ms |
get tp. blocked users: |
2ms |
| others: | 217ms |
| total: | 290ms |

| 0 / 0 |
