-
Notifications
You must be signed in to change notification settings - Fork 78
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
base: master
Are you sure you want to change the base?
Conversation
…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 = |
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.
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?
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.
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.
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.
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.
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.
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.
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 providedIndexableKey
class. Only some of the functions have currently been implemented, but it is fairly straightforward to implement the rest as needed.