You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Ian Robertson (JIRA)" <ji...@apache.org> on 2013/11/17 20:23:21 UTC

[jira] [Updated] (HIVE-5839) BytesRefArrayWritable compareTo violates contract

     [ https://issues.apache.org/jira/browse/HIVE-5839?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ian Robertson updated HIVE-5839:
--------------------------------

    Description: 
BytesRefArrayWritable's compareTo violates the compareTo contract from java.lang.Object. Specifically:

    The implementor must ensure sgn(x.compareTo( y )) == -sgn(y.compareTo( x )) for all x and y.

The compareTo implementation on BytesRefArrayWritable does a proper comparison of the sizes of the two instances. However, if the sizes are the same, it proceeds to do a check if both array's have the same constant. If not, it returns 1. This means that if x and y are two BytesRefArrayWritable instances with the same size, but different contents, then x.compareTo( y ) == 1 and y.compareTo( x ) == 1.

Additionally, the comparison of contents is order agnostic. This seems wrong, since order of entries should matter. It is also very inefficient, running at O(n^2), where n is the number of entries.

  was:
BytesRefArrayWritable's compareTo violates the compareTo contract from java.lang.Object. Specifically:

    The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y.

The compareTo implementation on BytesRefArrayWritable does a proper comparison of the sizes of the two instances. However, if the sizes are the same, it proceeds to do a check if both array's have the same constant. If not, it returns 1. This means that if x and y are two BytesRefArrayWritable instances with the same size, but different contents, then x.compareTo(y) == 1 and y.compareTo(x) == 1.

Additionally, the comparison of contents is order agnostic. This seems wrong, since order of entries should matter. It is also very inefficient, running at O(n^2), where n is the number of entries.


> BytesRefArrayWritable compareTo violates contract
> -------------------------------------------------
>
>                 Key: HIVE-5839
>                 URL: https://issues.apache.org/jira/browse/HIVE-5839
>             Project: Hive
>          Issue Type: Bug
>          Components: Serializers/Deserializers
>    Affects Versions: 0.11.0
>            Reporter: Ian Robertson
>
> BytesRefArrayWritable's compareTo violates the compareTo contract from java.lang.Object. Specifically:
>     The implementor must ensure sgn(x.compareTo( y )) == -sgn(y.compareTo( x )) for all x and y.
> The compareTo implementation on BytesRefArrayWritable does a proper comparison of the sizes of the two instances. However, if the sizes are the same, it proceeds to do a check if both array's have the same constant. If not, it returns 1. This means that if x and y are two BytesRefArrayWritable instances with the same size, but different contents, then x.compareTo( y ) == 1 and y.compareTo( x ) == 1.
> Additionally, the comparison of contents is order agnostic. This seems wrong, since order of entries should matter. It is also very inefficient, running at O(n^2), where n is the number of entries.



--
This message was sent by Atlassian JIRA
(v6.1#6144)