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

Implemented new TsTimeStamp type. Updated examples and tests. #35

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

shaunsales
Copy link
Contributor

@shaunsales shaunsales commented Sep 4, 2020

Still to be implemented;

  • Create a TsTimeBucket type with range checks
  • Figure out if we want mixed auto and explicit timestamp support in TS.MADD
  • Add better exception tests for all commands

@shaunsales
Copy link
Contributor Author

Added the TsTimeBucket type with updated tests and examples.

@gkorland gkorland requested a review from DvirDukhan September 5, 2020 23:47
Copy link
Collaborator

@DvirDukhan DvirDukhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shaunsales
Great PR, Thanks
Sorry for the long time it took me to return a feedback
few comments:

  1. the values:
        public static readonly TsTimeStamp MinValue = new TsTimeStamp(_minUnixMilliseconds);
        public static readonly TsTimeStamp MaxValue = new TsTimeStamp(_maxUnixMilliseconds);

Those members function with a dual purpose: value validation and replacing the - and + symbols, which are used in the module API.
I prefer not to have a dual purpose. As long as the module is not supporting negative values, the value validation is a welcome addition. However, instead of using the module native API, the current implementation sends actual values, which I want to avoid since module changes might change (break) the client behavior. I prefer that the properties will return the strings - and +
2. Having functions with default timestamp value (no timestamp parameter) - great addition
3. Please use and allow implicit casting whenever possible, so the user experience moving to this version will not change dramatically.

NRedisTimeSeries.Example/AddExample.cs Outdated Show resolved Hide resolved
NRedisTimeSeries.Example/AddExampleAsync.cs Outdated Show resolved Hide resolved
NRedisTimeSeries.Example/DecrByExample.cs Outdated Show resolved Hide resolved
NRedisTimeSeries.Example/DecrByExample.cs Outdated Show resolved Hide resolved
NRedisTimeSeries.Example/IncrByExample.cs Outdated Show resolved Hide resolved
NRedisTimeSeries/DataTypes/TsTimeBucket.cs Show resolved Hide resolved
NRedisTimeSeries.Test/TestDataTypes/TestTimeSeriesTuple.cs Outdated Show resolved Hide resolved
NRedisTimeSeries.Test/TestDataTypes/TestTimeSeriesTuple.cs Outdated Show resolved Hide resolved
NRedisTimeSeries.Test/TestDataTypes/TestTimeSeriesTuple.cs Outdated Show resolved Hide resolved
NRedisTimeSeries/DataTypes/TsTimeStamp.cs Show resolved Hide resolved
@shaunsales
Copy link
Contributor Author

@shaunsales

Great PR, Thanks

Sorry for the long time it took me to return a feedback

few comments:

  1. the values:
        public static readonly TsTimeStamp MinValue = new TsTimeStamp(_minUnixMilliseconds);

        public static readonly TsTimeStamp MaxValue = new TsTimeStamp(_maxUnixMilliseconds);

Those members function with a dual purpose: value validation and replacing the - and + symbols, which are used in the module API.

I prefer not to have a dual purpose. As long as the module is not supporting negative values, the value validation is a welcome addition. However, instead of using the module native API, the current implementation sends actual values, which I want to avoid since module changes might change (break) the client behavior. I prefer that the properties will return the strings - and +

I was thinking about this for a while when I was implementing the new timestamp and I think a good solution might be to hide the string conversion in an internal extension.

I want to avoid creating any additional backing fields in the struct as currently it can be represented as a single long.

The way I dealt with * was to simply assume we let Redis auto-timestamp when the user doesn't provide a timestamp and I think that works quite intuitively. I'd like to find a similar solution to +/-

  1. Having functions with default timestamp value (no timestamp parameter) - great addition

Thanks.

  1. Please use and allow implicit casting whenever possible, so the user experience moving to this version will not change dramatically.

I think we should be a little bit cautious with implicit casting, as it can cause confusion if you use out of range values. But that's more a usability thing. I'll have a look into it. Was there any specific casts you had in mind?

@DvirDukhan
Copy link
Collaborator

@shaunsales

  1. I agree - the usage of -/+ should be internal and not exposed. The next version should not support string casting. Maybe consider having static instances in the TsTimeStamp class for TsTimeStamp.MinTS and TsTimeStamp.MinTS that you can send as in input a function as the timestamp parameter, compare the parameter agains them and decide if the send the -/+ string (if you have a match) or the parameter timestamp UnixMilliseconds value.
  2. Regarding the casts - I saw in the tests that you explicitly calling the constructor of TsTimeStamp, I want to avoid this, that's all.

@shaunsales
Copy link
Contributor Author

  1. I agree - the usage of -/+ should be internal and not exposed. The next version should not support string casting. Maybe consider having static instances in the TsTimeStamp class for TsTimeStamp.MinTS and TsTimeStamp.MinTS that you can send as in input a function as the timestamp parameter, compare the parameter agains them and decide if the send the -/+ string (if you have a match) or the parameter timestamp UnixMilliseconds value.

Sure, I think that's a good compromise. I've been quite busy this week, but will try to get onto it this weekend.

  1. Regarding the casts - I saw in the tests that you explicitly calling the constructor of TsTimeStamp, I want to avoid this, that's all.

Ok, no problem - I was mostly wanting to point out that it could be confusing to users if they are using implicit casts and get ArgumentOutOfRangeException - my thinking was I wanted to have usability similar to the DateTime struct, so the learning curve is easier. When you explicitly construct, we can warn you about out-of-range values.

@DvirDukhan
Copy link
Collaborator

@shaunsales eventually an exception will be thrown if the user will try to use an invalid value when calling a function requiring TsTimeStamp instance (due to casting).
maybe add a unit test to the class for invalid usage from implicit casting?

@shaunsales
Copy link
Contributor Author

@DvirDukhan Yep, let's do that. I'll let you know when the changes have been made. Thanks.

…crBy and DecrBy examples to include timestamps. Removed duplicate examples for IncrBy and DecrBy. Tested against RedisTimeSeries 1.4.4
@DvirDukhan
Copy link
Collaborator

@shaunsales is your last commit handles the review comments? I can re-review?

@shaunsales
Copy link
Contributor Author

@shaunsales is your last commit handles the review comments? I can re-review?

Sure. I believe all the outstanding requests have been implemented.

@DvirDukhan
Copy link
Collaborator

@shaunsales LGTM

@DvirDukhan
Copy link
Collaborator

@shaunsales
Anything else needs to be done?
If not, can you please resolve the conflicts so I'll approve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants