[Mulgara-dev] perhaps before 2.0.6 released -- OrderedByRowComparator
Paul Gearon
gearon at ieee.org
Thu Oct 16 14:26:59 UTC 2008
Just looked more carefully at the patch, and I see now that it you
used the Float constructor to do the real test which is fine. Sorry
for doubting. :-)
Testing now.
Paul
On Thu, Oct 16, 2008 at 9:13 AM, Paul Gearon <gearon at ieee.org> wrote:
> Hi David,
>
> Sorry I never got to this before now.
>
> You caught me in the process of putting 2.0.6 out. This isn't too big
> a patch, so I think I can delay by the 30 minutes needed to get it in.
> However, I think I need to check it more carefully, as I don't think
> it's thorough enough. (The current code iterates over the entire
> string, but your test is partial)
>
> I've already added the other patch in. Since I was familiar with the
> web servlet (having ported it recently) I looked to see where this URL
> came from, and decided to re-use the tag map.... only to discover that
> you'd already worked this out. Oops. :-)
>
> Paul
>
> On Thu, Oct 16, 2008 at 7:56 AM, David Smith <DMS at viewpointusa.com> wrote:
>> I'd appreciate someone looking at before 2.0.6 released
>>
>> (I posted this back on Aug 1, 2008)
>>
>> OrderedByRowComparator doesn't correctly handle negative numbers...
>>
>>
>> Thanks
>>
>> Dave Smith
>> Viewpoint Data Management, LLC
>>
>>
>>
>>
>> =============
>> Index: OrderByRowComparator.java
>> ===================================================================
>> --- OrderByRowComparator.java (revision 1118)
>> +++ OrderByRowComparator.java (working copy)
>> @@ -345,43 +345,37 @@
>> Node rdfNode = value;
>>
>> if (rdfNode instanceof Literal) {
>> +
>> String text = ((Literal) rdfNode).getLexicalForm();
>>
>> - // Check if the string is a number.
>> - int len = text.length();
>> - boolean isNumber = true;
>> - boolean hasDecimalPoint = false;
>> + if( text.length() > 0 )
>> + {
>> + char ch= text.charAt(0);
>>
>> - if (logger.isDebugEnabled()) {
>> + // if it smells like a numeric (and not a DateTime)
>> + //
>> + if( ((ch >= '0' && ch <= '9') || ch == '.' || ch == '+' || ch ==
>> '-' ) && !(text.indexOf('T') >= 0) )
>> + {
>> + Float f= Float.NaN;
>> + boolean isNumber= false;
>> + try
>> + {
>> + f= new Float(text);
>> + isNumber= true;
>> + }
>> + catch( NumberFormatException ex )
>> + {
>> + }
>>
>> - logger.debug("Checking if " + text + " is a number");
>> - }
>> + if( isNumber )
>> + {
>> + return f;
>> + }
>> + }
>> + }
>>
>> - // Check if the string is empty
>> - isNumber = len > 0;
>> -
>> - for (int i = 0; i < len; ++i) {
>> - char ch = text.charAt(i);
>> - if (ch == '.') {
>> - if (hasDecimalPoint) {
>> - // A number can't have two decimal points.
>> - isNumber = false;
>> - break;
>> - }
>> -
>> - hasDecimalPoint = true;
>> - } else if ( (ch < '0') || (ch > '9')) {
>> - // A char which is not a digit.
>> - isNumber = false;
>> - break;
>> - }
>> - }
>> -
>> - if (isNumber) {
>> - return new Float(text);
>> - }
>> -
>> return text;
>> +
>> } else if (rdfNode instanceof URIReference) {
>> return ((URIReference) rdfNode).getURI().toString();
>> } else if (rdfNode instanceof BlankNode) {
>>
>>
>> =============
>>
>> create <rmi://dmstablet2.viewpoint.local/server1#sampledata>;
>> create <rmi://dmstablet2.viewpoint.local/server1#xsd>
>> <http://mulgara.org/mulgara#XMLSchemaModel>;
>>
>> delete
>> select $s <urn:aValue> $o
>> from <rmi://dmstablet2.viewpoint.local/server1#sampledata>
>> where
>> $s <urn:aValue> $o
>> from <rmi://dmstablet2.viewpoint.local/server1#sampledata>
>>
>> ;
>>
>> insert
>> <urn:0001> <urn:aValue>
>> '9000.0'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '-80.0'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '-8.8887'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '-8.00'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '6000'^^<http://www.w3.org/2001/XMLSchema#int>
>> <urn:0001> <urn:aValue>
>> '444'^^<http://www.w3.org/2001/XMLSchema#int>
>> <urn:0001> <urn:aValue>
>> '40.0'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '4.0'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '-11.0'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '-11.1'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '1'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '-1'^^<http://www.w3.org/2001/XMLSchema#double>
>> <urn:0001> <urn:aValue>
>> '11'^^<http://www.w3.org/2001/XMLSchema#double>
>>
>>
>> into <rmi://dmstablet2.viewpoint.local/server1#sampledata> ;
>>
>> select $s <urn:aValue> $o
>> from <rmi://dmstablet2.viewpoint.local/server1#sampledata>
>> where
>> $s <urn:aValue> $o
>>
>> ;
>>
>>
>> select $s <urn:aValue> $o
>> from <rmi://dmstablet2.viewpoint.local/server1#sampledata>
>> where
>> $s <urn:aValue> $o
>>
>> order by $o asc
>>
>> ;
>>
>> select $s <urn:aValue> $o
>> from <rmi://dmstablet2.viewpoint.local/server1#sampledata>
>> where
>> $s <urn:aValue> $o
>>
>> order by $o desc
>>
>> ;
>>
>>
>> select $s <urn:aValue> $o
>> from <rmi://dmstablet2.viewpoint.local/server1#sampledata>
>> where
>> $s <urn:aValue> $o and
>> $o <http://mulgara.org/mulgara#lt>
>> '-1'^^<http://www.w3.org/2001/XMLSchema#double> in
>> <rmi://dmstablet2.viewpoint.local/server1#xsd>
>>
>> ;
>>
>> select $s <urn:aValue> $o
>> from <rmi://dmstablet2.viewpoint.local/server1#sampledata>
>> where
>> $s <urn:aValue> $o and
>> $o <http://mulgara.org/mulgara#lt>
>> '7000'^^<http://www.w3.org/2001/XMLSchema#double> in
>> <rmi://dmstablet2.viewpoint.local/server1#xsd>
>>
>> ;
>>
>> =============
>> _______________________________________________
>> Mulgara-dev mailing list
>> Mulgara-dev at mulgara.org
>> http://mulgara.org/mailman/listinfo/mulgara-dev
>>
>
More information about the Mulgara-dev
mailing list