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

Make TDigest serializable #47

Closed
gregakespret opened this issue Apr 5, 2015 · 2 comments
Closed

Make TDigest serializable #47

gregakespret opened this issue Apr 5, 2015 · 2 comments

Comments

@gregakespret
Copy link

I was wondering why TDigest is not Serializable. I found myself writing some boilerplate code to serialize/deserialize it between tasks when using it in Spark and it would be cool if it was serializable by default. This is what I have to do now:

def serialize(tdigest: TDigest) = {
  val arr = new Array[Byte](tdigest.byteSize)
  tdigest.asBytes(ByteBuffer.wrap(arr))
  arr
}

def deserialize(arr: Array[Byte]) = {
  AVLTreeDigest.fromBytes(ByteBuffer.wrap(arr))
}

Do you have any thoughts on that? I could submit a PR for this if you think it'd be useful.

@tdunning
Copy link
Owner

tdunning commented Apr 6, 2015

Hmm...

I really dislike what Serializable does to code. It is definitely
important to have a way to save data, but it tends to make things really
brittle.

How bad is this for you?

On Sun, Apr 5, 2015 at 4:57 PM, Grega Kespret [email protected]
wrote:

I was wondering why TDigest is not Serializable. I found myself writing
some boilerplate code to serialize/deserialize it when using it in Spark
and it would be cool if it was serializable by default. This is what I have
to do now:

def serialize(tdigest: TDigest) = {
val arr = new ArrayByte
tdigest.asBytes(ByteBuffer.wrap(arr))
arr
}

def deserialize(arr: Array[Byte]) = {
AVLTreeDigest.fromBytes(ByteBuffer.wrap(arr))
}

Do you have any thoughts on that? I could submit a PR for this if you
think it'd be useful.


Reply to this email directly or view it on GitHub
#47.

@gregakespret
Copy link
Author

It's not that bad, I have a working solution and can continue to use it (code above).

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

No branches or pull requests

2 participants