-
Notifications
You must be signed in to change notification settings - Fork 12
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
Using TimeStamp class can lead to incompatible timestamps in RedisTimeSeries #20
Comments
Hi @shaunsales I want first to put aside the issue that you mentioned which is the negative timestamp values. I missed that the module defined its timestamp type as an unsigned 64-bit integer, as it seems trivial for me that you might want to model your data with timestamps prior to epoch: Regarding the mixture of
Personally I prefer the first one as this leaves more freedom to this project users to model their data as they see fit. Although it will make them use a conversion, their data model should be uniform and they will be able to use RedisTimeSeries default API. Let me know what you think, also, if I missed anything in my answer let me know. |
To expand on the original issue, there were two problems I ran up against when I first integrated the client into our project, which cost a few hours and I felt could be easily avoided;
@DvirDukhan I would agree with your first suggestion as being the preferable option. Ideally we want the following to be consistent for .NET developers;
It seems we will need a breaking change to the API, but it will greatly improve usability and reduce the amount of time needed when onboarding new developers. If we could remove the TimeStamp class and rewrite the methods to be more intuitive that would be a bonus; For example they take a DateTime by default, and if no DateTime is provided they default to Hope this is useful. I'm happy to create a PR with a proposed API to scaffold out the features above. Best, |
@shaunsales Waiting for your input |
How about the following, for the best of both worlds - the signature for methods requiring a timestamp can be one of three types;
If we want to use DateTime, we can use the following;
The
The reason I'm in favour of this method is that it's always easy to infer what timestamping format you're using. I think 90% of developers will be happy with the Also, another quite important thing to consider is the way we work with timebuckets - currently it's very easy to make mistakes with the range methods. I propose the following; I'm not sure if we want UnixTimeStamp to implicitly cast to long, but I do like the idea of being very obvious to developers what type of timestamp they are using, and keeping it consistent. Look forward to your thoughts on the above. Best, |
@shaunsales |
@DvirDukhan The return type should match the input type. I would expect that most users would use one type of time stamp per project. |
@shaunsales |
The TimeStamp class uses DateTime.Ticks which is incompatible with the native Unix Epoch milliseconds used by Redis TimeSeries.
If you have cross-platform clients accessing the time series data, or use the
*
auto timestamp which defaults to Unix ms, it's easy to end up with unexpected results when querying ranges and aggregating samples.I suggest the TimeStamp class bounds check entries and default to supporting only UnixMs min and max timestamps. After testing, it appears that Redis TimeSeries only supports positive timestamp values, which means any dates before epoch won't work.
This would allow
*
to work as expected from the NRedisTimeSeries client and timestamps would be compatible across Unix/MacOS and Windows platforms. However using Unix ms means that DateTime.MinValue would need to throw an out of range exception. I feel if we build out a decent TimeStamp struct, this is an acceptable tradeoff.The text was updated successfully, but these errors were encountered: