Rick Measham wrote:
> 
> Flavio S. Glock wrote:
> > Sets of type 4 are 'huge sets'. These have an 'unknown' count. The
> count
> > can be thousands or even millions of dates, but it is not infinite.
> 
> - or two or three -

Two or three are ok :)
 
> > Before version 0.10, you would run out of memory if you specified
> > something like "all seconds in the century".
> > Now, the program will just go on normally - it creates a 'huge set'.
> And
> > it doesn't attempt to count the set elements.
> 
> Would there be some way we could 'guess' if it's loo large to count? Or
> maybe if a count is requested, we count 10,000 and then return undef if
> there's more?

That's the way it works, kind of. 
I set the count limit to 200 elements. This seems to fit most practical
uses.

> I'm thinking there would be a lot of recurrences such as 'every tuesday'
> with restraints such as 'in 2003'. This is easily countable and probably
> useful.

No problem with this, it's below the limit.
 
> The 'guess' part would be to look at the recurrence and check it's
> 'density'. With the occurrence above, the density is 1/week. Given a
> start and end date, we could calculate this for a large number of years.
> Lets say this module doesn't return counts over 10,000. We build in
> yearly guestimates for our density denominators. The week guestimate is
> 52. So we can count the elements for (range as years in float)/52
> recurrences.
> 
> If we have a recurrence of 'every second' then the yearly guestimate is
> 60*60*24*356.25. Now we can take our (range as years in float) and
> divide it by our yearly guestimate. If the result is over 10,000 we
> return undef.
> 
> While all this is a heap of code, we can quickly see if it's worth
> counting the actual occurrences.

That's a good idea, but some sets have a variable density, such as
friday-13.
 
> ALSO If we go this path or not, I'd prefer not to get plain undef back.
> I'd like an indication that it was 'too hard to count', or that it was
> 'over 10,000'.

That would be ok, can you suggest an API?
Is it ok to die with a message?

- Flavio S. Glock

Reply via email to