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

Cannot sort on numbers #408

Closed
GoogleCodeExporter opened this issue Mar 16, 2015 · 2 comments
Closed

Cannot sort on numbers #408

GoogleCodeExporter opened this issue Mar 16, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

The new tolog NumbersModule [1] adds support for numbers. Tolog does not sort 
numbers correctly, though. This can be reproduced by using this query:

 import "http://psi.ontopia.net/tolog/numbers/" as numbers
 select $value from
 { numbers:value("6", $value)
 | numbers:value("45", $value)
 | numbers:value("78", $value)
 | numbers:value("123", $value)
 } order by $value?

Tolog returns 123, 45, 6, 78 instead of 6, 45, 78, 123.

This is caused by the RowComparator inner class in QueryProcessor. The code 
applies ORDER_OBJECT sorting for multi-typed signature arguments, which means 
ObjectUtils.toString(value) for non TMObjectIF objects. The NumbersModule uses 
'n' as signature, which returns two types [2]: Integer and Float. This results 
in numbers being sorted by their String equivalent, which explains the 
erroneous behaviour.

To fix this issue, check if multi-typed signatures hold only Numbers subclasses 
and, if so, apply a separate sorting algorithm on these numbers.

[1]: http://code.google.com/p/ontopia/source/detail?r=2182
[2]: 
http://code.google.com/p/ontopia/source/browse/trunk/ontopia-engine/src/main/jav
a/net/ontopia/topicmaps/impl/utils/ArgumentValidator.java?r=2126#100

Original issue reported on code.google.com by p.kruijsen on 19 Sep 2011 at 10:59

@GoogleCodeExporter
Copy link
Author

This issue was closed by revision r2212.

Original comment by p.kruijsen on 19 Sep 2011 at 11:00

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Original comment by qsieb...@gmail.com on 27 Jan 2012 at 11:07

  • Added labels: Release5.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant