Overview
SHA1 Hash: | 6559f3231e6964c3beed30174498639c6670a557 |
---|---|
Date: | 2008-02-24 04:43:56 |
User: | aku |
Comment: | New command 'state foreachrow' for incremental result processing, using less memory. Converted a number of places in pass InitCSet to this command, and marked a number of othre places for possible future use. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified tools/cvs2fossil/lib/c2f_pinitcsets.tcl from [37791a272d] to [14fdb6d32b].
@@ -195,19 +195,22 @@ # on the csets. Doing it like this, late creation, means # less such calls. None, but the creation itself. log write 14 initcsets meta_begin mem::mark - foreach {mid rid pid} [state run { - SELECT M.mid, R.rid, M.pid - FROM revision R, meta M -- R ==> M, using PK index of M. + state foreachrow { + SELECT M.mid AS xmid, + R.rid AS xrid, + M.pid AS xpid + FROM revision R, + meta M -- R ==> M, using PK index of M. WHERE R.mid = M.mid ORDER BY M.mid, R.date - }] { + } { log write 14 initcsets meta_next - if {$lastmeta != $mid} { + if {$lastmeta != $xmid} { if {[llength $revisions]} { incr n set p [repository projectof $lastproject] log write 14 initcsets meta_cset_begin mem::mark @@ -218,14 +221,14 @@ $cset destroy foreach cset $spawned { $cset persist ; $cset destroy } mem::mark set revisions {} } - set lastmeta $mid - set lastproject $pid + set lastmeta $xmid + set lastproject $xpid } - lappend revisions $rid + lappend revisions $xrid } if {[llength $revisions]} { incr n set p [repository projectof $lastproject] @@ -266,29 +269,32 @@ set lastsymbol {} set lastproject {} set tags {} - foreach {sid tid pid} [state run { - SELECT S.sid, T.tid, S.pid - FROM tag T, symbol S -- T ==> R/S, using PK indices of R, S. + state foreachrow { + SELECT S.sid AS xsid, + T.tid AS xtid, + S.pid AS xpid + FROM tag T, + symbol S -- T ==> R/S, using PK indices of R, S. WHERE T.sid = S.sid ORDER BY S.sid, T.tid - }] { - if {$lastsymbol != $sid} { + } { + if {$lastsymbol != $xsid} { if {[llength $tags]} { incr n set p [repository projectof $lastproject] set cset [project::rev %AUTO% $p sym::tag $lastsymbol $tags] set tags {} $cset persist $cset destroy } - set lastsymbol $sid - set lastproject $pid + set lastsymbol $xsid + set lastproject $xpid } - lappend tags $tid + lappend tags $xtid } if {[llength $tags]} { incr n set p [repository projectof $lastproject] @@ -299,29 +305,32 @@ set lastsymbol {} set lasproject {} set branches {} - foreach {sid bid pid} [state run { - SELECT S.sid, B.bid, S.pid - FROM branch B, symbol S -- B ==> R/S, using PK indices of R, S. + state foreachrow { + SELECT S.sid AS xsid, + B.bid AS xbid, + S.pid AS xpid + FROM branch B, + symbol S -- B ==> R/S, using PK indices of R, S. WHERE B.sid = S.sid ORDER BY S.sid, B.bid - }] { - if {$lastsymbol != $sid} { + } { + if {$lastsymbol != $xsid} { if {[llength $branches]} { incr n set p [repository projectof $lastproject] set cset [project::rev %AUTO% $p sym::branch $lastsymbol $branches] set branches {} $cset persist $cset destroy } - set lastsymbol $sid - set lastproject $pid + set lastsymbol $xsid + set lastproject $xpid } - lappend branches $bid + lappend branches $xbid } if {[llength $branches]} { incr n set p [repository projectof $lastproject]
Modified tools/cvs2fossil/lib/c2f_prev.tcl from [53853a44a2] to [f8ed1ba0f8].
@@ -116,10 +116,12 @@ # new data. state run { DELETE FROM cssuccessor WHERE cid = $myid; } set loop 0 + # TODO: Check other uses of cs_sucessors. + # TODO: Consider merging cs_sucessor's SELECT with the INSERT here. foreach nid [$mytypeobj cs_successors $myitems] { state run { INSERT INTO cssuccessor (cid, nid) VALUES ($myid,$nid) } @@ -323,10 +325,11 @@ } proc Getrevisioninfo {revisions} { set theset ('[join $revisions {','}]') set revisions {} + #foreachrow foreach {frid path fname revnr rop} [state run [subst -nocommands -nobackslashes { SELECT U.uuid, F.visible, F.name, R.rev, R.op FROM revision R, revuuid U, file F WHERE R.rid IN $theset -- All specified revisions AND U.rid = R.rid -- get fossil uuid of revision @@ -581,10 +584,11 @@ # the order given to them by the sort passes. Both the # filtering by project and sorting make use of 'project::rev # rev' impossible. set res {} + #foreachrow foreach {cid cdate} [state run { SELECT C.cid, T.date FROM changeset C, cstimestamp T WHERE C.type = 0 -- limit to revision changesets AND C.pid = $projectid -- limit to changesets in project @@ -595,27 +599,30 @@ } return $res } typemethod getcstypes {} { - foreach {tid name} [state run { + state foreachrow { SELECT tid, name FROM cstype; - }] { set mycstype($name) $tid } + } { set mycstype($name) $tid } return } typemethod load {repository} { set n 0 log write 2 csets {Loading the changesets} - foreach {id pid cstype srcid} [state run { - SELECT C.cid, C.pid, CS.name, C.src + state foreachrow { + SELECT C.cid AS id, + C.pid AS xpid, + CS.name AS cstype, + C.src AS srcid FROM changeset C, cstype CS WHERE C.type = CS.tid ORDER BY C.cid - }] { + } { log progress 2 csets $n {} - set r [$type %AUTO% [$repository projectof $pid] $cstype $srcid [state run { + set r [$type %AUTO% [$repository projectof $xpid] $cstype $srcid [state run { SELECT C.iid FROM csitem C WHERE C.cid = $id ORDER BY C.pos }] $id] @@ -892,10 +899,11 @@ array set delta {} array set stamp {} set theset ('[join $revisions {','}]') + #foreachrow foreach {rid time} [state run [subst -nocommands -nobackslashes { SELECT R.rid, R.date FROM revision R WHERE R.rid IN $theset }]] { @@ -1162,39 +1170,39 @@ # revisions we start from. Sensible as we are looking for # changeset internal dependencies. array set dep {} - foreach {rid child} [state run [subst -nocommands -nobackslashes { + state foreachrow [subst -nocommands -nobackslashes { -- (1) Primary child - SELECT R.rid, R.child + SELECT R.rid AS xrid, R.child AS xchild FROM revision R WHERE R.rid IN $theset -- Restrict to revisions of interest AND R.child IS NOT NULL -- Has primary child AND R.child IN $theset -- Which is also of interest UNION -- (2) Secondary (branch) children - SELECT R.rid, B.brid + SELECT R.rid AS xrid, B.brid AS xchild FROM revision R, revisionbranchchildren B WHERE R.rid IN $theset -- Restrict to revisions of interest AND R.rid = B.rid -- Select subset of branch children AND B.brid IN $theset -- Which is also of interest UNION -- (4) Child of trunk root successor of last NTDB on trunk. - SELECT R.rid, RA.child + SELECT R.rid AS xrid, RA.child AS xchild FROM revision R, revision RA WHERE R.rid IN $theset -- Restrict to revisions of interest AND R.isdefault -- Restrict to NTDB AND R.dbchild IS NOT NULL -- and last NTDB belonging to trunk AND RA.rid = R.dbchild -- Go directly to trunk root AND RA.child IS NOT NULL -- Has primary child. AND RA.child IN $theset -- Which is also of interest - }]] { + }] { # Consider moving this to the integrity module. - integrity assert {$rid != $child} {Revision $rid depends on itself.} - lappend dependencies($rid) $child - set dep($rid,$child) . + integrity assert {$xrid != $xchild} {Revision $xrid depends on itself.} + lappend dependencies($xrid) $xchild + set dep($xrid,$xchild) . } # The sql statements above looks only for direct dependencies # between revision in the changeset. However due to the # vagaries of meta data it is possible for two revisions of @@ -1220,15 +1228,15 @@ log write 14 csets {internal [array size dep]} log write 14 csets {collected [array size dependencies]} log write 14 csets pseudo-internalsuccessors array set fids {} - foreach {rid fid} [state run [subst -nocommands -nobackslashes { - SELECT R.rid, R.fid + state foreachrow [subst -nocommands -nobackslashes { + SELECT R.rid AS xrid, R.fid AS xfid FROM revision R WHERE R.rid IN $theset - }]] { lappend fids($fid) $rid } + }] { lappend fids($xfid) $xrid } set groups {} foreach {fid rids} [array get fids] { if {[llength $rids] < 2} continue foreach a $rids { @@ -1318,10 +1326,11 @@ # '1.2' revision) is a successor, if it exists. # Note that the branches spawned from the revisions, and the # tags associated with them are successors as well. + #foreachrow foreach {rid child} [state run [subst -nocommands -nobackslashes { -- (1) Primary child SELECT R.rid, R.child FROM revision R WHERE R.rid IN $theset -- Restrict to revisions of interest @@ -1344,18 +1353,20 @@ }]] { # Consider moving this to the integrity module. integrity assert {$rid != $child} {Revision $rid depends on itself.} lappend dependencies([list rev $rid]) [list rev $child] } + #foreachrow foreach {rid child} [state run [subst -nocommands -nobackslashes { SELECT R.rid, T.tid FROM revision R, tag T WHERE R.rid IN $theset -- Restrict to revisions of interest AND T.rev = R.rid -- Select tags attached to them }]] { lappend dependencies([list rev $rid]) [list sym::tag $child] } + #foreachrow foreach {rid child} [state run [subst -nocommands -nobackslashes { SELECT R.rid, B.bid FROM revision R, branch B WHERE R.rid IN $theset -- Restrict to revisions of interest AND B.root = R.rid -- Select branches attached to them @@ -1570,27 +1581,30 @@ # The first revision committed on a branch, and all branches # and tags which have it as their prefered parent are the # successors of a branch. set theset ('[join $branches {','}]') + #foreachrow foreach {bid child} [state run [subst -nocommands -nobackslashes { SELECT B.bid, R.rid FROM branch B, revision R WHERE B.bid IN $theset -- Restrict to branches of interest AND B.first = R.rid -- Get first revision on the branch }]] { lappend dependencies([list sym::branch $bid]) [list rev $child] } + #foreachrow foreach {bid child} [state run [subst -nocommands -nobackslashes { SELECT B.bid, BX.bid FROM branch B, preferedparent P, branch BX WHERE B.bid IN $theset -- Restrict to branches of interest AND B.sid = P.pid -- Get subordinate branches via the AND BX.sid = P.sid -- prefered parents of their symbols }]] { lappend dependencies([list sym::branch $bid]) [list sym::branch $child] } + #foreachrow foreach {bid child} [state run [subst -nocommands -nobackslashes { SELECT B.bid, T.tid FROM branch B, preferedparent P, tag T WHERE B.bid IN $theset -- Restrict to branches of interest AND B.sid = P.pid -- Get subordinate tags via the
Modified tools/cvs2fossil/lib/c2f_state.tcl from [b7329274e1] to [98813ec9b6].
@@ -157,10 +157,16 @@ } typemethod run {args} { Save $args return [uplevel 1 [linsert $args 0 $mystate eval]] + } + + typemethod foreachrow {sql script} { + Save $sql + uplevel 1 [list $mystate eval $sql $script] + return } typemethod one {args} { Save $args return [uplevel 1 [linsert $args 0 $mystate onecolumn]]