Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Guava rangeset #168

Closed
TuomasKiviaho opened this issue Apr 24, 2017 · 9 comments
Closed

Support for Guava rangeset #168

TuomasKiviaho opened this issue Apr 24, 2017 · 9 comments
Assignees
Milestone

Comments

@TuomasKiviaho
Copy link

I'd like to use CRON as a compact human readable expression of RangeSet. This would give me possibility to overcome problems if I'd be treating time as DiscreteDomain.

Would it (even) be possible to convert CRON to RangeSet. Vice versa would (probably) also be possible but the rangeset would probably have to forego some sort of analyzer that normalizes it to a more compact form using negations etc.

@jmrozanec
Copy link
Owner

jmrozanec commented Apr 24, 2017

@TuomasKiviaho sounds like an interesting idea! Can you elaborate a bit more how would you express each cron field and provide some pseudocode examples? Thanks!

@TuomasKiviaho
Copy link
Author

Timestamps can't be expressed feasibly as explained in https://softwareengineering.stackexchange.com/questions/257121/converting-cron-schedule-to-time-intervals.

The individual fields of CRON (well maybe not all of the variants, but at least Quartz can) on the other hand can. Individual fields would be treated as separate range sets and I believe these can then be expressed even as discrete domains (in certain CRON dialects at least).

RangeSet would be universal way to describe the various special characters such as * meaning Range.ALL and ? comforming to Range.IsEmpty(). These can be expressed as venn/set diagram and even better there are vast amount of operations already available in the Guava lib and threeten so these operations could be brought directly to Cron class itself. Interval that is familiar from JODA didn't make it to threeten but the class gives an idea what one could do with com.cronutils.model.Cron.

This might be not a good idea because there is certainly a reason why Interval didn't make to jdk8 (ambiguous situations perhaps or then it just wasn't generic enough) and maybe I'm trying to reincarnate a bad idea here, but I think I'll be giving it a shot at one point.

@jmrozanec
Copy link
Owner

jmrozanec commented Apr 25, 2017

@TuomasKiviaho this can be done. We could provide a bound for past/future execution times, calculate time between them and provide a set of ranges. May we ask you for further clarification on two subjects?

  • Are we willing to provide a set per cron field or a single set for time between execution times?
  • Can you illustrate a use case where this feature would provide value?
    Thanks!

@TuomasKiviaho
Copy link
Author

TuomasKiviaho commented Apr 25, 2017

@TuomasKiviaho this can be done. We could provide a bound for past/future execution times, calculate time between them and provide a set of ranges. May we ask you for further clarification on two subjects?

I'm actually not that interested in actually calculating the past nor future execution times.

Can you illustrate a use case where this feature would provide value?

My use case is actually a conversion from CRON representation to a RangeSets that I use to build SQL like queries against POJOs using QueryDSL. Both SQL and QueryDSL have functions for year, month, day, hour, minute and second that also compose the internal fields of Cron class. If I'd turn the RangeSets representing these fields to pure values in form of stamp in (?,?,?,...) then I'd be sending quite a lot of data in form of an array over the wire in the worst case scenario. Hence I try to craft YEAR(stamp) between Cron.year.lowerEndpoint and Cron.year.upperEndpoint and ... style predicate out of CRON expression. I could do the translation manually by using visitor pattern but I just though that this might be an interesting approach for someone else as well.

Are we willing to provide a set per Cron field or a single set for time between execution times?

Due to the latter I'd be needing a set per Cron field. This would of course make it harder to do CRON1 intersect|union|negation|... CRON2 style operations, but I guess that's what a new RangeSet capable ExecutionBuilder could be made for.

I've also got a separate notion of valid-time start/stop similar to org.quartz.CronExpression or ISO_8601. These on the other hand fit more naturally to single set orientation, but this is outside cron-utils and those I am able to insert into my AST separately.

@jmrozanec
Copy link
Owner

@TuomasKiviaho this is a very interesting case. We would like to include such a functionality. May we ask you to take the lead? Perhaps we can do a quick draft implementation and start iterating. Thank you for the proposal!

@jmrozanec
Copy link
Owner

We created branch rangeset-support to develop this feature.

@jmrozanec jmrozanec changed the title Support for quava rangeset Support for Guava rangeset Apr 25, 2017
@jmrozanec
Copy link
Owner

@TuomasKiviaho the feature is implemented! Will be deployed soon! Thanks! 😄

@jmrozanec
Copy link
Owner

@TuomasKiviaho the feature was extracted to its own repo, to avoid the Guava dependency at the core library.

jmrozanec added a commit that referenced this issue Mar 15, 2018
…ndency, since the feature was extracted to its own repo.
@jmrozanec
Copy link
Owner

@TuomasKiviaho release 7.0.2 is now available! Thank you for contributing to cron-utils!

@jmrozanec jmrozanec added the done label Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants