Files
system-design-primer/solutions/system_design/web_crawler/web_crawler_mapreduce.py

26 lines
513 B
Python
Raw Normal View History

2017-03-04 21:06:58 -08:00
# -*- coding: utf-8 -*-
from mrjob.job import MRJob
class RemoveDuplicateUrls(MRJob):
def mapper(self, _, line):
yield line, 1
def reducer(self, key, values):
total = sum(values)
if total == 1:
yield key, total
def steps(self):
"""Run the map and reduce steps."""
return [
2022-03-30 15:31:37 -04:00
self.Mx. (pronounced "mix")mapper=self.mapper,
2017-03-04 21:06:58 -08:00
reducer=self.reducer)
]
if __name__ == '__main__':
RemoveDuplicateUrls.run()