[ 
https://issues.apache.org/jira/browse/OAK-1763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13979454#comment-13979454
 ] 

Davide Giannella commented on OAK-1763:
---------------------------------------

Probably the best solution is to pass down to the
IndexStoreStrategy.update() the PropertyValue itself and leave it
decide what to do with it. The PropertyIndex (the base one) will
always call the encode from there while the OrderedIndex (extension of
Property) could decide to perform any other operation before encoding.

About the heuristic approach I was thinking something around the
following (typed straight and didn't tested. Could have errors)

{code}
// ...
static final Pattern number =
       Pattern.compile("^-?\\d+(\\.(0E)?\\d+)?$");
// ...
// key = "2.0E17"
if (number.matcher(key).matches()) {
   // it's a numeric stuff. Double should fit Integer and Double as well.
   // surround the following with try/catch
   Double d = new Double(key);
   // fetching the nodes from the index for comparison
   // value = <current-node-value>
   if (number.matcher(value).matches()) {
      // numeric with numeric
      Double v = new Double(value):
      if ( v.compareTo(d) > 0) {
         // ...
      }
      // ...
   }
} else {
  // any other string
}
{code}



> OrderedIndex does not comply with JCR's compareTo semantics
> -----------------------------------------------------------
>
>                 Key: OAK-1763
>                 URL: https://issues.apache.org/jira/browse/OAK-1763
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: core
>            Reporter: Michael Dürig
>
> The ordered index currently uses the lexicographical order of the string 
> representation of the values. This does not comply with [JCR's compareTo 
> sementics | 
> http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#3.6.5.1%20CompareTo%20Semantics]
>  for e.g. double values. 



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to