CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
revisionDML Namespace Reference

Functions

def addEntry
 
def addRevision
 
def bookNewEntry
 
def bookNewRevision
 
def branchInfoByName
 
def branchType
 
def createBranch
 
def dataRevisionsOfEntry
 
def entryInBranch
 
def latestDataRevisionOfEntry
 
def revisionsInBranch
 
def revisionsInBranchName
 
def revisionsInTag
 

Variables

tuple databranchinfo = (branchid,'DATA')
 
tuple datainfo = createBranch(schema,'DATA','TRUNK',comment='hold data')
 
tuple entryinfo = (revision_id,entry_id,str(runnum),data_id)
 
tuple hltentryid = entryInBranch(schema,nameDealer.hltdataTableName(),str(runnum),'DATA')
 
tuple latestrevision = latestDataRevisionOfEntry(schema,nameDealer.lumidataTableName(),lumientry_id,revlist)
 
tuple lumientry_id = entryInBranch(schema,nameDealer.lumidataTableName(),'1211','DATA')
 
tuple lumientryid = entryInBranch(schema,nameDealer.lumidataTableName(),str(runnum),'DATA')
 
string myconstr = 'sqlite_file:test.db'
 
tuple norminfo = createBranch(schema,'NORM','TRUNK',comment='hold normalization factor')
 
tuple revisioninfo = bookNewRevision( schema,nameDealer.lumidataTableName() )
 
tuple revlist = revisionsInBranchName(schema,'DATA')
 
tuple schema = session.nominalSchema()
 
tuple session = svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
 
tuple svc = sessionManager.sessionManager(myconstr,debugON=False)
 
tuple tables = lumidbDDL.createTables(schema)
 
tuple trgentryid = entryInBranch(schema,nameDealer.trgdataTableName(),str(runnum),'DATA')
 
tuple trunkinfo = createBranch(schema,'TRUNK',None,comment='main')
 

Function Documentation

def revisionDML.addEntry (   schema,
  datatableName,
  entryinfo,
  branchinfo 
)
input:
    entryinfo (revision_id(0),entry_id(1),entry_name(2),data_id(3))
    branchinfo (branch_id,branch_name)
1.allocate and insert a new revision into the revisions table
2.allocate and insert a new entry into the entry table with the new revision
3.inset into data_rev table with new data_id ,revision)id mapping

insert into revisions(revision_id,branch_id,branch_name,comment,ctime) values()
insert into datatablename_entries (entry_id,revision_id) values()
insert into datatablename_rev(data_id,revision_id) values()

Definition at line 340 of file revisionDML.py.

References nameDealer.entryTableName(), nameDealer.revisionTableName(), and nameDealer.revmapTableName().

Referenced by CalibrationInterface< CategoryT, CalibDataT >.addCategoryDefinition(), TAPD.addEntry(), TMom.addEntry(), dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), dataDML.addTrgRunDataToBranch(), EcalMatacqAnalyzer.endJob(), and AlgorithmCalibration< T, CO >.readCategories().

341 def addEntry(schema,datatableName,entryinfo,branchinfo):
342  '''
343  input:
344  entryinfo (revision_id(0),entry_id(1),entry_name(2),data_id(3))
345  branchinfo (branch_id,branch_name)
346  1.allocate and insert a new revision into the revisions table
347  2.allocate and insert a new entry into the entry table with the new revision
348  3.inset into data_rev table with new data_id ,revision)id mapping
349 
350  insert into revisions(revision_id,branch_id,branch_name,comment,ctime) values()
351  insert into datatablename_entries (entry_id,revision_id) values()
352  insert into datatablename_rev(data_id,revision_id) values()
353  '''
354  try:
355  revisiontableName=nameDealer.revisionTableName()
356  entrytableName=nameDealer.entryTableName(datatableName)
357  revtableName=nameDealer.revmapTableName(datatableName)
358 
359  db=dbUtil.dbUtil(schema)
360  tabrowDefDict={}
361  tabrowDefDict['REVISION_ID']='unsigned long long'
362  tabrowDefDict['BRANCH_ID']='unsigned long long'
363  tabrowDefDict['BRANCH_NAME']='string'
364  tabrowDefDict['CTIME']='time stamp'
365  tabrowValueDict={}
366  tabrowValueDict['REVISION_ID']=entryinfo[0]
367  tabrowValueDict['BRANCH_ID']=branchinfo[0]
368  tabrowValueDict['BRANCH_NAME']=branchinfo[1]
369  tabrowValueDict['CTIME']=coral.TimeStamp()
370  db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
371 
372  tabrowDefDict={}
373  tabrowDefDict['REVISION_ID']='unsigned long long'
374  tabrowDefDict['ENTRY_ID']='unsigned long long'
375  tabrowDefDict['NAME']='string'
376 
377  tabrowValueDict={}
378  tabrowValueDict['REVISION_ID']=entryinfo[0]
379  tabrowValueDict['ENTRY_ID']=entryinfo[1]
380  tabrowValueDict['NAME']=entryinfo[2]
381  db.insertOneRow(entrytableName,tabrowDefDict,tabrowValueDict)
382 
383  tabrowDefDict={}
384  tabrowDefDict['REVISION_ID']='unsigned long long'
385  tabrowDefDict['DATA_ID']='unsigned long long'
386  tabrowValueDict={}
387  tabrowValueDict['REVISION_ID']=entryinfo[0]
388  tabrowValueDict['DATA_ID']=entryinfo[3]
389  db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
390  except:
391  raise
def revmapTableName
Definition: nameDealer.py:65
def revisionTableName
Definition: nameDealer.py:11
def entryTableName
Definition: nameDealer.py:68
def revisionDML.addRevision (   schema,
  datatableName,
  revisioninfo,
  branchinfo 
)
1.insert a new revision into the revisions table
2.insert into data_id, revision_id pair to  datatable_revmap
insert into revisions(revision_id,branch_id,branch_name,ctime) values()
insert into datatable_rev(data_id,revision_id) values())
input:
     revisioninfo (revision_id(0),data_id(1))
     branchinfo  (branch_id(0),branch_name(1))

Definition at line 392 of file revisionDML.py.

References nameDealer.revisionTableName(), and nameDealer.revmapTableName().

Referenced by dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), and dataDML.addTrgRunDataToBranch().

393 def addRevision(schema,datatableName,revisioninfo,branchinfo):
394  '''
395  1.insert a new revision into the revisions table
396  2.insert into data_id, revision_id pair to datatable_revmap
397  insert into revisions(revision_id,branch_id,branch_name,ctime) values()
398  insert into datatable_rev(data_id,revision_id) values())
399  input:
400  revisioninfo (revision_id(0),data_id(1))
401  branchinfo (branch_id(0),branch_name(1))
402  '''
403  try:
404  revisiontableName=nameDealer.revisionTableName()
405  revtableName=nameDealer.revmapTableName(datatableName)
406 
407  db=dbUtil.dbUtil(schema)
408  tabrowDefDict={}
409  tabrowDefDict['REVISION_ID']='unsigned long long'
410  tabrowDefDict['BRANCH_ID']='unsigned long long'
411  tabrowDefDict['BRANCH_NAME']='string'
412  tabrowDefDict['CTIME']='time stamp'
413 
414  tabrowValueDict={}
415  tabrowValueDict['REVISION_ID']=revisioninfo[0]
416  tabrowValueDict['BRANCH_ID']=branchinfo[0]
417  tabrowValueDict['BRANCH_NAME']=branchinfo[1]
418  tabrowValueDict['CTIME']=coral.TimeStamp()
419 
420  db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
421 
422  tabrowDefDict={}
423  tabrowDefDict['REVISION_ID']='unsigned long long'
424  tabrowDefDict['DATA_ID']='unsigned long long'
425  tabrowValueDict={}
426  tabrowValueDict['REVISION_ID']=revisioninfo[0]
427  tabrowValueDict['DATA_ID']=revisioninfo[1]
428  db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
429  except:
raise
def revmapTableName
Definition: nameDealer.py:65
def revisionTableName
Definition: nameDealer.py:11
def revisionDML.bookNewEntry (   schema,
  datatableName 
)
allocate new revision_id,entry_id,data_id

Definition at line 314 of file revisionDML.py.

References nameDealer.entryTableName(), and nameDealer.revisionTableName().

Referenced by dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), and dataDML.addTrgRunDataToBranch().

315 def bookNewEntry(schema,datatableName):
316  '''
317  allocate new revision_id,entry_id,data_id
318  '''
319  try:
320  entrytableName=nameDealer.entryTableName(datatableName)
321  iddealer=idDealer.idDealer(schema)
322  revision_id=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
323  data_id=iddealer.generateNextIDForTable( datatableName)
324  entry_id=iddealer.generateNextIDForTable( nameDealer.entryTableName(datatableName) )
325  return (revision_id,entry_id,data_id)
326  except:
327  raise
def revisionTableName
Definition: nameDealer.py:11
def entryTableName
Definition: nameDealer.py:68
def bookNewEntry
Definition: revisionDML.py:314
def revisionDML.bookNewRevision (   schema,
  datatableName 
)
allocate new revision_id,data_id

Definition at line 328 of file revisionDML.py.

References nameDealer.revisionTableName().

Referenced by dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), and dataDML.addTrgRunDataToBranch().

329 def bookNewRevision(schema,datatableName):
330  '''
331  allocate new revision_id,data_id
332  '''
333  try:
334  iddealer=idDealer.idDealer(schema)
335  revision_id=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
336  data_id=iddealer.generateNextIDForTable(datatableName)
337  return (revision_id,data_id)
338  except:
339  raise
def revisionTableName
Definition: nameDealer.py:11
def bookNewRevision
Definition: revisionDML.py:328
def revisionDML.branchInfoByName (   schema,
  branchName 
)
select (revision_id,branch_id) from revisions where name=:branchName

Definition at line 280 of file revisionDML.py.

References runTheMatrix.data, and nameDealer.revisionTableName().

Referenced by revisionsInBranchName().

281 def branchInfoByName(schema,branchName):
282  '''
283  select (revision_id,branch_id) from revisions where name=:branchName
284  '''
285  try:
286  qHandle=schema.newQuery()
287  qHandle.addToTableList( nameDealer.revisionTableName() )
288  qHandle.addToOutputList('REVISION_ID','revision_id')
289  qHandle.addToOutputList('BRANCH_ID','branch_id')
290  qCondition=coral.AttributeList()
291  qCondition.extend('name','string')
292  qCondition['name'].setData(branchName)
293  qResult=coral.AttributeList()
294  qResult.extend('revision_id','unsigned long long')
295  qResult.extend('branch_id','unsigned long long')
296  qHandle.defineOutput(qResult)
297  qHandle.setCondition('NAME=:name',qCondition)
298  cursor=qHandle.execute()
299  revision_id=None
300  branch_id=None
301  while cursor.next():
302  revision_id=cursor.currentRow()['revision_id'].data()
303  branch_id=cursor.currentRow()['branch_id'].data()
304  del qHandle
305  return (revision_id,branch_id)
306  except Exception,e :
307  raise RuntimeError(' revisionDML.branchInfoByName: '+str(e))
308 
309 
310 #=======================================================
311 #
312 # INSERT requires in update transaction
313 #
#=======================================================
def branchInfoByName
Definition: revisionDML.py:280
def revisionTableName
Definition: nameDealer.py:11
def revisionDML.branchType (   schema,
  name 
)
output: tag,branch
the difference between tag and branch: tag is an empty branch
select count(revision_id) from revisions where branch_name=:name
if >0: is real branch
else: is tag

Definition at line 110 of file revisionDML.py.

References runTheMatrix.data, and nameDealer.revisionTableName().

Referenced by PFTauDiscriminants::DiscriminantBase< int >.branchTree(), edm::RootOutputFile.fillBranches(), edm::PoolOutputModule.fillSelectedItemList(), edm::RootOutputFile.finishEndFile(), edm::PrincipalGetAdapter.getBranchDescription(), edm::ProductRegistry.productProduced(), edm::PoolOutputModule.respondToOpenInputFile(), edm::RootOutputFile.RootOutputFile(), and edm::ProductRegistry.setProductProduced().

111 def branchType(schema,name):
112  '''
113  output: tag,branch
114  the difference between tag and branch: tag is an empty branch
115  select count(revision_id) from revisions where branch_name=:name
116  if >0: is real branch
117  else: is tag
118  '''
119  result='tag'
120  try:
121  qHandle=schema.newQuery()
122  qHandle.addToTableList( nameDealer.revisionTableName() )
123  qHandle.addToOutputList('count(REVISION_ID)','nchildren')
124  qCondition=coral.AttributeList()
125  qCondition.extend('branch_name','string')
126  qCondition['branch_name'].setData(name)
127  qResult=coral.AttributeList()
128  qResult.extend('nchildren','unsigned int')
129  qHandle.defineOutput(qResult)
130  conditionStr='BRANCH_NAME=:branch_name'
131  qHandle.setCondition(conditionStr,qCondition)
132  cursor=qHandle.execute()
133  while cursor.next():
134  if cursor.currentRow()['nchildren'].data()>0:
135  result='branch'
136  del qHandle
137  return result
138  except :
139  raise
140 #def revisionsInBranch(schema,branchid):
141 # '''
142 # returns all revision values in a branch/tag
143 # result=[revision_id]
144 # select r.revision_id from revisions r where r.branch_id=:branchid and r.revision_id not in (select distinct a.branch_id from revisions a where a.branch_id>:branchid)
145 # '''
146 # result=[]
147 # try:
148 # qHandle=schema.newQuery()
149 # subquery=qHandle.defineSubQuery('B')
150 # subquery.addToTableList( nameDealer.revisionTableName(),'a' )
151 # subquery.addToOutputList('distinct a.BRANCH_ID')
152 # subqueryCondition=coral.AttributeList()
153 # subqueryCondition.extend('branchid','unsigned long long')
154 # subqueryCondition['branchid'].setData(branchid)
155 # subquery.setCondition('a.BRANCH_ID>:branchid',subqueryCondition)
156 #
157 # qHandle.addToTableList( nameDealer.revisionTableName(),'r' )
158 # qHandle.addToTableList( 'B')
159 # qHandle.addToOutputList('r.REVISION_ID','revision_id')
160 # qCondition=coral.AttributeList()
161 # qCondition.extend('branchid','unsigned long long')
162 # qCondition['branchid'].setData(branchid)
163 # qResult=coral.AttributeList()
164 # qResult.extend('revision_id','unsigned long long')
165 # qHandle.defineOutput(qResult)
166 # conditionStr='r.BRANCH_ID=:branchid AND r.REVISION_ID NOT IN B'
167 # qHandle.setCondition(conditionStr,qCondition)
168 # cursor=qHandle.execute()
169 # while cursor.next():
170 # result.append(cursor.currentRow()['revision_id'].data())
171 # del qHandle
172 # return result
173 # except :
174 # raise
def revisionTableName
Definition: nameDealer.py:11
def revisionDML.createBranch (   schema,
  name,
  parentname,
  comment = '' 
)
create a new branch/tag under given parentnode
insert into revisions(revision_id,branch_id,branch_name,name,comment,ctime) values()
return (revisionid,parentid,parentname)

Definition at line 430 of file revisionDML.py.

References runTheMatrix.data, and nameDealer.revisionTableName().

Referenced by lumidb2Schema.createBranch().

431 def createBranch(schema,name,parentname,comment=''):
432  '''
433  create a new branch/tag under given parentnode
434  insert into revisions(revision_id,branch_id,branch_name,name,comment,ctime) values()
435  return (revisionid,parentid,parentname)
436  '''
437  try:
438  parentid=None
439  revisionid=0
440  if not parentname is None:
441  qHandle=schema.newQuery()
442  qHandle.addToTableList( nameDealer.revisionTableName() )
443  qHandle.addToOutputList( 'REVISION_ID','revision_id' )
444  qCondition=coral.AttributeList()
445  qCondition.extend('parentname','string')
446  qCondition['parentname'].setData(parentname)
447  qResult=coral.AttributeList()
448  qResult.extend('revision_id','unsigned long long')
449  qHandle.defineOutput(qResult)
450  qHandle.setCondition('NAME=:parentname',qCondition)
451  cursor=qHandle.execute()
452  while cursor.next():
453  parentid=cursor.currentRow()['revision_id'].data()
454  del qHandle
455  else:
456  parentname='ROOT'
457  iddealer=idDealer.idDealer(schema)
458  revisionid=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
459  db=dbUtil.dbUtil(schema)
460  tabrowDefDict={}
461  tabrowDefDict['REVISION_ID']='unsigned long long'
462  tabrowDefDict['BRANCH_ID']='unsigned long long'
463  tabrowDefDict['BRANCH_NAME']='string'
464  tabrowDefDict['NAME']='string'
465  tabrowDefDict['COMMENT']='string'
466  tabrowDefDict['CTIME']='time stamp'
467  tabrowValueDict={}
468  tabrowValueDict['REVISION_ID']=revisionid
469  tabrowValueDict['BRANCH_ID']=parentid
470  tabrowValueDict['BRANCH_NAME']=parentname
471  tabrowValueDict['NAME']=name
472  tabrowValueDict['COMMENT']=comment
473  tabrowValueDict['CTIME']=coral.TimeStamp()
474  db.insertOneRow(nameDealer.revisionTableName(),tabrowDefDict, tabrowValueDict )
475  return (revisionid,parentid,parentname)
476  except:
477  raise
def revisionTableName
Definition: nameDealer.py:11
def createBranch
Definition: revisionDML.py:430
def revisionDML.dataRevisionsOfEntry (   schema,
  datatableName,
  entry,
  revrange 
)
all data version of the given entry whose revision falls in branch revision range
select d.data_id,r.revision_id from datatable d, datarevmaptable r where d.entry_id(or name )=:entry and d.data_id=r.data_id
input: if isinstance(entry,str): d.entry_name=:entry ; else d.entry_id=:entry
output: [data_id]

Definition at line 229 of file revisionDML.py.

References runTheMatrix.data, and nameDealer.revmapTableName().

Referenced by latestDataRevisionOfEntry().

230 def dataRevisionsOfEntry(schema,datatableName,entry,revrange):
231  '''
232  all data version of the given entry whose revision falls in branch revision range
233  select d.data_id,r.revision_id from datatable d, datarevmaptable r where d.entry_id(or name )=:entry and d.data_id=r.data_id
234  input: if isinstance(entry,str): d.entry_name=:entry ; else d.entry_id=:entry
235  output: [data_id]
236  '''
237  qHandle=schema.newQuery()
238  try:
239  result=[]
240  byname=False
241  if isinstance(entry,str):
242  byname=True
243  qHandle.addToTableList( datatableName,'d' )
244  qHandle.addToTableList( nameDealer.revmapTableName(datatableName), 'r')
245  qHandle.addToOutputList('d.DATA_ID','data_id')
246  qHandle.addToOutputList('r.REVISION_ID','revision_id')
247  qCondition=coral.AttributeList()
248  qConditionStr='d.DATA_ID=r.DATA_ID and '
249  if byname:
250  qCondition.extend('entry_name','string')
251  qCondition['entry_name'].setData(entry)
252  qConditionStr+='d.ENTRY_NAME=:entry_name'
253  else:
254  qCondition.extend('entry_id','unsigned long long')
255  qCondition['entry_id'].setData(entry)
256  qConditionStr+='d.ENTRY_ID=:entry_id'
257  qResult=coral.AttributeList()
258  qResult.extend('data_id','unsigned long long')
259  qResult.extend('revision_id','unsigned long long')
260  qHandle.defineOutput(qResult)
261  qHandle.setCondition(qConditionStr,qCondition)
262  cursor=qHandle.execute()
263  while cursor.next():
264  data_id=cursor.currentRow()['data_id'].data()
265  revision_id=cursor.currentRow()['revision_id'].data()
266  if revision_id in revrange:
267  result.append(data_id)
268  return result
269  except :
270  del qHandle
271  raise
def revmapTableName
Definition: nameDealer.py:65
def dataRevisionsOfEntry
Definition: revisionDML.py:229
def revisionDML.entryInBranch (   schema,
  datatableName,
  entryname,
  branch 
)
whether an entry(by name) already exists in the given branch
select e.entry_id from entrytable e,revisiontable r where r.revision_id=e.revision_id and e.name=:entryname and r.branch_name=branchname/branch_id
input:
    if isinstance(branch,str):byname
    else: byid
output:entry_id/None

Definition at line 186 of file revisionDML.py.

References runTheMatrix.data, nameDealer.entryTableName(), and nameDealer.revisionTableName().

Referenced by dataDML.addHLTRunDataToBranch(), dataDML.addLumiRunDataToBranch(), dataDML.addNormToBranch(), and dataDML.addTrgRunDataToBranch().

187 def entryInBranch(schema,datatableName,entryname,branch):
188  '''
189  whether an entry(by name) already exists in the given branch
190  select e.entry_id from entrytable e,revisiontable r where r.revision_id=e.revision_id and e.name=:entryname and r.branch_name=branchname/branch_id
191  input:
192  if isinstance(branch,str):byname
193  else: byid
194  output:entry_id/None
195  '''
196  try:
197  result=None
198  byname=False
199  if isinstance(branch,str):
200  byname=True
201  qHandle=schema.newQuery()
202  qHandle.addToTableList( nameDealer.entryTableName(datatableName),'e' )
203  qHandle.addToTableList( nameDealer.revisionTableName(),'r' )
204  qHandle.addToOutputList('e.ENTRY_ID','entry_id')
205  qCondition=coral.AttributeList()
206  qCondition.extend('entryname','string')
207  qCondition['entryname'].setData(entryname)
208  qConditionStr='r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname and '
209  if byname:
210  qCondition.extend('branch_name','string')
211  qCondition['branch_name'].setData(branch)
212  qConditionStr+='r.BRANCH_NAME=:branch_name'
213  else:
214  qCondition.extend('branch_id','unsigned long long')
215  qCondition['branch_id'].setData(branch)
216  qConditionStr+='r.BRANCH_ID=:branch_id'
217  qResult=coral.AttributeList()
218  qResult.extend('entry_id','unsigned long long')
219  qHandle.defineOutput(qResult)
220  qHandle.setCondition(qConditionStr,qCondition)
221  cursor=qHandle.execute()
222  while cursor.next():
223  entry_id=cursor.currentRow()['entry_id'].data()
224  result=entry_id
225  del qHandle
226  return result
227  except :
228  raise
def revisionTableName
Definition: nameDealer.py:11
def entryTableName
Definition: nameDealer.py:68
def entryInBranch
Definition: revisionDML.py:186
def revisionDML.latestDataRevisionOfEntry (   schema,
  datatableName,
  entry,
  revrange 
)
return max(data_id) of all datarevisionofEntry

Definition at line 272 of file revisionDML.py.

References dataRevisionsOfEntry(), and max().

273 def latestDataRevisionOfEntry(schema,datatableName,entry,revrange):
274  '''
275  return max(data_id) of all datarevisionofEntry
276  '''
277  result=dataRevisionsOfEntry(schema,datatableName,entry,revrange)
278  if result and len(result)!=0: return max(result)
279  return None
const T & max(const T &a, const T &b)
def dataRevisionsOfEntry
Definition: revisionDML.py:229
def latestDataRevisionOfEntry
Definition: revisionDML.py:272
def revisionDML.revisionsInBranch (   schema,
  branchid 
)
returns all revision values in a branch
result=[revision_id]
select distinct branch_id from revisions where branch_id>:branchid;
select revision_id from revisions where branch_id=:branchid ;
if the branchid matches and the revisionid is not in the branchid collection,not 0, then this revision is in the branch
require also revisionid>branchid

Definition at line 59 of file revisionDML.py.

References runTheMatrix.data, and nameDealer.revisionTableName().

Referenced by revisionsInBranchName().

59 
60 def revisionsInBranch(schema,branchid):
61  '''
62  returns all revision values in a branch
63  result=[revision_id]
64  select distinct branch_id from revisions where branch_id>:branchid;
65  select revision_id from revisions where branch_id=:branchid ;
66  if the branchid matches and the revisionid is not in the branchid collection,not 0, then this revision is in the branch
67  require also revisionid>branchid
68  '''
69  result=[]
70  qHandle=schema.newQuery()
71  try:
72  nextbranches=[]
73  qHandle.addToTableList( nameDealer.revisionTableName() )
74  qHandle.addToOutputList('distinct BRANCH_ID','branch_id')
75  qCondition=coral.AttributeList()
76  qCondition.extend('branchid','unsigned long long')
77  qCondition['branchid'].setData(branchid)
78  qResult=coral.AttributeList()
79  qResult.extend('branch_id','unsigned long long')
80  qHandle.defineOutput(qResult)
81  qHandle.setCondition('BRANCH_ID>:branchid',qCondition)
82  cursor=qHandle.execute()
83  while cursor.next():
84  nextbranches.append(cursor.currentRow()['branch_id'].data())
85  del qHandle
86  candidates=[]
87  conditionStr='BRANCH_ID=:branchid and REVISION_ID!=0'
88  qHandle=schema.newQuery()
89  qHandle.addToTableList( nameDealer.revisionTableName() )
90  qHandle.addToOutputList('REVISION_ID','revision_id')
91  qCondition=coral.AttributeList()
92  qCondition.extend('branchid','unsigned long long')
93  qCondition['branchid'].setData(branchid)
94  qResult=coral.AttributeList()
95  qResult.extend('revision_id','unsigned long long')
96  qHandle.defineOutput(qResult)
97  qHandle.setCondition(conditionStr,qCondition)
98  cursor=qHandle.execute()
99  while cursor.next():
100  candidates.append(cursor.currentRow()['revision_id'].data())
101  del qHandle
102  for c in candidates:
103  if c in nextbranches:
104  continue
105  result.append(c)
106  return result
107  except:
108  if qHandle: del qHandle
109  raise
def revisionTableName
Definition: nameDealer.py:11
def revisionsInBranch
Definition: revisionDML.py:59
def revisionDML.revisionsInBranchName (   schema,
  branchname 
)
returns all revisions in a branch/tag by name

Definition at line 175 of file revisionDML.py.

References branchInfoByName(), and revisionsInBranch().

176 def revisionsInBranchName(schema,branchname):
177  '''
178  returns all revisions in a branch/tag by name
179  '''
180  result=[]
181  try:
182  (revision_id,branch_id)=branchInfoByName(schema,branchname)
183  result=revisionsInBranch(schema,revision_id)
184  return result
185  except :
raise
def branchInfoByName
Definition: revisionDML.py:280
def revisionsInBranchName
Definition: revisionDML.py:175
def revisionsInBranch
Definition: revisionDML.py:59
def revisionDML.revisionsInTag (   schema,
  tagrevisionid,
  branchid 
)
returns all revisions before tag in selected branch
select revision_id from revisions where revision_id!=0 and revision_id<tagrevisionid and branch_id=:branchid
result=[revision_id]

Definition at line 10 of file revisionDML.py.

References runTheMatrix.data, and nameDealer.revisionTableName().

10 
11 def revisionsInTag(schema,tagrevisionid,branchid):
12  '''
13  returns all revisions before tag in selected branch
14  select revision_id from revisions where revision_id!=0 and revision_id<tagrevisionid and branch_id=:branchid
15  result=[revision_id]
16  '''
17  result=[]
18  qHandle=schema.newQuery()
19  try:
20  nextbranches=[]
21  qHandle.addToTableList( nameDealer.revisionTableName() )
22  qHandle.addToOutputList('distinct BRANCH_ID','branch_id')
23  qCondition=coral.AttributeList()
24  qCondition.extend('branchid','unsigned long long')
25  qCondition['branchid'].setData(branchid)
26  qResult=coral.AttributeList()
27  qResult.extend('branch_id','unsigned long long')
28  qHandle.defineOutput(qResult)
29  qHandle.setCondition('BRANCH_ID>:branchid',qCondition)
30  cursor=qHandle.execute()
31  while cursor.next():
32  nextbranches.append(cursor.currentRow()['branch_id'].data())
33  del qHandle
34  candidates=[]
35  conditionStr='REVISION_ID!=0 and BRANCH_ID=:branchid and REVISION_ID<:tagrevisionid'
36  qHandle=schema.newQuery()
37  qHandle.addToTableList( nameDealer.revisionTableName() )
38  qHandle.addToOutputList('REVISION_ID','revision_id')
39  qCondition=coral.AttributeList()
40  qCondition.extend('branchid','unsigned long long')
41  qCondition.extend('tagrevisionid','unsigned long long')
42  qCondition['branchid'].setData(branchid)
43  qCondition['tagrevisionid'].setData(tagrevisionid)
44  qResult=coral.AttributeList()
45  qResult.extend('revision_id','unsigned long long')
46  qHandle.defineOutput(qResult)
47  qHandle.setCondition(conditionStr,qCondition)
48  cursor=qHandle.execute()
49  while cursor.next():
50  candidates.append(cursor.currentRow()['revision_id'].data())
51  del qHandle
52  for c in candidates:
53  if c in nextbranches:
54  continue
55  result.append(c)
56  return result
57  except:
58  if qHandle:del qHandle
raise
def revisionTableName
Definition: nameDealer.py:11
def revisionsInTag
Definition: revisionDML.py:10

Variable Documentation

tuple revisionDML.databranchinfo = (branchid,'DATA')

Definition at line 496 of file revisionDML.py.

tuple revisionDML.datainfo = createBranch(schema,'DATA','TRUNK',comment='hold data')

Definition at line 491 of file revisionDML.py.

tuple revisionDML.entryinfo = (revision_id,entry_id,str(runnum),data_id)

Definition at line 504 of file revisionDML.py.

tuple revisionDML.hltentryid = entryInBranch(schema,nameDealer.hltdataTableName(),str(runnum),'DATA')

Definition at line 501 of file revisionDML.py.

tuple revisionDML.latestrevision = latestDataRevisionOfEntry(schema,nameDealer.lumidataTableName(),lumientry_id,revlist)

Definition at line 538 of file revisionDML.py.

tuple revisionDML.lumientry_id = entryInBranch(schema,nameDealer.lumidataTableName(),'1211','DATA')

Definition at line 536 of file revisionDML.py.

tuple revisionDML.lumientryid = entryInBranch(schema,nameDealer.lumidataTableName(),str(runnum),'DATA')

Definition at line 499 of file revisionDML.py.

string revisionDML.myconstr = 'sqlite_file:test.db'

Definition at line 483 of file revisionDML.py.

tuple revisionDML.norminfo = createBranch(schema,'NORM','TRUNK',comment='hold normalization factor')

Definition at line 493 of file revisionDML.py.

tuple revisionDML.revisioninfo = bookNewRevision( schema,nameDealer.lumidataTableName() )

Definition at line 508 of file revisionDML.py.

tuple revisionDML.revlist = revisionsInBranchName(schema,'DATA')

Definition at line 534 of file revisionDML.py.

tuple revisionDML.schema = session.nominalSchema()

Definition at line 486 of file revisionDML.py.

tuple revisionDML.session = svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])

Definition at line 485 of file revisionDML.py.

tuple revisionDML.svc = sessionManager.sessionManager(myconstr,debugON=False)

Definition at line 484 of file revisionDML.py.

tuple revisionDML.tables = lumidbDDL.createTables(schema)

Definition at line 488 of file revisionDML.py.

tuple revisionDML.trgentryid = entryInBranch(schema,nameDealer.trgdataTableName(),str(runnum),'DATA')

Definition at line 500 of file revisionDML.py.

tuple revisionDML.trunkinfo = createBranch(schema,'TRUNK',None,comment='main')

Definition at line 489 of file revisionDML.py.