Note that there are some explanatory texts on larger screens.

plurals
  1. POAlgorithm in Python to store and search daily occurrence for thousands of numbered events?
    primarykey
    data
    text
    <p>I'm investigating solutions of storing and querying a historical record of event occurrences for a large number of items.</p> <p>This is the simplified scenario: I'm getting a daily log of 200 000 streetlamps (labeled sl1 to sl200000) which shows if the lamp was operational on the day or not. It does not matter for how long the lamp was in service only that it was on a given calendar day.</p> <p>Other bits of information are stored for each lamp as well and the beginning of the Python class looks something like this:</p> <pre><code>class Streetlamp(object): """Class for streetlamp record""" def __init__(self, **args): self.location = args['location'] self.power = args['power'] self.inservice = ??? </code></pre> <p>My py-foo is not too great and I would like to avoid a solution which is too greedy on disk/memory storage. So a solution with a dict of (year, month, day) tuples could be one solution, but I'm hoping to get pointers for a more efficient solution.</p> <p>A record could be stored as a bit stream with each bit representing a day of a year starting with Jan 1. Hence, if a lamp was operational the first three days of 2010, then the record could be:</p> <pre><code>sl1000_up = dict('2010': '11100000000000...', '2011':'11111100100...') </code></pre> <p>Search across year boundaries would need a merge, leap years are a special case, plus I'd need to code/decode a fair bit with this home grown solution. It seems not quiet right. <a href="https://stackoverflow.com/questions/2897297/speed-up-bitstring-bit-operations-in-python">speed-up-bitstring-bit-operations</a>, <a href="https://stackoverflow.com/questions/2315032/how-do-i-find-missing-dates-in-a-list-of-sorted-dates">how-do-i-find-missing-dates-in-a-list</a> and <a href="https://stackoverflow.com/questions/4375310/finding-data-gaps-with-bit-masking">finding-data-gaps-with-bit-masking</a> where interesting postings I came across. I also investigated <a href="https://code.google.com/p/python-bitstring/" rel="nofollow noreferrer">python-bitstring</a> and did some googling, but nothing seems to really fit.</p> <p>Additionally I'd like search for 'gaps' to be possible, e.g. 'three or more days out of action' and it is essential that a flagged day can be converted into a real calendar date.</p> <p>I would appreciate ideas or pointers to possible solutions. To add further detail, it might be of interest that the back-end DB used is ZODB and pure Python objects which can be pickled are preferred. </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