Skip to content

Commit

Permalink
optimize reading records
Browse files Browse the repository at this point in the history
  • Loading branch information
dionhaefner committed May 14, 2020
1 parent 223bf34 commit 0abda56
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions fowd/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,13 @@ def read_pickled_record_chunks(input_file):

def read_pickle_outfile(input_file):
reader = read_pickled_record_chunks(input_file)
try:
out = next(reader)
except StopIteration:
return {}

records = collections.defaultdict(list)
for row in reader:
assert set(out.keys()) == set(row.keys())
for key, val in row.items():
out[key] = np.concatenate((out[key], val))
records[key].append(val)

out = {key: np.concatenate(val) for key, val in records.items()}
return out


Expand Down

0 comments on commit 0abda56

Please sign in to comment.