-
Notifications
You must be signed in to change notification settings - Fork 1k
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
For secondary sorting #57
Comments
I'm not familiar with this code but the key is not lic but (lic, f(trip)) and so it is likely to be intended. Values are separately sorted and split. @sryza ? |
As far as I can tell, for this line
K is lic, S is f(trip). Ordering by(_._1) means to order by K , which is lic, right ? Did I miss something here? |
It should apply to the repartition and sort of |
Here is what I understand. presess is RDD of ((lic, secondaryKeyFunc(trip)), trip) . The key is composite key includes lic and timestamp of the trip. The value is the trip.
This line indicates how we want to sort by the key, which is by the first element of the tuple( lic , timestamp) , which is lic in this case. As I tried to run the code with small set of taxi data, I found that the data are not ordered by the pickup time. |
My reading is that the code in its present form is correct. In this case, CC @jwills who wrote this code originally. |
Here is the mock data I am using for testing purpose
I added a line to print out the trip
What I got is
As you can see, it is not ordered by pick up time. Keep the same order as is in the text file. |
I tried running the code on @yaominator 's data sample and hit the incorrect behavior as well. It looks my analysis of what was going on was incorrect, because, by the contract of repartionAndSortWithinPartitions, the given ordering only applies to keys, which are the (lic, pickup time) tuples. The ordering overrides the natural lexicographic tuple ordering to only look at the first element. I've pushed a fix here: 5d0514c. This code isn't included in the text of the book, so I don't think we need an accompanying change there. |
works great !!! +1 |
Awesome |
For this line
https://github.com/sryza/aas/blob/master/ch08-geotime/src/main/scala/com/cloudera/datascience/geotime/RunGeoTime.scala#L175
I am wondering if it should be changed to
so it can be sorted by the pickup time. If using the _1, it means it will use lic to sort, but in the same partition, it is always the same anyway. I think what we need is to sort by the pickup time within the partition.
The text was updated successfully, but these errors were encountered: