Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It really depends on the specific case but I can think that a possible solution would be to store events in pages and keep in memory just the page directory:</p> <pre><code>struct Page { int id; int timestamp0, timestamp1; int bytes_used; }; </code></pre> <p>Every page only has events for a specific ID and all pages are of the same size (e.g. 4K). When you receive an event you add it to the specific page if it fits, otherwise allocate a new page for that event ID.</p> <p>When doing the searches you can quickly decide by looking at the index which pages from your data file are worth processing and you don't have to process the whole file.</p> <p>Pseudocode for adding an event is:</p> <ol> <li>find last page for ID x</li> <li>if the event doesn't fit in the page allocate a new fresh page</li> <li>store the event and update the index entry for the page</li> </ol> <p>for doing a search you:</p> <ol> <li>for each entry in the index</li> <li>if the entry is about an ID you don't care about then go to next one</li> <li>if <code>(page.timestamp0 &gt;= tsmax || page.timestamp1 &lt; tsmin)</code> then the page doesn't contain any interesting event, go to next one</li> <li>this page contains at least a relevant event; load the page and process the events that are contained in the period <code>tsmin ... tsmax</code> you are interested in.</li> </ol> <p>You can also avoid storing the index in the file (making the event logging operation faster) if you add an ID field once per page. Just when starting the server a full scan of all the data will be needed... may be or not this is an interesting option.</p> <p>You can also easily decide how much data to keep... when no more free pages are available you can reuse (may be after storing away a zipped copy for archival) all pages that only contain events older than a certain date.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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