Comments (1)
- 파이프라인이란 여러 개의 스트림이 파이프처럼 연결되어 있는 구조이다.
- 스트림은 중간 처리와 최종 처리를 파이프라인으로 해결한다.
즉, 스트림은 중간처리와 최종 처리로 구성되어 있는 구조이다.
중간 처리
- 중간처리 메서드는 반환 값으로 스트림을 반환한다.
- 중간 처리 메서드의 예시로는 필터, 매핑 등이 있다.
최종처리
- 중간 스트림이 생성될 때 요소들이 바로 중간 처리 되는 것은 아니다.
최종 처리가 시작되기 전까지 지연되다가, 최종 처리가 시작되면 컬렉션의 요소가 하나씩 중간 스트림에서 처리되고 최종 처리까지 오게 된다.
파이프라인 형성 과정 요약
- 중간처리 메서드는 중간처리 된 스트림을 리턴한다.
- 이 스트림에서 다시 중간처리 메소드를 호출해서 파이프 라인을 형성한다.
- 최종 스트림이 시작하면 그때서야 컬렉션에서 요소가 하나씩 중간 스트림에서 처리된다.
스트림 파이프라인의 장점
중간 연산은 반환 값으로 스트림을 반환한다. 따라서 여러 중간 연산을 연결해서 질의를 만들 수 있다.
중간 연산을 합치고, 합쳐진 중간 연산을 최종 연산으로 한 번에 처리한다.
중간 연산의 중요한 특징은 단말 연산을 스트림 파이프라인에 실행하기 전까지는 아무 연산도 수행하지 않는다는 것, 즉 lazy라는 것이다.
from 2022-modern-java-in-action.
Related Issues (20)
- 컬렉션과 스트림의 차이는 뭘까? HOT 1
- 스트림은 만능일까? HOT 1
- 스트림이 게으르게 계산하면서 얻는 이점은 무엇일까? HOT 1
- 루프 퓨전이란 무엇인가? HOT 1
- 스트림 연산은 어떻게 작동할까? HOT 1
- 쇼트서킷은 어떻게 작동하는 것일까? HOT 2
- 스트림 연산에 있어 상태가 있거나 없다는 의미가 무엇인가? HOT 2
- 무한스트림과 가변, 불변 상태 HOT 1
- Optional을 사용해야 하는 적절한 경우는 언제일까? HOT 1
- 무한 스트림의 존재 의의
- reduce를 사용하는 것이 왜 반복문보다 장점을 가지는 것일까? HOT 2
- flatMap 이란? HOT 1
- null에 안전한 스트림 생성 방법 HOT 1
- Collectors.toMap 실습 HOT 2
- groupingBy와 partitioningBy 비교 HOT 1
- collect vs collector vs collectors (vs Collections vs Collection) 구분하기 HOT 2
- 내장 Collector의 Characteristics 파악하기 HOT 1
- reduce vs collect HOT 1
- collectionAndThen() 는 언제 사용하면 좋을까?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 2022-modern-java-in-action.