Re: discuss: add to_human_size function

2024-04-29 Thread Štefan Miklošovič
FYI, I added both to_human_size and to_human_duration (1), (2). I try my luck with asking for a reviewer. It is also tested / documented etc. (1) https://github.com/apache/cassandra/pull/3239/files (2) https://github.com/apache/cassandra/blob/f35ed228145fae3edb4325d29464f0d950d13511/doc/modules/c

Re: discuss: add to_human_size function

2024-04-25 Thread Ekaterina Dimitrova
All I say is we should be careful not to open the door for someone to be able to set for a parameter in cassandra.yaml 512MiB and convert it to 0 GiB internally while changing those classes. Loss of precision and weird settings. As long as that pandora box stays closed, all good 👍🏻 I do support t

Re: discuss: add to_human_size function

2024-04-25 Thread Jon Haddad
I can’t see a good reason not to support it. Seems like extra work to avoid with no benefit. — Jon Haddad Rustyrazorblade Consulting rustyrazorblade.com On Thu, Apr 25, 2024 at 7:16 AM Štefan Miklošovič < stefan.mikloso...@gmail.com> wrote: > Can you elaborate on intentionally not supporting so

Re: discuss: add to_human_size function

2024-04-25 Thread Štefan Miklošovič
Can you elaborate on intentionally not supporting some conversions? Are we safe to base these conversions on DataStorageUnit? We have set of units from BYTES to GIBIBYTES and respective methods on them which convert from that unit to whatever else. Is this OK to be used for the purposes of this fea

Re: discuss: add to_human_size function

2024-04-25 Thread Ekaterina Dimitrova
All I am saying is be careful with adding those conversions not to end up used while setting our configuration. Thanks 🙏 On Thu, 25 Apr 2024 at 6:53, Štefan Miklošovič wrote: > Well, technically I do not need DataStorageSpec at all. All I need is > DataStorageUnit for that matter. That can conve

Re: discuss: add to_human_size function

2024-04-25 Thread Štefan Miklošovič
Well, technically I do not need DataStorageSpec at all. All I need is DataStorageUnit for that matter. That can convert from one unit to another easily. We can omit tebibytes, that's just fine. People would need to live with gibibytes at most in cqlsh output. They would not get 5 TiB but 5120 GiB,

Re: discuss: add to_human_size function

2024-04-25 Thread Ekaterina Dimitrova
Edit: I meant to say smaller to bigger unit, not size, sorry On Thu, 25 Apr 2024 at 6:35, Ekaterina Dimitrova wrote: > Quick comment: > > DataRateSpec, DataStorageSpec, or DurationSpec > - we intentionally do not support going smaller to bigger size in those > classes which are specific for cass

Re: discuss: add to_human_size function

2024-04-25 Thread Ekaterina Dimitrova
Quick comment: DataRateSpec, DataStorageSpec, or DurationSpec - we intentionally do not support going smaller to bigger size in those classes which are specific for cassandra.yaml - precision issues. Please keep it that way. That is why the notion of min unit was added in cassandra.yaml for parame

Re: discuss: add to_human_size function

2024-04-25 Thread Claude Warren, Jr via dev
TiB is not yet in DataStorageSpec (perhaps we should add it). A quick review tells me that all the units are unique across the 3 specs. As long as we guarantee that in the future the method you propose should be easily expandable to the other specs. +1 to this idea. On Thu, Apr 25, 2024 at 12:26

Re: discuss: add to_human_size function

2024-04-25 Thread Štefan Miklošovič
That is a very interesting point, Claude. My so-far implementation is using FileUtils.stringifyFileSize which is just dividing a value by a respective divisor based on how big a value is. While this works, it will prevent you from specifying what unit you want that value to be converted to as well

Re: discuss: add to_human_size function

2024-04-19 Thread Claude Warren, Jr via dev
I like the idea. Is the intention to have the of the function be parsable by the config parsers like DataRateSpec, DataStorageSpec, or DurationSpec? Claude On Thu, Apr 18, 2024 at 9:47 PM Ariel Weisberg wrote: > Hi, > > I think it’s a good quality of life improvement, but I am someone who > b

Re: discuss: add to_human_size function

2024-04-18 Thread Ariel Weisberg
Hi, I think it’s a good quality of life improvement, but I am someone who believes in a rich set of built-in functions being a good thing. A format function is a bit more scope and kind of orthogonal. It would still be good to have shorthand functions for things like size. Ariel On Tue, Apr 9

Re: discuss: add to_human_size function

2024-04-15 Thread Štefan Miklošovič
I think we might still have two functions. The first one, format, as you just showed, which would copy the behaviour in MySQL as closely as possible. The second one would deal with sizes, like "format_size", which would append size unit, as shown in the branch I posted. WDYT? Regards On Thu, A

Re: discuss: add to_human_size function

2024-04-10 Thread Brad
It's a useful idea and something supported in other databases. MySQL has FORMAT function: FORMAT(X,D[,locale]) Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part. If