Re: Java: DefaultVectorComparators - invalid implementation

2020-04-09 Thread Fan Liya
Hi Martin,

Thank you so much for reporting this problem.

In the current implementation, we do not consider corner cases related to
integer overflow, and this problem should be fixed.

I have opened an issue to track this problem [1].
Do you want to provide a patch for it?

Best,
Liya Fan

[1] https://issues.apache.org/jira/browse/ARROW-8392

On Fri, Apr 10, 2020 at 12:55 AM Martin Janda  wrote:

> I made first look to Apache Arrow Java sources.
>
> I found wrong implementation for DefaultVectorComparators.LongComparator
> I suppose that other comparators can be wrong too.
>
> Simple test:
>
> long l1=Long.MIN_VALUE +1L;
> long l2=Long.MAX_VALUE;
>
> System.out.println("Arrow: " + Long.signum(l1 - l2));
> System.out.println("Java : " + Long.compare(l1, l2));
>
> Result:
> Arrow: 1
> Java : -1
>
> I think that there should be added tests for corner cases. And I suggest
> to replace arrow implementation with Long.compare, Integer.compare...
>   that provides correct results.
>Thank you
> Martin
>
> PS I have no access to JIRA to report this issue.
>
>


Java: DefaultVectorComparators - invalid implementation

2020-04-09 Thread Martin Janda

I made first look to Apache Arrow Java sources.

I found wrong implementation for DefaultVectorComparators.LongComparator 
I suppose that other comparators can be wrong too.


Simple test:

long l1=Long.MIN_VALUE +1L;
long l2=Long.MAX_VALUE;

System.out.println("Arrow: " + Long.signum(l1 - l2));
System.out.println("Java : " + Long.compare(l1, l2));

Result:
Arrow: 1
Java : -1

I think that there should be added tests for corner cases. And I suggest to 
replace arrow implementation with Long.compare, Integer.compare...
 that provides correct results.
  Thank you
   Martin

PS I have no access to JIRA to report this issue.