Record.compareTo() throws ClassCastException when comparing records
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start in wayang-commons/wayang-basic/src/main/java/org/apache/wayang/basic/data/Record.java around lines 184-185 and inspect how compareTo() handles values. Reproduce the equal-record case first, then verify element-by-element comparison for ordering, tie-breaking, single-field records, and dissimilar field types; done means these comparisons no longer throw ClassCastException and equal records return 0.
Written by the indexing model from the issue text.
Description
Description
Record.compareTo() throws a ClassCastException when comparing records containing Comparable values.
The issue occurs because Record.values is an Object[], but compareTo() attempts to cast the entire array to Comparable[].
Location
wayang-commons/wayang-basic/src/main/java/org/apache/wayang/basic/data/Record.java
Around lines 184-185.
Steps to Reproduce
Record first = new Record(1, 2);
Record second = new Record(1, 2);
first.compareTo(second);
This results in a ClassCastException.
Expected Behavior
Record.compareTo() should compare the record values without throwing a ClassCastException.
For the example above, comparing two equal records should return 0.
Proposed Solution
Compare the record values element-by-element instead of casting the entire Object[] to Comparable[].
I have implemented a fix locally and added regression tests covering equal records, ordering, tie-breaking, single-field records, and dissimilar field types.
- Dominant language
- Java
- Stars
- 274
- Forks
- 141
- Avg merge
- 5d 16h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/wayang
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
[Docs] Fix broken markdown formatting, leaked reviewer prompt, and outdated URLs in tutorial.md Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
convert to config Opentodo
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
todo
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100