dbinit.py (2343:a2b4a6ccee56) dbinit.py (2665:a124942bacb8)
1# Copyright (c) 2003-2004 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 9 unchanged lines hidden (view full) ---

18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1# Copyright (c) 2003-2004 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 9 unchanged lines hidden (view full) ---

18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Nathan Binkert
26
27import MySQLdb
28
29class MyDB(object):
30 def __init__(self, options):
31 self.name = options.db
32 self.host = options.host
33 self.user = options.user

--- 59 unchanged lines hidden (view full) ---

93 rn_project VARCHAR(100) NOT NULL,
94 rn_date TIMESTAMP NOT NULL,
95 rn_expire TIMESTAMP NOT NULL,
96 PRIMARY KEY (rn_id),
97 UNIQUE (rn_name,rn_sample)
98 ) TYPE=InnoDB''')
99
100 #
28
29import MySQLdb
30
31class MyDB(object):
32 def __init__(self, options):
33 self.name = options.db
34 self.host = options.host
35 self.user = options.user

--- 59 unchanged lines hidden (view full) ---

95 rn_project VARCHAR(100) NOT NULL,
96 rn_date TIMESTAMP NOT NULL,
97 rn_expire TIMESTAMP NOT NULL,
98 PRIMARY KEY (rn_id),
99 UNIQUE (rn_name,rn_sample)
100 ) TYPE=InnoDB''')
101
102 #
103 # We keep the bin names separate so that the data table doesn't get
104 # huge since bin names are frequently repeated.
105 #
106 # COLUMNS:
107 # 'id' is the unique bin identifer.
108 # 'name' is the string name for the bin.
109 #
110 # INDEXES:
111 # 'bin' is indexed to get the name of a bin when data is retrieved
112 # via the data table.
113 # 'name' is indexed to get the bin id for a named bin when you want
114 # to search the data table based on a specific bin.
115 #
116 self.query('''
117 CREATE TABLE bins(
118 bn_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
119 bn_name VARCHAR(255) NOT NULL,
120 PRIMARY KEY(bn_id),
121 UNIQUE (bn_name)
122 ) TYPE=InnoDB''')
123
124 #
101 # The stat table gives us all of the data for a particular stat.
102 #
103 # COLUMNS:
104 # 'stat' is a unique identifier for each stat to be used in other
105 # tables for references.
106 # 'name' is simply the simulator derived name for a given
107 # statistic.
108 # 'descr' is the description of the statistic and what it tells

--- 84 unchanged lines hidden (view full) ---

193 # -5: maximum value
194 # -6: underflow
195 # -7: overflow
196 # 'y' is used by a VECTORDIST and the VECTOR2D to describe the second
197 # dimension.
198 # 'run' is the run that the data was generated from. Details up in
199 # the run table
200 # 'tick' is a timestamp generated by the simulator.
125 # The stat table gives us all of the data for a particular stat.
126 #
127 # COLUMNS:
128 # 'stat' is a unique identifier for each stat to be used in other
129 # tables for references.
130 # 'name' is simply the simulator derived name for a given
131 # statistic.
132 # 'descr' is the description of the statistic and what it tells

--- 84 unchanged lines hidden (view full) ---

217 # -5: maximum value
218 # -6: underflow
219 # -7: overflow
220 # 'y' is used by a VECTORDIST and the VECTOR2D to describe the second
221 # dimension.
222 # 'run' is the run that the data was generated from. Details up in
223 # the run table
224 # 'tick' is a timestamp generated by the simulator.
225 # 'bin' is the name of the bin that the data was generated in, if
226 # any.
201 # 'data' is the actual stat value.
202 #
203 # INDEXES:
204 # 'stat' is indexed so that a user can find all of the data for a
205 # particular stat. It is not unique, because that specific stat
227 # 'data' is the actual stat value.
228 #
229 # INDEXES:
230 # 'stat' is indexed so that a user can find all of the data for a
231 # particular stat. It is not unique, because that specific stat
206 # can be found in many runs and samples, in addition to
232 # can be found in many runs, bins, and samples, in addition to
207 # having entries for the mulidimensional cases.
208 # 'run' is indexed to allow a user to remove all of the data for a
209 # particular execution run. It can also be used to allow the
210 # user to print out all of the data for a given run.
211 #
212 self.query('''
213 CREATE TABLE data(
214 dt_stat SMALLINT UNSIGNED NOT NULL,
215 dt_x SMALLINT NOT NULL,
216 dt_y SMALLINT NOT NULL,
217 dt_run SMALLINT UNSIGNED NOT NULL,
218 dt_tick BIGINT UNSIGNED NOT NULL,
233 # having entries for the mulidimensional cases.
234 # 'run' is indexed to allow a user to remove all of the data for a
235 # particular execution run. It can also be used to allow the
236 # user to print out all of the data for a given run.
237 #
238 self.query('''
239 CREATE TABLE data(
240 dt_stat SMALLINT UNSIGNED NOT NULL,
241 dt_x SMALLINT NOT NULL,
242 dt_y SMALLINT NOT NULL,
243 dt_run SMALLINT UNSIGNED NOT NULL,
244 dt_tick BIGINT UNSIGNED NOT NULL,
245 dt_bin SMALLINT UNSIGNED NOT NULL,
219 dt_data DOUBLE NOT NULL,
220 INDEX (dt_stat),
221 INDEX (dt_run),
246 dt_data DOUBLE NOT NULL,
247 INDEX (dt_stat),
248 INDEX (dt_run),
222 UNIQUE (dt_stat,dt_x,dt_y,dt_run,dt_tick)
249 UNIQUE (dt_stat,dt_x,dt_y,dt_run,dt_tick,dt_bin)
223 ) TYPE=InnoDB;''')
224
225 #
226 # Names and descriptions for multi-dimensional stats (vectors, etc.)
227 # are stored here instead of having their own entry in the statistics
228 # table. This allows all parts of a single stat to easily share a
229 # single id.
230 #

--- 135 unchanged lines hidden (view full) ---

366
367 self.query('''
368 DELETE subdata
369 FROM subdata
370 LEFT JOIN data ON sd_stat=dt_stat
371 WHERE dt_stat IS NULL''')
372
373 self.query('''
250 ) TYPE=InnoDB;''')
251
252 #
253 # Names and descriptions for multi-dimensional stats (vectors, etc.)
254 # are stored here instead of having their own entry in the statistics
255 # table. This allows all parts of a single stat to easily share a
256 # single id.
257 #

--- 135 unchanged lines hidden (view full) ---

393
394 self.query('''
395 DELETE subdata
396 FROM subdata
397 LEFT JOIN data ON sd_stat=dt_stat
398 WHERE dt_stat IS NULL''')
399
400 self.query('''
401 DELETE bins
402 FROM bins
403 LEFT JOIN data ON bn_id=dt_bin
404 WHERE dt_bin IS NULL''')
405
406 self.query('''
374 DELETE events
375 FROM events
376 LEFT JOIN runs ON ev_run=rn_id
377 WHERE rn_id IS NULL''')
378
379 self.query('''
380 DELETE event_names
381 FROM event_names
382 LEFT JOIN events ON en_id=ev_event
383 WHERE ev_event IS NULL''')
407 DELETE events
408 FROM events
409 LEFT JOIN runs ON ev_run=rn_id
410 WHERE rn_id IS NULL''')
411
412 self.query('''
413 DELETE event_names
414 FROM event_names
415 LEFT JOIN events ON en_id=ev_event
416 WHERE ev_event IS NULL''')