Thread: K5 JBPatch
View Single Post
Old 09-04-2012, 08:46 AM   #639
knc1
Embedded Cheerleader
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 5,766
Karma: 5722276
Join Date: Feb 2012
Device: Too many.
Does the system allow you to write to that database?

Store the partial total of the number of leaves at each collection node (like storing the number of files at each directory node) as you traverse back up the collection tree.

When modify the collection tree, invalidate the node partial totals in that path as part of the process.

That way, you only have to recursively update the parts of the collection tree that happen to be invalid when you need the leaf and branch count(s).
Otherwise, the expansive traverse and count has already been done, just collect sub-totals as deep as required at the moment.
knc1 is offline   Reply With Quote