Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
system-design-primer
Commits
fb662421
Commit
fb662421
authored
Apr 25, 2018
by
cclauss
Committed by
Donne Martin
Apr 25, 2018
Browse files
Fix coding errors (#149)
parent
bb49172d
Changes
3
Hide whitespace changes
Inline
Side-by-side
solutions/system_design/mint/mint_mapreduce.py
View file @
fb662421
...
@@ -35,7 +35,7 @@ class SpendingByCategory(MRJob):
...
@@ -35,7 +35,7 @@ class SpendingByCategory(MRJob):
if
period
==
self
.
current_year_month
():
if
period
==
self
.
current_year_month
():
yield
(
period
,
category
),
amount
yield
(
period
,
category
),
amount
def
reducer
(
self
,
key
,
value
):
def
reducer
(
self
,
key
,
value
s
):
"""Sum values for each key.
"""Sum values for each key.
(2016-01, shopping), 125
(2016-01, shopping), 125
...
...
solutions/system_design/pastebin/pastebin.py
View file @
fb662421
...
@@ -26,7 +26,7 @@ class HitCounts(MRJob):
...
@@ -26,7 +26,7 @@ class HitCounts(MRJob):
period
=
self
.
extract_year_month
(
line
)
period
=
self
.
extract_year_month
(
line
)
yield
(
period
,
url
),
1
yield
(
period
,
url
),
1
def
reducer
(
self
,
key
,
value
):
def
reducer
(
self
,
key
,
value
s
):
"""Sum values for each key.
"""Sum values for each key.
(2016-01, url0), 2
(2016-01, url0), 2
...
...
solutions/system_design/sales_rank/sales_rank_mapreduce.py
View file @
fb662421
...
@@ -9,7 +9,7 @@ class SalesRanker(MRJob):
...
@@ -9,7 +9,7 @@ class SalesRanker(MRJob):
"""Return True if timestamp is within past week, False otherwise."""
"""Return True if timestamp is within past week, False otherwise."""
...
...
def
mapper
(
self
,
_
line
):
def
mapper
(
self
,
_
,
line
):
"""Parse each log line, extract and transform relevant lines.
"""Parse each log line, extract and transform relevant lines.
Emit key value pairs of the form:
Emit key value pairs of the form:
...
@@ -25,7 +25,7 @@ class SalesRanker(MRJob):
...
@@ -25,7 +25,7 @@ class SalesRanker(MRJob):
if
self
.
within_past_week
(
timestamp
):
if
self
.
within_past_week
(
timestamp
):
yield
(
category
,
product_id
),
quantity
yield
(
category
,
product_id
),
quantity
def
reducer
(
self
,
key
,
value
):
def
reducer
(
self
,
key
,
value
s
):
"""Sum values for each key.
"""Sum values for each key.
(foo, p1), 2
(foo, p1), 2
...
@@ -74,4 +74,4 @@ class SalesRanker(MRJob):
...
@@ -74,4 +74,4 @@ class SalesRanker(MRJob):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
HitCounts
.
run
()
SalesRanker
.
run
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment