SortWithTake causes NPE on scala 2.10
See: See: https://groups.google.com/forum/#!topic/cascading-user/ADeupogU6wM
Daniel Vizzini writes:
I have the following piece of code:
val pivotedSort: Pipe = Tsv(filePath, fields).read
//sort
.groupBy('key) {
_.sortWithTake[(Long, Double)]((('items, 'score), 'top_placements), 5) {
(p0: (Long, Double), p1: (Long, Double)) => if (p0._2 == p1._2) { p0._1 < p1._1 } else { p0._2 < p1._2 }
}
}
which throws this error:
ReduceAttempt TASK_TYPE="REDUCE" TASKID="task_201306241658_46319_r_000005" TASK_ATTEMPT_ID="attempt_201306241658_46319_r_000005_0" TASK_STATUS="FAILED" FINISH_TIME="1372802901415" HOSTNAME="lvsaishdc3dn0391\.lvs\.ebay\.com" ERROR="cascading\.flow\.FlowException: internal error during reducer execution
at cascading\.flow\.hadoop\.FlowReducer\.reduce(FlowReducer\.java:140)
at org\.apache\.hadoop\.mapred\.ReduceTask\.runOldReducer(ReduceTask\.java:520)
at org\.apache\.hadoop\.mapred\.ReduceTask\.run(ReduceTask\.java:421)
at org\.apache\.hadoop\.mapred\.Child$4\.run(Child\.java:255)
at java\.security\.AccessController\.doPrivileged(Native Method)
at javax\.security\.auth\.Subject\.doAs(Subject\.java:396)
at org\.apache\.hadoop\.security\.UserGroupInformation\.doAs(UserGroupInformation\.java:1149)
at org\.apache\.hadoop\.mapred\.Child\.main(Child\.java:249)
Caused by: java\.lang\.NullPointerException
at scala\.math\.Ordering$$anon$4\.compare(Ordering\.scala:111)
at java\.util\.PriorityQueue\.siftUpUsingComparator(PriorityQueue\.java:594)
at java\.util\.PriorityQueue\.siftUp(PriorityQueue\.java:572)
at java\.util\.PriorityQueue\.offer(PriorityQueue\.java:274)
at java\.util\.PriorityQueue\.add(PriorityQueue\.java:251)
at com\.twitter\.chill\.PriorityQueueSerializer\.read(PriorityQueueSerializer\.scala:47)
at com\.twitter\.chill\.PriorityQueueSerializer\.read(PriorityQueueSerializer\.scala:26)
at com\.esotericsoftware\.kryo\.Kryo\.readObject(Kryo\.java:629)
at cascading\.kryo\.KryoDeserializer\.deserialize(KryoDeserializer\.java:37)
at cascading\.tuple\.hadoop\.TupleSerialization$SerializationElementReader\.read(TupleSerialization\.java:607)
at cascading\.tuple\.hadoop\.io\.HadoopTupleInputStream\.readType(HadoopTupleInputStream\.java:105)
at cascading\.tuple\.hadoop\.io\.HadoopTupleInputStream\.getNextElement(HadoopTupleInputStream\.java:52)
at cascading\.tuple\.io\.TupleInputStream\.readTuple(TupleInputStream\.java:78)
at cascading\.tuple\.io\.TupleInputStream\.readTuple(TupleInputStream\.java:67)
at cascading\.tuple\.hadoop\.io\.TupleDeserializer\.deserialize(TupleDeserializer\.java:38)
at cascading\.tuple\.hadoop\.io\.TupleDeserializer\.deserialize(TupleDeserializer\.java:28)
at org\.apache\.hadoop\.mapred\.Task$ValuesIterator\.readNextValue(Task\.java:1282)
at org\.apache\.hadoop\.mapred\.Task$ValuesIterator\.next(Task\.java:1222)
at org\.apache\.hadoop\.mapred\.ReduceTask$ReduceValuesIterator\.moveToNext(ReduceTask\.java:250)
at org\.apache\.hadoop\.mapred\.ReduceTask$ReduceValuesIterator\.next(ReduceTask\.java:246)
at cascading\.flow\.hadoop\.util\.TimedIterator\.next(TimedIterator\.java:74)
at cascading\.flow\.hadoop\.HadoopGroupByClosure$1\.next(HadoopGroupByClosure\.java:113)
at cascading\.flow\.hadoop\.HadoopGroupByClosure$1\.next(HadoopGroupByClosure\.java:71)
at cascading\.pipe\.joiner\.InnerJoin$JoinIterator\.initLastValues(InnerJoin\.java:136)
at cascading\.pipe\.joiner\.InnerJoin$JoinIterator\.next(InnerJoin\.java:168)
at cascading\.pipe\.joiner\.InnerJoin$JoinIterator\.next(InnerJoin\.java:52)
at cascading\.tuple\.TupleEntryChainIterator\.next(TupleEntryChainIterator\.java:75)
at cascading\.tuple\.TupleEntryChainIterator\.next(TupleEntryChainIterator\.java:30)
at cascading\.flow\.stream\.OpenReducingDuct\.receive(OpenReducingDuct\.java:49)
at cascading\.flow\.stream\.OpenReducingDuct\.receive(OpenReducingDuct\.java:28)
at cascading\.flow\.hadoop\.stream\.HadoopGroupGate\.run(HadoopGroupGate\.java:90)
at cascading\.flow\.hadoop\.FlowReducer\.reduce(FlowReducer\.java:133)
\.\.\. 7 more
I then ran sortWithTake, sortedTake and sortedReverseTake. I got the null pointer on the first two, but not the third. Given that sortedReverseTake is a thin wrapper around sortedTake, I figure there must be some implicit shenanigans that are throwing the exception.
Keshi Dai writes: I have the exactly same issue after upgrading to scalding_2.10 0.8.6, but the null exception goes away if I use scalding_2.9.2 0.8.6
I think https://github.com/twitter/chill/issues/111 shows this will be fixed with the new chill. We should add a unit test here though.
Can someone ( @daikeshi or @reconditesea ) write a test to verify that this is fixed now with chill 0.3.0 in scalding (you will need to make a pull req after the chill upgrade goes in).
It has to be a hadoop test (.runHadoop) else serialization won't be triggered.
Sure, I'll add the test tonight
Hi Oscar, Daniel would like to submit the test, and he's already working on it. He's going to add the test later
Sorry just saw this email. Primary oncall this week and was diving into some issues this morning. Thanks Daniel for picking this up.
On Thu, Jul 25, 2013 at 1:06 PM, Keshi Dai [email protected] wrote:
Hi Oscar, Daniel would like to submit the test, and he's already working on it. He's going to add the test later
— Reply to this email directly or view it on GitHubhttps://github.com/twitter/scalding/issues/505#issuecomment-21580838 .
Kevin Lin | Twitter, Inc. 1355 Market St. | San Francisco, CA | 94103
Follow me: @reconditesea https://twitter.com/reconditesea
Just one quick question with runHadoop. I get an error this in 2.9.2 with it and not without it:
'List((a,List((1,3.5), (3,3.0), (2,3.0))))' is not equal to 'List((a,List((1,3.5), (3,3.0), (2,3.0))))'. Values have the same string representation but possibly different types like List[Int] and List[String]
The quick and dirty around this is to test the equality of the toStrings, but is there a type-checked way of doing it?
Where are you seeing this? It could be a real bug in that something could be converted into a string at the wrong place.
Not exactly a bug. As you mentioned in the pull request, the Tsv constructor writes a List as a String.
As I asked in the pull request, is there any effort to use bake JSON's as well as primitives and Strings into Scalding source and sink methods so that collections could be easily serialized mid-Cascade?
Looks like this is fixed. Closing.