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

ORC-53. Make the complex types Comparable so they can be put as keys in OrcMap #29

Closed
wants to merge 3 commits into from

Conversation

omalley
Copy link
Contributor

@omalley omalley commented May 26, 2016

No description provided.

} else if (theirs == null) {
return -1;
} else {
int val = ((Comparable<Writable>) ours).compareTo(theirs);

Choose a reason for hiding this comment

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

Comparing two complex types with different nested types will cause trouble here. To avoid this, we need to first compare the schemas, then the values. This applies to all the complex types.

@omalley omalley force-pushed the orc-53 branch 2 times, most recently from 77d32e7 to 62df673 Compare June 1, 2016 03:56
@omalley
Copy link
Contributor Author

omalley commented Jun 1, 2016

Ok, this needed a relatively large change. To compare the schemas, I wanted to make TypeDescription implement Comparable, but the equals and hashCode were set up to match against the id, which would have largely screwed things up. So, I made SchemaEvolution use a HashMap<Integer, TypeDescription> and used the id as the key. That is more straightforward and let me change the semantics of equals and hashCode to be more reasonable. While I was in TypeDescription, I also made it Serializable since FindBugs was complaining about the OrcList and OrcMap having non-serializable fields.

I also added a log4j.properties file into the test resources so that the log messages come out to the console during unit tests.

I also changed the 4 complex ORC types to implement WritableComparable, which ORC-53 had done to better match with MapReduce's requirements for key types.

OrcStruct right = new OrcStruct(rightType);
assertEquals(-1, left.compareTo(right));
assertEquals(1, right.compareTo(left));
left.setAllFields(new Text("123"), new IntWritable(123));

Choose a reason for hiding this comment

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

I checked out your branch and got a compilation error for setAllFields, which was introduced for ORC-52.

@omalley
Copy link
Contributor Author

omalley commented Jun 1, 2016

The compilation was working for me, but you had a good point that in the current version that everything should implement WritableComparable since obviously compareTo needs to recurse all the way down.

Can you try the current version?

@wagnermarkd
Copy link

Everything works on the orc-52 branch, which is based on orc-53, but with orc-53 I still see the previous error for TestOrcStruct and this new one for OrcRecordReader:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project orc-mapreduce: Compilation failure: Compilation failure:
[ERROR] /home/mwagner/git/orc/java/mapreduce/src/java/org/apache/orc/mapred/OrcRecordReader.java:[94,15] no suitable method found for setFieldValue(int,org.apache.hadoop.io.Writable)
[ERROR] method org.apache.orc.mapred.OrcStruct.setFieldValue(int,org.apache.hadoop.io.WritableComparable) is not applicable
[ERROR] (argument mismatch; org.apache.hadoop.io.Writable cannot be converted to org.apache.hadoop.io.WritableComparable)

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.

None yet

2 participants