Map Reduce Programming의 감속기에서 셔플 링 및 정렬 단계의 목적은 무엇입니까?
Map Reduce 프로그래밍에서 감소 단계에는 하위 부분으로 셔플 링, 정렬 및 감소가 있습니다. 정렬은 비용이 많이 드는 일입니다.
Map Reduce Programming의 감속기에서 셔플 링 및 정렬 단계의 목적은 무엇입니까?
먼저 shuffling
매퍼에서 리듀서로 데이터를 전송하는 과정이므로 리듀서에 필요한 것이 분명하다고 생각합니다. 그렇지 않으면 입력 (또는 모든 매퍼의 입력)을 가질 수 없기 때문입니다. . 시간을 절약하기 위해지도 단계가 완료되기 전에 셔플 링을 시작할 수 있습니다. 그렇기 때문에지도 상태가 아직 100 %가 아닌 경우 감소 상태가 0 %보다 크지 만 (33 % 미만) 볼 수 있습니다.
Sorting
감속기의 시간을 절약하여 새로운 감속 작업이 시작되어야하는시기를 쉽게 구별 할 수 있습니다. 정렬 된 입력 데이터의 다음 키가 이전 키와 다를 때 간단히 새 축소 작업을 시작합니다. 각각의 축소 작업은 키-값 쌍의 목록을 가져 오지만 키-목록 (값) 입력을받는 reduce () 메서드를 호출해야하므로 키별로 값을 그룹화해야합니다. 입력 데이터가 맵 단계에서 (로컬로) 미리 정렬되고 축소 단계에서 단순히 병합 정렬 된 경우 (리듀서가 많은 매퍼로부터 데이터를 가져 오기 때문에) 그렇게하기 쉽습니다.
Partitioning
답변 중 하나에서 언급 한은 다른 프로세스입니다. 지도 단계의 출력 인 (키, 값) 쌍이 전송 될 감속기를 결정합니다. 기본 파티션 도구는 키에 해싱을 사용하여 축소 작업에 배포하지만이를 재정의하고 사용자 지정 파티션 도구를 사용할 수 있습니다.
이러한 단계에 대한 훌륭한 정보 소스는이 Yahoo 자습서 입니다.
이에 대한 멋진 그래픽 표현은 다음과 같습니다 (이 그림에서는 셔플을 "복사"라고 함).
주 shuffling
와 sorting
당신이 제로 감속기를 지정하면 전혀 수행되지 않습니다 (setNumReduceTasks (0)). 그런 다음 MapReduce 작업이지도 단계에서 중지되고지도 단계에는 어떤 종류의 정렬도 포함되지 않으므로지도 단계도 더 빠릅니다.
업데이트 : 더 공식적인 것을 찾고 있기 때문에 Tom White의 책 "Hadoop : The Definitive Guide"를 읽을 수도 있습니다. 여기 에 귀하의 질문에 대한 흥미로운 부분이 있습니다.
Tom White는 2007 년 2 월부터 Apache Hadoop 커미터로 활동하고 있으며 Apache Software Foundation의 회원이므로 꽤 신뢰할 수 있고 공식적인 것 같습니다.
Mapreduce 프로그램의 주요 단계를 다시 살펴 보겠습니다.
지도 단계는 매퍼에 의해 이루어집니다. 매퍼 는 정렬되지 않은 입력 키 / 값 쌍에서 실행됩니다. 각 매퍼는 각 입력 키 / 값 쌍에 대해 0 개, 1 개 또는 여러 개의 출력 키 / 값 쌍을 내 보냅니다.
결합 단계는 결합 장치에 의해 수행된다. 결합기는 동일한 키와 키 / 값 쌍을 결합해야한다. 각 결합기는 0 번, 1 번 또는 여러 번 실행할 수 있습니다.
셔플 및 분류 단계는 프레임 워크에 의해 수행된다. 모든 매퍼의 데이터는 키별로 그룹화되고 리듀서로 분할되며 키별로 정렬됩니다. 각 감속기는 동일한 키와 관련된 모든 값을 얻습니다. 프로그래머는 정렬을위한 사용자 지정 비교 함수와 데이터 분할을위한 파티 셔 너를 제공 할 수 있습니다 .
파티션 프로그램은 감속기가 특정 키 값 쌍을 얻을 것이다 결정합니다.
감속기 얻은, 키 / [값리스트] 쌍이 정렬 키로 정렬. 값 목록에는 매퍼가 생성 한 동일한 키를 가진 모든 값이 포함됩니다. 각 감속기는 각 입력 키 / 값 쌍에 대해 0 개, 1 개 또는 여러 개의 출력 키 / 값 쌍을 방출합니다 .
이 javacodegeeks를 한 번 봐 가지고 기사 마리아 Jurcovicova로하고 mssqltips 더 나은 이해를 위해 다타에 의해 기사
아래는 safaribooksonline 기사 의 이미지입니다.
위의 답변에서 누락 된 몇 가지 점을 추가하려고 생각했습니다. 여기 에서 가져온이 다이어그램 은 실제로 무슨 일이 일어나고 있는지 명확하게 나타냅니다.
진짜 목적을 다시 말하면
Split: Improves the parallel processing by distributing the processing load across different nodes (Mappers), which would save the overall processing time.
Combine: Shrinks the output of each Mapper. It would save the time spending for moving the data from one node to another.
Sort (Shuffle & Sort): Makes it easy for the run-time to schedule (spawn/start) new reducers, where while going through the sorted item list, whenever the current key is different from the previous, it can spawn a new reducer.
Some of the data processing requirements doesn't need sort at all. Syncsort had made the sorting in Hadoop pluggable. Here is a nice blog from them on sorting. The process of moving the data from the mappers to the reducers is called shuffling, check this article for more information on the same.
I've always assumed this was necessary as the output from the mapper is the input for the reducer, so it was sorted based on the keyspace and then split into buckets for each reducer input. You want to ensure all the same values of a Key end up in the same bucket going to the reducer so they are reduced together. There is no point sending K1,V2 and K1,V4 to different reducers as they need to be together in order to be reduced.
Tried explaining it as simply as possible
Shuffling is the process by which intermediate data from mappers are transferred to 0,1 or more reducers. Each reducer receives 1 or more keys and its associated values depending on the number of reducers (for a balanced load). Further the values associated with each key are locally sorted.
There only two things that MapReduce does NATIVELY: Sort and (implemented by sort) scalable GroupBy.
Most of applications and Design Patterns over MapReduce are built over these two operations, which are provided by shuffle and sort.
This is a good reading. Hope it helps. In terms of sorting you are concerning, I think it is for the merge operation in last step of Map. When map operation is done, and need to write the result to local disk, a multi-merge will be operated on the splits generated from buffer. And for a merge operation, sorting each partition in advanced is helpful.
Well, In Mapreduce there are two important phrases called Mapper and reducer both are too important, but Reducer is mandatory. In some programs reducers are optional. Now come to your question. Shuffling and sorting are two important operations in Mapreduce. First Hadoop framework takes structured/unstructured data and separate the data into Key, Value.
Now Mapper program separate and arrange the data into keys and values to be processed. Generate Key 2 and value 2 values. This values should process and re arrange in proper order to get desired solution. Now this shuffle and sorting done in your local system (Framework take care it) and process in local system after process framework cleanup the data in local system. Ok
Here we use combiner and partition also to optimize this shuffle and sort process. After proper arrangement, those key values passes to Reducer to get desired Client's output. Finally Reducer get desired output.
K1, V1 -> K2, V2 (we will write program Mapper), -> K2, V' (here shuffle and soft the data) -> K3, V3 Generate the output. K4,V4.
이 모든 단계는 논리적 인 작업 일뿐 원본 데이터를 변경하지 않습니다.
질문 : Map Reduce Programming의 감속기에서 셔플 링 및 정렬 단계의 목적은 무엇입니까?
짧은 대답 : 원하는 출력을 얻기 위해 데이터를 처리합니다. 셔플 링은 데이터를 집계하고 감소는 예상 출력을 얻습니다.
'programing tip' 카테고리의 다른 글
64 비트 OS에서 32 비트 JVM의 최대 Java 힙 크기 (0) | 2020.08.13 |
---|---|
프록시와 데코레이터 패턴의 차이점 (0) | 2020.08.13 |
진행 중입니다. (0) | 2020.08.13 |
왜 float 값을 템플릿 매개 변수로 사용할 수 없습니까? (0) | 2020.08.13 |
잘못된 형식의 숫자 값이 있습니다. (0) | 2020.08.13 |