-
Notifications
You must be signed in to change notification settings - Fork 707
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
Cache boxed classes #1501
Cache boxed classes #1501
Conversation
This cache's the Boxes when we can, to make them much harder to Exhaust. Also the Macros will now supply an ID to enable them to be cached
@@ -0,0 +1,31 @@ | |||
/* | |||
Copyright 2014 Twitter, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
back dating it? :)
Addressed all the comments i think |
val untypedRes = Option(boxedCache.get(cls)) match { | ||
case Some(r) => r | ||
case None => | ||
val r = next[K]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you did the Any
here instead of K
you would not need the cast in putIfAbsent, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that works
👍 MWG |
…eBoxedClasses Conflicts: scalding-serialization/src/main/scala/com/twitter/scalding/serialization/Boxed.scala
This should make it far harder to exhaust boxed classes. The macros now inherit from a class providing a sane equals and hash code. They supply the class name they operate on as their ID to this parent class. Includes test that runs through a few primitive types and a custom case class.