You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by wagnermarkd <gi...@git.apache.org> on 2016/05/31 21:30:56 UTC

[GitHub] orc pull request: ORC-53. Make the complex types Comparable so they can be p...

Github user wagnermarkd commented on a diff in the pull request:

    https://github.com/apache/orc/pull/29#discussion_r65266565
  
    --- Diff: java/mapreduce/src/java/org/apache/orc/mapred/OrcList.java ---
    @@ -71,4 +71,30 @@ public void readFields(DataInput input) throws IOException {
           }
         }
       }
    +
    +  @Override
    +  public int compareTo(OrcList<E> other) {
    +    if (other == null) {
    +      return -1;
    +    }
    +    int ourSize = size();
    +    int otherSize = other.size();
    +    for(int e=0; e < ourSize && e < otherSize; ++e) {
    +      Writable ours = get(e);
    +      Writable theirs = other.get(e);
    +      if (ours == null) {
    +        if (theirs != null) {
    +          return 1;
    +        }
    +      } else if (theirs == null) {
    +        return -1;
    +      } else {
    +        int val = ((Comparable<Writable>) ours).compareTo(theirs);
    --- End diff --
    
    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.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---