Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. data structure design for data aggregation

data structure design for data aggregation

Scheduled Pinned Locked Moved C#
performancecssdesigndata-structurestutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    George_George
    wrote on last edited by
    #1

    Hello everyone, I want to learn from your advice about how to design data structure in the following scenario to be most efficient. One thread will create data (composed of ID and content), and output to a queue or something (data structure could be chosen to make the scenario more efficient), the data created is very frequently working to produce data, another thread is responsible to aggregate data (for the same ID, aggregate the content and output to a file), and aggregation thread works less frequently -- sleep 10 minutes, aggregate and then sleep again. I am going to find a solution which could balance, 1. Less performance impact to the data creating thread; 2. To make data aggregation thread works as efficient as possible and consume less memory. Any advice about how to design data structures? Currently, - I am stupidly using a List, appending data by the data creation thread, and I think appending data to the List is less performance impact to data create thread than using Dictionary to insert. Am I correct? - Read data from begin to end of another thread -- using ID as key into a Dictionary, since there maybe duplicate ID, so when I insert into the Dictionary, I will check if contains key, if yes, I will update the data, or else insert a new one; - Using lock on the whole List to make thread safe. Does the lock on the whole List is too heavy? Any smarter ways? :-) thanks in advance, George

    C 1 Reply Last reply
    0
    • G George_George

      Hello everyone, I want to learn from your advice about how to design data structure in the following scenario to be most efficient. One thread will create data (composed of ID and content), and output to a queue or something (data structure could be chosen to make the scenario more efficient), the data created is very frequently working to produce data, another thread is responsible to aggregate data (for the same ID, aggregate the content and output to a file), and aggregation thread works less frequently -- sleep 10 minutes, aggregate and then sleep again. I am going to find a solution which could balance, 1. Less performance impact to the data creating thread; 2. To make data aggregation thread works as efficient as possible and consume less memory. Any advice about how to design data structures? Currently, - I am stupidly using a List, appending data by the data creation thread, and I think appending data to the List is less performance impact to data create thread than using Dictionary to insert. Am I correct? - Read data from begin to end of another thread -- using ID as key into a Dictionary, since there maybe duplicate ID, so when I insert into the Dictionary, I will check if contains key, if yes, I will update the data, or else insert a new one; - Using lock on the whole List to make thread safe. Does the lock on the whole List is too heavy? Any smarter ways? :-) thanks in advance, George

      C Offline
      C Offline
      Christian Wikander
      wrote on last edited by
      #2

      I am thinking this would be better done with a database. Databases have built in functions for maintaining ID's. They also have functions for aggregating the data in most ways you can think of.

      G 1 Reply Last reply
      0
      • C Christian Wikander

        I am thinking this would be better done with a database. Databases have built in functions for maintaining ID's. They also have functions for aggregating the data in most ways you can think of.

        G Offline
        G Offline
        George_George
        wrote on last edited by
        #3

        Thanks Christian, Is there a built-in data structure like MuitlMap in C++, which allows one key maps to multiple values in C#? regards, George

        C 1 Reply Last reply
        0
        • G George_George

          Thanks Christian, Is there a built-in data structure like MuitlMap in C++, which allows one key maps to multiple values in C#? regards, George

          C Offline
          C Offline
          Christian Wikander
          wrote on last edited by
          #4

          I don't think so.

          G 1 Reply Last reply
          0
          • C Christian Wikander

            I don't think so.

            G Offline
            G Offline
            George_George
            wrote on last edited by
            #5

            Thanks Christian, If not using database, any ideas about what is the best solution you could have with memory based data structures? regards, George

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups