
Новые сообщения [новые:0]
Дайджест
Горячие темы
Избранное [новые:0]
Форумы
Пользователи
Статистика
Статистика нагрузки
Мод. лог
Поиск
|
|
26.09.2015, 22:08
|
|||
|---|---|---|---|
|
|||
Как используется 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:37
|
|||
|---|---|---|---|
Как используется 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.) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
27.09.2015, 00:49
|
|||
|---|---|---|---|
|
|||
Как используется 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.) Спасибо) очень похоже на правду ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|

start [/forum/topic.php?fid=59&mobile=1&tid=2124893]: |
0ms |
get settings: |
7ms |
get forum list: |
15ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
197ms |
get topic data: |
10ms |
get forum data: |
3ms |
get page messages: |
39ms |
get tp. blocked users: |
1ms |
| others: | 196ms |
| total: | 474ms |

| 0 / 0 |
