Skip to content

Commit 10303ff

Browse files
author
hkalodner
authored
Merge pull request #16 from abirke/fix-mapreduce
Fix MapReduce
2 parents ddff811 + 1c80619 commit 10303ff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Notebooks/blocksci/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def mapreduce_block_ranges(chain, mapFunc, reduceFunc, init, start=None, end=No
3232
end = blocks[-1].height
3333

3434
if cpu_count == 1:
35-
return reduce(reduceFunc, (mapFunc(block) for block in chain[start:end]))
35+
return mapFunc(chain[start:end])
3636

3737
segments = chain.segment(start, end, cpu_count)
3838
with Pool(cpu_count - 1) as p:
@@ -48,14 +48,14 @@ def mapreduce_blocks(chain, mapFunc, reduceFunc, init, start=None, end=None, cpu
4848
"""
4949
def mapRangeFunc(blocks):
5050
return reduce(reduceFunc, (mapFunc(block) for block in blocks), init)
51-
return mapreduce_block_ranges(chain, mapRangeFunc, start, end, reduceFunc, init, cpu_count)
51+
return mapreduce_block_ranges(chain, mapRangeFunc, reduceFunc, init, start, end, cpu_count)
5252

5353
def mapreduce_txes(chain, mapFunc, reduceFunc, init, start=None, end=None, cpu_count=psutil.cpu_count()):
5454
"""Initialized multithreaded map reduce function over a stream of transactions
5555
"""
5656
def mapRangeFunc(blocks):
5757
return reduce(reduceFunc, (mapFunc(tx) for block in blocks for tx in block))
58-
return mapreduce_block_ranges(chain, mapRangeFunc, start, end, reduceFunc, init, cpu_count)
58+
return mapreduce_block_ranges(chain, mapRangeFunc, reduceFunc, init, start, end, cpu_count)
5959

6060

6161
def map_blocks(self, blockFunc, start = None, end = None, cpu_count=psutil.cpu_count()):

0 commit comments

Comments
 (0)