c# - What is a good .NET data structure for finding unique items? -
i have large collection of custom objects have retrieved query in system. let's these objects have 5 different properties - firstname, lastname, gender, zipcode , birthday. each of different properties able list of of unique values , counts , sort them in descending order. sort of faceted navigation system. if have 5000 results in initial query able display top 10 firstnames popular least popular count next it. , same other properties.
currently have routine goes through each item 1 @ time , examines different properties , keeps bunch of different hashtables information. works super slow. think going through each item 1 @ time not efficient. there other type of c# structure use make getting type of information easier? know sql server great job of type of thing - don't think possibility here. i'm getting list of custom objects api of different system. have take list of objects , put them in temp table somehow , sort of defeats purpose think. plus sql server temp tables connection specific think , app re-use connections.
edit: trying avoid having iterate through list , process each individual item. wondering if there data structure allow me sort of query whole list @ once (like database) , information. problem our front end web server getting hammered because have lot of traffic on server , people hitting these faceted nav pages , looking more efficient way of doing it.
any ideas?
thanks, corey
unfortunately, i'm pretty sure answer question is, "no." if only way have of getting data unindexed list<myobject>, something going have go through items one-by-one , analyze them top-n or create indices. if pass on tool (a temp database or third party data structure), you're putting processing somewhere else , cpu crank much. solution outline in original question seems reasonable thing do.
a few suggestions:
- are these top-n lists same users, or broken distinct number of use cases? them once , store them in web cache. maybe set background process update them every m minutes keep them up-to-date.
- is ui perception problem? calculate , display important results first , calculate others in background , deliver page asynchronously?
- beg api provider more robust way results?? :)
- throw more hardware @ it?? :)
sorry non-answer, don't think there's magic bullet here.
Comments
Post a Comment