2016-10-17 9 views
1

map reduce를 사용하여 왼쪽 조인 기능을 구현 중입니다. 왼쪽에는 약 6 억 개의 레코드가 있고 오른쪽에는 약 2 천 3 백만 개의 레코드가 있습니다. mapper에서 왼쪽 조인 조건에 사용 된 열을 사용하고 키퍼 출력을 감속기로 전달하는 키를 만들고 있습니다. 두 테이블의 값 수가 많은 매퍼 키가 거의 없기 때문에 성능 문제가 발생합니다 (예 : 각각 456789 및 78960). 다른 감속기가 작업을 마쳤지 만이 감속기는 더 오랜 시간 동안 계속 작동합니다. 성능을 높이기 위해 다중 감속기가 병렬로 매퍼의 동일한 키 - 값 출력에서 ​​작동 할 수있는 방법이 있습니까?매퍼에서 단일 출력으로 여러 개의 축소판을 실행하십시오.

이것은 내가 최적화하고 싶은 하이브 쿼리입니다.

select distinct 
     a.sequence, 
     a.fr_nbr, 
     b.to_nbr, 
     a.fr_radius, 
     a.fr_zip, 
     a.latitude as fr_latitude, 
     a.longitude as fr_longitude, 
     a.to_zip, 
     b.latitude as to_latitude, 
     b.longitude as to_longitude, 
     ((2 * asin(sqrt(cos(radians(a.latitude)) * cos(radians(b.latitude)) * pow(sin(radians((a.longitude - b.longitude)/2)), 2) + pow(sin(radians((a.latitude - b.latitude)/2)), 2)))) * 6371 * 0.621371) as distance, 
     a.load_year, 
     a.load_month 
from common.sb_p1 a LEFT JOIN common.sb__temp0u b  
     on a.to_zip=b.zip 
      and a.load_year=b.load_year 
      and a.load_month=b.load_month 
where b.correction = 0 
     and a.fr_nbr <> b.to_nbr 
     and ((2 * asin(sqrt(cos(radians(a.latitude)) * cos(radians(b.latitude)) * pow(sin(radians((a.longitude - b.longitude)/2)), 2) + pow(sin(radians((a.latitude - b.latitude)/2)), 2)))) * 6371 * 0.621371 <= a.fr_radius) 

다른 해결책도 있습니다.

+0

에 배포되지 않습니다? 지도 측 (복제) 또는 축소 측 (재분할)? – Nicomak

+0

키를 알고 있다면 더 나은 성능을 위해 사용자 정의 파티션을 작성할 수 있습니다. Exp : If key.value <78960 .... else .... https://www.tutorialspoint.com/map_reduce/map_reduce_partitioner.htm – pckmn

+0

@Nicomak 축소 결합을 사용하고 있습니다. –

답변

0

또한 이것을 위해 HiveQL을 사용할 수도 있습니다. 꽤 많이 위에서 언급 한 것과 같은 상황에 대한 의미와지도의 복잡성을 처리 구현을 줄일 수 있습니다. UNION ALL 사용

+0

현재 HiveQL을 사용하고 있으며 48 시간에서 50 시간 정도의 시간이 소요됩니다. 그게 내가 맞춤형 Map Reduce 프로그램에서 시험해보고 싶었던 이유였다. –

1

분할 왜곡 된 키 : 병렬로 실행됩니다

select * from table1 a left join table2 b on a.key=b.key 
where a.key not in (456789,78960) 
union all 
select * from table1 a left join table2 b on a.key=b.key 
where a.key = 456789 
union all 
select * from table1 a left join table2 b on a.key=b.key 
where a.key = 78960 
; 

이 하위 쿼리, 비대칭 키를 사용하고있는 조인 어떤 종류의 단일 감속기