[llvm-commits] [zorg] r146789 - in /zorg/trunk/lnt/lnt/server/db: testsuite.py testsuitedb.py
Daniel Dunbar
daniel at zuster.org
Fri Dec 16 16:12:22 PST 2011
Author: ddunbar
Date: Fri Dec 16 18:12:22 2011
New Revision: 146789
URL: http://llvm.org/viewvc/llvm-project?rev=146789&view=rev
Log:
[lnt/v0.4] lnt.server.db: Mark some fields as unique, and create indices where appropriate.
Modified:
zorg/trunk/lnt/lnt/server/db/testsuite.py
zorg/trunk/lnt/lnt/server/db/testsuitedb.py
Modified: zorg/trunk/lnt/lnt/server/db/testsuite.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/db/testsuite.py?rev=146789&r1=146788&r2=146789&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/db/testsuite.py (original)
+++ zorg/trunk/lnt/lnt/server/db/testsuite.py Fri Dec 16 18:12:22 2011
@@ -14,8 +14,8 @@
__tablename__ = 'SampleType'
id = Column("ID", Integer, primary_key=True)
- name = Column("Name", String(256))
+ name = Column("Name", String(256), unique=True)
def __init__(self, name):
self.name = name
@@ -26,7 +26,7 @@
__tablename__ = 'StatusKind'
id = Column("ID", Integer, primary_key=True)
- name = Column("Name", String(256))
+ name = Column("Name", String(256), unique=True)
def __init__(self, name):
self.name = name
@@ -38,7 +38,7 @@
__tablename__ = 'TestSuite'
id = Column("ID", Integer, primary_key=True)
- name = Column("Name", String(256))
+ name = Column("Name", String(256), unique=True)
db_key_name = Column("DBKeyName", String(256))
version = Column("Version", Integer)
@@ -60,7 +60,8 @@
__tablename__ = 'TestSuiteMachineFields'
id = Column("ID", Integer, primary_key=True)
- test_suite_id = Column("TestSuiteID", Integer, ForeignKey('TestSuite.ID'))
+ test_suite_id = Column("TestSuiteID", Integer, ForeignKey('TestSuite.ID'),
+ index=True)
name = Column("Name", String(256))
info_key = Column("InfoKey", String(256))
@@ -75,7 +76,8 @@
__tablename__ = 'TestSuiteOrderFields'
id = Column("ID", Integer, primary_key=True)
- test_suite_id = Column("TestSuiteID", Integer, ForeignKey('TestSuite.ID'))
+ test_suite_id = Column("TestSuiteID", Integer, ForeignKey('TestSuite.ID'),
+ index=True)
name = Column("Name", String(256))
info_key = Column("InfoKey", String(256))
ordinal = Column("Ordinal", Integer)
@@ -95,7 +97,8 @@
__tablename__ = 'TestSuiteRunFields'
id = Column("ID", Integer, primary_key=True)
- test_suite_id = Column("TestSuiteID", Integer, ForeignKey('TestSuite.ID'))
+ test_suite_id = Column("TestSuiteID", Integer, ForeignKey('TestSuite.ID'),
+ index=True)
name = Column("Name", String(256))
info_key = Column("InfoKey", String(256))
@@ -110,7 +113,8 @@
__tablename__ = 'TestSuiteSampleFields'
id = Column("ID", Integer, primary_key=True)
- test_suite_id = Column("TestSuiteID", Integer, ForeignKey('TestSuite.ID'))
+ test_suite_id = Column("TestSuiteID", Integer, ForeignKey('TestSuite.ID'),
+ index=True)
name = Column("Name", String(256))
type_id = Column("Type", Integer, ForeignKey('SampleType.ID'))
info_key = Column("InfoKey", String(256))
Modified: zorg/trunk/lnt/lnt/server/db/testsuitedb.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/db/testsuitedb.py?rev=146789&r1=146788&r2=146789&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/db/testsuitedb.py (original)
+++ zorg/trunk/lnt/lnt/server/db/testsuitedb.py Fri Dec 16 18:12:22 2011
@@ -23,7 +23,7 @@
__tablename__ = db_key_name + '_Machine'
id = Column("ID", Integer, primary_key=True)
- name = Column("Name", String(256))
+ name = Column("Name", String(256), index=True)
number = Column("Number", Integer)
parameters = Column("Parameters", Binary)
@@ -52,6 +52,9 @@
# Dynamically create fields for all of the test suite defined order
# fields.
+ #
+ # FIXME: We are probably going to want to index on some of these,
+ # but need a bit for that in the test suite definition.
class_dict = locals()
for item in test_suite.order_fields:
if item.name in class_dict:
@@ -71,8 +74,10 @@
__tablename__ = db_key_name + '_Run'
id = Column("ID", Integer, primary_key=True)
- machine_id = Column("MachineID", Integer, ForeignKey(Machine.id))
- order_id = Column("OrderID", Integer, ForeignKey(Order.id))
+ machine_id = Column("MachineID", Integer, ForeignKey(Machine.id),
+ index=True)
+ order_id = Column("OrderID", Integer, ForeignKey(Order.id),
+ index=True)
imported_from = Column("ImportedFrom", String(512))
start_time = Column("StartTime", DateTime)
end_time = Column("EndTime", DateTime)
@@ -83,6 +88,9 @@
# Dynamically create fields for all of the test suite defined run
# fields.
+ #
+ # FIXME: We are probably going to want to index on some of these,
+ # but need a bit for that in the test suite definition.
class_dict = locals()
for item in test_suite.run_fields:
if item.name in class_dict:
@@ -107,7 +115,7 @@
__tablename__ = db_key_name + '_Test'
id = Column("ID", Integer, primary_key=True)
- name = Column("Name", String(256))
+ name = Column("Name", String(256), unique=True, index=True)
def __init__(self, name):
self.name = name
@@ -120,8 +128,8 @@
__tablename__ = db_key_name + '_Sample'
id = Column("ID", Integer, primary_key=True)
- run_id = Column("RunID", Integer, ForeignKey(Run.id))
- test_id = Column("TestID", Integer, ForeignKey(Test.id))
+ run_id = Column("RunID", Integer, ForeignKey(Run.id), index=True)
+ test_id = Column("TestID", Integer, ForeignKey(Test.id), index=True)
run = sqlalchemy.orm.relation(Run)
test = sqlalchemy.orm.relation(Test)
@@ -159,6 +167,10 @@
self.Sample = Sample
self.Order = Order
+ # Create the compound index we cannot declare inline.
+ sqlalchemy.schema.Index("ix_Sample_RunID_TestID",
+ Sample.run_id, Sample.test_id)
+
# Create the test suite database tables in case this is a new database.
self.base.metadata.create_all(self.v4db.engine)
More information about the llvm-commits
mailing list