Fossil SCM

Added ability to declare indices on tables in the persistent state. Used this to declare indices on critical columns. Slows down the transactions saving changesets, this however is made up when it comes to successor/predecessor retrieval of changesets.

aku 2007-12-02 03:40 trunk
Commit 74854a30b8b4cc44a19fc8e305768fac8c536a14
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -174,11 +174,13 @@
174174
fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
175175
lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
176176
sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag
177177
178178
rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged.
179
- }
179
+ } { rev sid }
180
+ # Indices on: rev (revision successors)
181
+ # sid (tag predecessors, branch successors/predecessors)
180182
181183
state writing branch {
182184
bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
183185
fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
184186
lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
@@ -193,11 +195,14 @@
193195
-- only revision on trunk is the unnecessary dead one the
194196
-- branch was sprouted from and it has commits. The branch
195197
-- will exist to be the LOD of its revisions, nothing to
196198
-- sprout from, the dead revision was removed, hence no
197199
-- root.
198
- }
200
+ } { root first sid }
201
+ # Indices on: root (revision successors)
202
+ # first (revision predecessors)
203
+ # sid (tag predecessors, branch successors/predecessors)
199204
200205
# Project level ...
201206
# pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
202207
#
203208
# pTrunk <- pLineOfDevelopment
204209
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -174,11 +174,13 @@
174 fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
175 lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
176 sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag
177
178 rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged.
179 }
 
 
180
181 state writing branch {
182 bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
183 fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
184 lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
@@ -193,11 +195,14 @@
193 -- only revision on trunk is the unnecessary dead one the
194 -- branch was sprouted from and it has commits. The branch
195 -- will exist to be the LOD of its revisions, nothing to
196 -- sprout from, the dead revision was removed, hence no
197 -- root.
198 }
 
 
 
199
200 # Project level ...
201 # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
202 #
203 # pTrunk <- pLineOfDevelopment
204
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -174,11 +174,13 @@
174 fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
175 lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
176 sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag
177
178 rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged.
179 } { rev sid }
180 # Indices on: rev (revision successors)
181 # sid (tag predecessors, branch successors/predecessors)
182
183 state writing branch {
184 bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
185 fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
186 lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
@@ -193,11 +195,14 @@
195 -- only revision on trunk is the unnecessary dead one the
196 -- branch was sprouted from and it has commits. The branch
197 -- will exist to be the LOD of its revisions, nothing to
198 -- sprout from, the dead revision was removed, hence no
199 -- root.
200 } { root first sid }
201 # Indices on: root (revision successors)
202 # first (revision predecessors)
203 # sid (tag predecessors, branch successors/predecessors)
204
205 # Project level ...
206 # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
207 #
208 # pTrunk <- pLineOfDevelopment
209
--- tools/cvs2fossil/lib/c2f_pcollsym.tcl
+++ tools/cvs2fossil/lib/c2f_pcollsym.tcl
@@ -55,11 +55,12 @@
5555
-- forest in case of multiple projects, with one tree per
5656
-- project.
5757
5858
sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol,
5959
pid INTEGER NOT NULL REFERENCES symbol
60
- }
60
+ } { pid }
61
+ # Index on: pid (branch successors`)
6162
return
6263
}
6364
6465
typemethod load {} {
6566
# Pass manager interface. Executed to load data computed by
6667
--- tools/cvs2fossil/lib/c2f_pcollsym.tcl
+++ tools/cvs2fossil/lib/c2f_pcollsym.tcl
@@ -55,11 +55,12 @@
55 -- forest in case of multiple projects, with one tree per
56 -- project.
57
58 sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol,
59 pid INTEGER NOT NULL REFERENCES symbol
60 }
 
61 return
62 }
63
64 typemethod load {} {
65 # Pass manager interface. Executed to load data computed by
66
--- tools/cvs2fossil/lib/c2f_pcollsym.tcl
+++ tools/cvs2fossil/lib/c2f_pcollsym.tcl
@@ -55,11 +55,12 @@
55 -- forest in case of multiple projects, with one tree per
56 -- project.
57
58 sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol,
59 pid INTEGER NOT NULL REFERENCES symbol
60 } { pid }
61 # Index on: pid (branch successors`)
62 return
63 }
64
65 typemethod load {} {
66 # Pass manager interface. Executed to load data computed by
67
--- tools/cvs2fossil/lib/c2f_state.tcl
+++ tools/cvs2fossil/lib/c2f_state.tcl
@@ -93,20 +93,28 @@
9393
if {$mypath eq ""} return
9494
file delete $mypath
9595
return
9696
}
9797
98
- typemethod writing {name definition} {
98
+ typemethod writing {name definition {indices {}}} {
9999
# Method for a user to declare a table its needs for storing
100100
# persistent state, and the expected structure. A possibly
101101
# previously existing definition is dropped.
102102
103103
log write 1 state "writing $name" ; # TODO move to level 5 or so
104104
105105
$mystate transaction {
106106
catch { $mystate eval "DROP TABLE $name" }
107107
$mystate eval "CREATE TABLE $name ( $definition )"
108
+
109
+ set id 0
110
+ foreach columns $indices {
111
+ log write 1 state "index $name$id" ; # TODO move to level 5 or so
112
+
113
+ $mystate eval "CREATE INDEX ${name}$id ON ${name} ( [join $columns ,] )"
114
+ incr id
115
+ }
108116
}
109117
return
110118
}
111119
112120
typemethod reading {name} {
113121
--- tools/cvs2fossil/lib/c2f_state.tcl
+++ tools/cvs2fossil/lib/c2f_state.tcl
@@ -93,20 +93,28 @@
93 if {$mypath eq ""} return
94 file delete $mypath
95 return
96 }
97
98 typemethod writing {name definition} {
99 # Method for a user to declare a table its needs for storing
100 # persistent state, and the expected structure. A possibly
101 # previously existing definition is dropped.
102
103 log write 1 state "writing $name" ; # TODO move to level 5 or so
104
105 $mystate transaction {
106 catch { $mystate eval "DROP TABLE $name" }
107 $mystate eval "CREATE TABLE $name ( $definition )"
 
 
 
 
 
 
 
 
108 }
109 return
110 }
111
112 typemethod reading {name} {
113
--- tools/cvs2fossil/lib/c2f_state.tcl
+++ tools/cvs2fossil/lib/c2f_state.tcl
@@ -93,20 +93,28 @@
93 if {$mypath eq ""} return
94 file delete $mypath
95 return
96 }
97
98 typemethod writing {name definition {indices {}}} {
99 # Method for a user to declare a table its needs for storing
100 # persistent state, and the expected structure. A possibly
101 # previously existing definition is dropped.
102
103 log write 1 state "writing $name" ; # TODO move to level 5 or so
104
105 $mystate transaction {
106 catch { $mystate eval "DROP TABLE $name" }
107 $mystate eval "CREATE TABLE $name ( $definition )"
108
109 set id 0
110 foreach columns $indices {
111 log write 1 state "index $name$id" ; # TODO move to level 5 or so
112
113 $mystate eval "CREATE INDEX ${name}$id ON ${name} ( [join $columns ,] )"
114 incr id
115 }
116 }
117 return
118 }
119
120 typemethod reading {name} {
121

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button