On Aug 24, 2010, at 10:31 AM, Glenn Little wrote:
There seem to be conflicting opinions about whether or not it's good
practice to mutate the hash that I am iterating over.
Well, to give you a stronger data point that it is just fine, one of
my main applications is data aggregation. Part of that process is data
transformation.
Step 1, import CSV
Step 2, reorganize into the data structures I want (arrays of hashes
with new keys)
Step 3, transform about half the fields (some of them quite complex)
Step 4, create index hashes of several columns
Step 5, using the indexes, match and aggregate data into yet another
set of structures
That's done on millions of records, tens of millions of data cells --
takes 7 cores about 2 hours to do it all -- in fact there's so much
data we have to use random access disk space because we can exceed 4
GB per core in processing (avg is probably 2GB). This has run
automatically every night for 2 years.
My point? All hashes are transformed in place.
There's no need to create new hashes.
-- gw
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby