From: Rohit M on 5 May 2010 11:58 Hello All, Need advice in a TCL performance area. So basically I have a tree (with large number of rows ~100K) for which very frequently I need to get the count of different "status" values. The status values are known and a finite set of around 10. Here is the code, can it be improved further using any tree functions directly? The $_tree here is a wrapper built over BLT Tree and I have all the function available as listed here http://man-wiki.net/index.php/N:blt_hiertable # Reset valueCounts foreach value [array names _valueCounts] { set _valueCounts($value) 0 } # Iterate through the tree to create count for each status foreach id [$_tree find 0] { set summary [$_tree get $id hstatus] if {$summary != "" } { incr _valueCounts($summary) } } Thanks in advance for you help. Rohit
From: Rohit M on 10 May 2010 04:21 On May 5, 8:58 pm, Rohit M <rohit.marka...(a)gmail.com> wrote: > Hello All, > Need advice in a TCL performance area. So basically I have a > tree > (with large number of rows ~100K) for which very frequently I need to > get the count of different "status" values. The status values are > known > and a finite set of around 10. Here is the code, can it be improved > further using any tree functions directly? > > The $_tree here is a wrapper built over BLT Tree and I have all the > function available > as listed herehttp://man-wiki.net/index.php/N:blt_hiertable > > # Reset valueCounts > foreach value [array names _valueCounts] { > set _valueCounts($value) 0 > } > > # Iterate through the tree to create count for each status > foreach id [$_tree find 0] { > set summary [$_tree get $id hstatus] > > if {$summary != "" } { > incr _valueCounts($summary) > } > } > > Thanks in advance for you help. > Rohit Bumping up for responses. thanks Rohit
From: Rohit M on 10 May 2010 09:41 On May 10, 1:21 pm, Rohit M <rohit.marka...(a)gmail.com> wrote: > On May 5, 8:58 pm, Rohit M <rohit.marka...(a)gmail.com> wrote: > > > > > Hello All, > > Need advice in a TCL performance area. So basically I have a > > tree > > (with large number of rows ~100K) for which very frequently I need to > > get the count of different "status" values. The status values are > > known > > and a finite set of around 10. Here is the code, can it be improved > > further using any tree functions directly? > > > The $_tree here is a wrapper built over BLT Tree and I have all the > > function available > > as listed herehttp://man-wiki.net/index.php/N:blt_hiertable > > > # Reset valueCounts > > foreach value [array names _valueCounts] { > > set _valueCounts($value) 0 > > } > > > # Iterate through the tree to create count for each status > > foreach id [$_tree find 0] { > > set summary [$_tree get $id hstatus] > > > if {$summary != "" } { > > incr _valueCounts($summary) > > } > > } > > > Thanks in advance for you help. > > Rohit > > Bumping up for responses. > thanks > Rohit Ol let me rephrase this question, can I do an AND operation for three different parameters in the "find" operation of BLT Tree? 1) I want only top level nodes (this tree has two levels after root) 2) I want only visible nodes (ishidden will work as will getting the tag "hide") 3) I want count of different "hstatus" values for ABOVE 2 parameters (which are an finite set of 6 different values, let us say Status1, Status2 ... ) So in effect I want something like this but I dont this is possible: find children root -key -exact "hide " and -key -exact "Status1" Is there another way around? thanks again in advance. Rohit
From: Uwe Klein on 10 May 2010 10:19 Rohit M wrote: > So in effect I want something like this but I dont this is possible: > > find children root -key -exact "hide " and -key -exact "Status1" > > Is there another way around? > > thanks again in advance. > Rohit > the find subcommand supports a variety of options. Have you looked at the manpage? forex: http://www.digipedia.pl/man/doc/view/blt_tree.n/ treeName find node ?switches? Finds for all nodes matching the criteria given by switches for the subtree designated by node. A list of the selected nodes is returned. By default all nodes match, but you can set switches to narrow the match. The -exact, -glob, and -regexp switches indicate both what kind of pattern matching to perform and the pattern. By default each pattern will be com pared with the node label. You can set more than one of these switches. If any of the patterns match (logical or), the node matches. If the -key switch is used, it designates the data field to be matched. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The order in which the nodes are traversed is con trolled by the -order switch. The possible order ings are preorder, postorder, inorder, and breadth first. The default is postorder. The valid switches are listed below: uwe
From: Rohit M on 11 May 2010 07:24
On May 10, 7:19 pm, Uwe Klein <uwe_klein_habertw...(a)t-online.de> wrote: > Rohit M wrote: > > So in effect I want something like this but I dont this is possible: > > > find children root -key -exact "hide " and -key -exact "Status1" > > > Is there another way around? > > > thanks again in advance. > > Rohit > > the find subcommand supports a variety of options. > > Have you looked at the manpage? > > forex:http://www.digipedia.pl/man/doc/view/blt_tree.n/ > > treeName find node ?switches? > Finds for all nodes matching the criteria given by switches for the subtree designated by node. A > list of the selected nodes is returned. By default all nodes match, but you can set switches to > narrow the match. > > The -exact, -glob, and -regexp switches indicate both what kind of pattern matching to perform and > the pattern. By default each pattern will be com pared with the node label. You can set more than > one of these switches. If any of the patterns match (logical or), the node matches. If the -key > switch is used, it designates the data field to be matched. > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > The order in which the nodes are traversed is con trolled by the -order switch. The possible order > ings are preorder, postorder, inorder, and breadth first. The default is postorder. > > The valid switches are listed below: > > uwe Thanks Uwe, I did go through the manpage and as you can see it says following: "You can set more than one of these switches. If any of the patterns match (logical or), the node matches." I want it to do a logical and instead of an or that it does. I can workaround this with "exec" switch i.e. using a tcl function, but that again slows down my function a lot. |