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

Add BigInteger version of getBytes #172

Closed
havocp opened this issue Jun 23, 2014 · 4 comments · Fixed by #663
Closed

Add BigInteger version of getBytes #172

havocp opened this issue Jun 23, 2014 · 4 comments · Fixed by #663

Comments

@havocp
Copy link
Collaborator

havocp commented Jun 23, 2014

We support huge unit prefixes like yottabytes that can't fit in a long, so either drop that support or add a BigInteger-based accessor.

This is an API addition so would go in a 1.4

@havocp
Copy link
Collaborator Author

havocp commented Jun 23, 2014

Though it's pretty hard to come up with use-cases for byte counts that don't fit in a long, I guess.

@mpryahin
Copy link
Contributor

mpryahin commented Dec 23, 2019

Hello,
I came across this requirement multiple times. And now once again. I need to pass a configuration option containing memory size which doesn't fit 64 bits. It would be fantastic if we had this feature implemented in TypeSafe Config.
I propose the enhancement by introducing the following backwards-compatible changes:

  1. ConfigMemorySize class. Add a factory method constructing ConfigMemorySize class instances taking a BigInteger as an argument.
  2. Config interface. Add BigInteger-based accessors for memory config options. (consider deprecating long-based accessors?)
  3. SimpleConfig class. Change the getMemorySize implementation to create ConfigMemorySize class instances passing BigInteger as an argument.
  4. ConfigMemorySize class. Introduce a new method toByteArray returning a byte array representation of this BigInteger.
  5. ConfigMemorySize class. Keep the toBytes method for backward compatibility. The implementation tries extracting Long value out of a BigInteger in case it fits 64 bytes. It is exactly how it's implemented in the getBytes method of the SimpleConfig class.

I'm ready to create a PR.

@mpryahin
Copy link
Contributor

mpryahin commented Jan 8, 2020

Though it's pretty hard to come up with use-cases for byte counts that don't fit in a long, I guess.

Hi @havocp,
We're using Aerospike in our project which stores keys in RAM and data on disk. We need to limit the maximum amount of RAM which is allowed to be consumed. The maximum RAM value for a single Aerospike Set is defined as a maximum number of unique keys per Set multiplied by 64 bytes each where the maximum number of unique keys is limited by the hash function (RIPEMD-160) which can produce 2^160 unique values. The value of 64*2^160 bytes doesn't fit in a long.

Could you please have a look at the PR?

Thanks a lot in advance!

@mpryahin
Copy link
Contributor

hello @havocp
I just wanted to ask when approximately you are going to merge the approved PR into the main branch?

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

Successfully merging a pull request may close this issue.

2 participants