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

Cache boxed classes #1501

Merged
merged 5 commits into from
Feb 5, 2016
Merged

Cache boxed classes #1501

merged 5 commits into from
Feb 5, 2016

Conversation

ianoc
Copy link
Collaborator

@ianoc ianoc commented Feb 4, 2016

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.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

back dating it? :)

@ianoc
Copy link
Collaborator Author

ianoc commented Feb 4, 2016

Addressed all the comments i think

val untypedRes = Option(boxedCache.get(cls)) match {
case Some(r) => r
case None =>
val r = next[K]()
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, that works

@johnynek
Copy link
Collaborator

johnynek commented Feb 5, 2016

👍 MWG

…eBoxedClasses

Conflicts:
	scalding-serialization/src/main/scala/com/twitter/scalding/serialization/Boxed.scala
ianoc added a commit that referenced this pull request Feb 5, 2016
@ianoc ianoc merged commit c1857ce into develop Feb 5, 2016
@ianoc ianoc deleted the ianoc/cacheBoxedClasses branch February 5, 2016 18:00
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