You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Jakob Homan (JIRA)" <ji...@apache.org> on 2008/08/02 00:55:31 UTC

[jira] Updated: (ZOOKEEPER-44) DataTree does not use natural sort for getChildren

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

Jakob Homan updated ZOOKEEPER-44:
---------------------------------

    Status: Patch Available  (was: Open)

I've gone ahead and implemented the patch as discussed, which does the following:
   * Implements the padding for sequential file names, padding ten zeroes to the name (enough to handle as many digits as can be generated by a 32-bit int).  This allows the names to be sorted by natural order.
   * Removed the server sorting the list of children, leaving it up to the client to do so if it wishes.  This could give a very slight performance bump, particularly when dealing with directories with a large number of files.
   * Updated the Javadoc to reflect this change in both versions of the getChildren method.
   * Adds a unit test that checks that the sequential file names are being created correctly.

I thought about adding a GetChildrenSorted or such method, but since it's really easy for the client to sort the list once returned (java.Collections.List.Sort(children)), it seems like it would be more work to add and support these methods.
 
Hope this is useful.

> DataTree does not use natural sort for getChildren
> --------------------------------------------------
>
>                 Key: ZOOKEEPER-44
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-44
>             Project: Zookeeper
>          Issue Type: Improvement
>          Components: server
>    Affects Versions: 3.0.0
>            Reporter: Stu Hood
>            Assignee: Benjamin Reed
>            Priority: Minor
>             Fix For: 3.0.0
>
>
> DataTree.getChildren() performs Collection.sort() on the list of children before returning it, but Java's default comparator for Strings will sort 'lock-20' before 'lock-3' for instance. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.