Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create unique ID from 3 values <int, int, DateTime>?
    primarykey
    data
    text
    <p>I'm parsing an online feed (tcp relay) that sends approximately 30-50 messages per second (300-500 rows of data). The messages contain 2 types of information: <strong><em>orders</em></strong> and <strong><em>history</em></strong>. </p> <p>So, with <strong><em>orders</em></strong>, each one has a unique ID and I've got:</p> <pre><code>private static Dictionary&lt;long,MarketOrder&gt; MarketOrders = new Dictionary&lt;long,MarketOrder&gt;(); </code></pre> <p>to which I insert orders as they come in. Data comes from cache files so messages can contain data which is old and has to be filtered out. I'm currently doing this:</p> <pre><code>if (MarketOrders.ContainsKey(order.OrderID)) { // If record exists in a dictionary add hits and overwrite the object if newer. int hits = MarketOrders[order.OrderID].Hits; if (MarketOrders[order.OrderID].LastUpdated &lt; order.LastUpdated) { MarketOrders[order.OrderID] = order; } MarketOrders[order.OrderID].Hits = hits + 1; } else { // If not, add new one order.Hits = 1; MarketOrders.Add(order.OrderID, order); } </code></pre> <p>This runs in a BackgroundWorker process, and when the dictionary item count hits 2500, it is deep cloned (using binary serializer), cleared and another background process is initiated, that inserts the cloned copy into the database. As soon as dictionary is cleared, orders are being inserted again. So basically I'm trying to receive as much as I can and insert to database in batches. </p> <p>I'm trying to do something similar with the <strong><em>history</em></strong> data. There is no unique ID as such and uniqueness comes from combination of <code>&lt;int, int, DateTime&gt;</code> values.</p> <p>I need a fast method of generating a unique key from these 3 values, so I can store it in a dictionary like I do with orders, or another method of storing and filtering that data.</p> <p>Any suggestions? I'm targeting .NET 4.0.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload