c# - Dictionary<DatafeedStagingTableRow, List<UserIdsTableRow>> records; - Tell me why this is a bad idea -


so have code blindingly fast. i'm sure i'm doing terrible thing; need confirm , give me reason why.

i have process datafeed ~80,000 records, , can match of ~250,000 records either network id, hr personnel number, or combination of legal org code , local id. none of these 3 identifiers permanent – of them change, though not @ same time (small miracles). have nothing leverage primary key, , users can match more 1 record coming in results. in fact, identifiers not unique - can have multiple matches against particular hr personnel number, example. need flag users have more 1 active account, example (among other things). goes without saying not code.

the basic approach shred 250k results coming database 3 lists, each keyed 1 of 3 identifiers. each datafeed record, build unioned list of matches each. shockingly, slow.

i've tweaked code point can consolidate matches 80,000 rows , execute validation checks against them in less 1 second, think may have had sell soul it. code below small part of solution, it's... questionable.

// working typed datatables dictionary<datafeedtablerow, list<useridstablerow>> datafeedusersdictionary = new dictionary<datafeedtablerow, list<useridstablerow>>(); dictionary<string, list<useridstablerow>> alllocalidsdictionary;  foreach (datafeedtablerow datafeedtablerow in stagingdatatable) {     datafeedusersdictionary.add(datafeedtablerow, new list<useridstablerow>()); }  //  god may have killed puppy  // populate 3 dictionaries - 1 each identification type // these dictionaries hold useridstablerow objects  foreach (datafeedtablerow datafeedtablerow in stagingdatatable) {     list<useridstablerow> currentrecordmatches = datafeedusersdictionary[datafeedtablerow];      if (!stagingtablerow.islegal_org_idnull() && !datafeedtablerow.islocal_company_idnull()) {         localidkey = new stringbuilder().append(datafeedtablerow.legal_org_id)                                         .append(@":")                                         .append(datafeedtablerow .local_company_id)                                         .tostring();      if (alllocalidsdictionary.containskey(localidkey)) {         currentrecordmatches.addrange(alllocalidsdictionary[localidkey].where(row => !currentrecordmatches.contains(row)));     } } 

a bit of code has been snipped, of course. because datafeedusersdictionary keyed row datafeed's typed datatable, easy:

list<datafeedtablerow> multipleactiverecords = new list<datafeedtablerow>(); multipleactiverecords.addrange(datafeedusersdictionary.where(row => row.value.count(active => active.security_status_code == "active" ||                                                                                                active.security_status_code == "new_user" ||                                                                                                active.security_status_code == "temp leave") > 1)                                                       .select(stagingtablerecord => stagingtablerecord.key)); 


have sell soul in name of performance. , shouldn't because it's dangerous or unpredictable (vb 6 window handle references, anyone?). this?

the reason feel remotely okay because of functions .contains(datatablerow)... same thing, yes?


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -