I have a MapReduce program that returns the results of the computation as a dict that looks like the following:
{'pods': (54802L, 25417L, 59877L), 'sash': (160573L, 97199L, 178836L), ...}
I am trying to pull the items in this dictionary to make use of the values in the 3-tuples, but I keep receiving an error KeyError: 0
when trying to parse through the errors in the code shown below (specifically on this line key, indicies = results[i]
)
bloomFilter = [False] * 200000
for i in range(0, len(results)):
key, indicies = results[i]
bloomFilter[indicies[1]] = True
bloomFilter[indicies[2]] = True
bloomFilter[indicies[3]] = True
What is the proper way to pull the information from the dict so that I can make use of the values in the 3-tuples?
Also, can I use L
values as indicies in a array, or do I need to cast them to ints?
I would iterate over the results
dictionary like so:
for key in results:
indices = results[key]
bloomFilter[indices[0]] = True
bloomFilter[indices[1]] = True
bloomFilter[indices[2]] = True
Note also that the indices
tuple is zero-indexed, meaning you'll need to extract the values starting with zero (not one) like the above code shows.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.