[dev] DataTree::get sorted

Duck duck at obala.net
Sun Apr 10 11:13:40 PDT 2005


--Boundary-00=_UzWWCjekvDf0dM8
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

The patch brigs the attribute sorting capability to the DataTree::get(). 

At first I meet to link the get method to getSortedTree() but I left this 
idea.  While I  was there I added the from/count parameters to it. Just if 
some will have the need  to get the SQL results of portion of a (sorted) DT. 
Maybe to handle it in his own application. Since this method is not 
implemented any where in actual horde apps the insertion of the two 
parameters wont break anything.

So lets get to the actual sorting.
I hope I moved in the right direction.

1.  I added the standard 3 sorting parameters to _load() and get()
2.  Than I added an _sortHash class variable to handle the sorting parameters 
of the get call. The hash is created the by a new method DataTree::sortHash()
3. The DataTree::set() is changed to store the sorting position in the _data 
array in the way that we can have multiply sorting of the same objects/tree. 
The _load call will be skipped if the sorting hash already exists.
4. Then another new method _cmpSorted() is used in _extractOneLevel() to sort 
the tree if the _sortHash is set.

And this is all. If get() is called without the sorting parameters (the 
_sortHash is not set) all will act as before. 

To show how it works, I attached a patch to the Agora Messages too. It 
eliminates the double DB access of get() and sortByAttributes() with only one 
"new" get() call.

Comments?

Duck

--Boundary-00=_UzWWCjekvDf0dM8
Content-Disposition: attachment;
	filename="sql.diff"
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

A non-text attachment was scrubbed...
Name: sql.diff
Type: text/x-diff
Size: 3954 bytes
Desc: not available
Url : http://lists.horde.org/archives/dev/attachments/20050410/35795cdd/sql-0001.bin

--Boundary-00=_UzWWCjekvDf0dM8
Content-Disposition: attachment;
	filename="dataTree.diff"
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

A non-text attachment was scrubbed...
Name: dataTree.diff
Type: text/x-diff
Size: 7787 bytes
Desc: not available
Url : http://lists.horde.org/archives/dev/attachments/20050410/35795cdd/dataTree-0001.bin

--Boundary-00=_UzWWCjekvDf0dM8
Content-Disposition: attachment;
	filename="Messages.diff"
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

A non-text attachment was scrubbed...
Name: Messages.diff
Type: text/x-diff
Size: 1424 bytes
Desc: not available
Url : http://lists.horde.org/archives/dev/attachments/20050410/35795cdd/Messages-0001.bin

--Boundary-00=_UzWWCjekvDf0dM8--


More information about the dev mailing list