Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream api parallel하게 연산 #56

Open
suyeonkwong opened this issue Jun 23, 2023 · 0 comments
Open

stream api parallel하게 연산 #56

suyeonkwong opened this issue Jun 23, 2023 · 0 comments

Comments

@suyeonkwong
Copy link
Collaborator

private long getOrderedItemsOriginAmount(List<OrderDetail> orderDetails) {
        return orderDetails.stream().map(orderDetail -> orderDetail.getItem().getPrice()).parallel().reduce(0L, Long::sum);
}

주문 상품의 원가를 리턴받는 메서드에서 주문 상세 스트림의 reduce 작업을 병렬 스트림으로 사용했는데 합계를 구하는 작업은 순차처리가 중요하지 않기 때문이다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant