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

Support for Non-Long Keys #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Support for Non-Long Keys #2

wants to merge 3 commits into from

Conversation

kmader
Copy link

@kmader kmader commented Feb 23, 2015

A proposed addition to have non-Long keys using the IndexableRDD which is a thin class on top of IndexedRDD and has a conversion between a key of any type and a Long using the provided IndexableKey class. Only some of the functions have currently been implemented, but it is fairly straightforward to implement the rest as needed.

…ypes provided the mechanism for converting them to and from. Only a few functions currently implemented
val p3dKey = new IndexableKey[Point3D] {
override def toId(key: Point3D): Id = 1000*key.z+100*key.y+key.x

override def fromId(id: Id): Point3D =
Copy link
Member

Choose a reason for hiding this comment

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

How general is this interface? Let's say the integers in my case class are pretty large, then (assuming toId is still some kind of encoding or hashing) fromId may fail?

Copy link
Author

Choose a reason for hiding this comment

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

Those are just the example ones, clearly in this case IndexableKey stops working for Point3D as soon as y>=10 or x>=100. fromId and toId need to be unique and reversible for this to be a really practical approach.
I think however there are many scenarios where this makes sense and it makes processing much easier to keep the key as the type it is and having the IndexableRDD perform the translation automatically, rather than converting it to long and keeping track of its real value somewhere else.

Copy link
Member

Choose a reason for hiding this comment

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

Speaking for certain NLP applications, not being able to have a bijection can be a blocker. It'd be good to have real-world examples of applications the purposed interface makes available to build.

Copy link
Author

Choose a reason for hiding this comment

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

Well spatial applications / imaging is a perfect application since for many applications the domain of the Point3D is known (dimensions 1000 x 1000 x 1000) which means the points can be bijectively mapped to longs using id=(1000*z+y)*1000+x. This is also generally applicable to matrices and arrays (particularly sparse ones) since they typically have well defined sizes and could also have such a mapping performed easily and rarely do they contain a number of points which cannot be expressed as a long.

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