Exemplo n.º 1
0
def 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
    '''
    result=[]
    qHandle=schema.newQuery()
    try:
        nextbranches=[]
        qHandle.addToTableList( nameDealer.revisionTableName() )
        qHandle.addToOutputList('distinct BRANCH_ID','branch_id')
        qCondition=coral.AttributeList()
        qCondition.extend('branchid','unsigned long long')
        qCondition['branchid'].setData(branchid)
        qResult=coral.AttributeList()
        qResult.extend('branch_id','unsigned long long')
        qHandle.defineOutput(qResult)
        qHandle.setCondition('BRANCH_ID>:branchid',qCondition)
        cursor=qHandle.execute()
        while next(cursor):
            nextbranches.append(cursor.currentRow()['branch_id'].data())
        del qHandle
        candidates=[]
        conditionStr='BRANCH_ID=:branchid and REVISION_ID!=0'
        qHandle=schema.newQuery()
        qHandle.addToTableList( nameDealer.revisionTableName() )
        qHandle.addToOutputList('REVISION_ID','revision_id')
        qCondition=coral.AttributeList()
        qCondition.extend('branchid','unsigned long long')
        qCondition['branchid'].setData(branchid)
        qResult=coral.AttributeList()
        qResult.extend('revision_id','unsigned long long')
        qHandle.defineOutput(qResult)
        qHandle.setCondition(conditionStr,qCondition)
        cursor=qHandle.execute()
        while next(cursor):
            candidates.append(cursor.currentRow()['revision_id'].data())
        del qHandle
        for c in candidates:
            if c in nextbranches:
                continue
            result.append(c)
        return result
    except:
        if qHandle: del qHandle
        raise
Exemplo n.º 2
0
def 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]
    '''
    result=[]
    qHandle=schema.newQuery()
    try:
        nextbranches=[]
        qHandle.addToTableList( nameDealer.revisionTableName() )
        qHandle.addToOutputList('distinct BRANCH_ID','branch_id')
        qCondition=coral.AttributeList()
        qCondition.extend('branchid','unsigned long long')
        qCondition['branchid'].setData(branchid)
        qResult=coral.AttributeList()
        qResult.extend('branch_id','unsigned long long')
        qHandle.defineOutput(qResult)
        qHandle.setCondition('BRANCH_ID>:branchid',qCondition)
        cursor=qHandle.execute()
        while next(cursor):
            nextbranches.append(cursor.currentRow()['branch_id'].data())
        del qHandle
        candidates=[]
        conditionStr='REVISION_ID!=0 and BRANCH_ID=:branchid and REVISION_ID<:tagrevisionid'
        qHandle=schema.newQuery()
        qHandle.addToTableList( nameDealer.revisionTableName() )
        qHandle.addToOutputList('REVISION_ID','revision_id')
        qCondition=coral.AttributeList()
        qCondition.extend('branchid','unsigned long long')
        qCondition.extend('tagrevisionid','unsigned long long')
        qCondition['branchid'].setData(branchid)
        qCondition['tagrevisionid'].setData(tagrevisionid)
        qResult=coral.AttributeList()
        qResult.extend('revision_id','unsigned long long')
        qHandle.defineOutput(qResult)
        qHandle.setCondition(conditionStr,qCondition)
        cursor=qHandle.execute()
        while next(cursor):
            candidates.append(cursor.currentRow()['revision_id'].data())
        del qHandle
        for c in candidates:
            if c in nextbranches:
                continue
            result.append(c)
        return result
    except:
        if qHandle:del qHandle
        raise
def 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)
    '''
    try:
        parentid = None
        revisionid = 0
        if not parentname is None:
            qHandle = schema.newQuery()
            qHandle.addToTableList(nameDealer.revisionTableName())
            qHandle.addToOutputList('REVISION_ID', 'revision_id')
            qCondition = coral.AttributeList()
            qCondition.extend('parentname', 'string')
            qCondition['parentname'].setData(parentname)
            qResult = coral.AttributeList()
            qResult.extend('revision_id', 'unsigned long long')
            qHandle.defineOutput(qResult)
            qHandle.setCondition('NAME=:parentname', qCondition)
            cursor = qHandle.execute()
            while cursor.next():
                parentid = cursor.currentRow()['revision_id'].data()
            del qHandle
        else:
            parentname = 'ROOT'
        iddealer = idDealer.idDealer(schema)
        revisionid = iddealer.generateNextIDForTable(
            nameDealer.revisionTableName())
        db = dbUtil.dbUtil(schema)
        tabrowDefDict = {}
        tabrowDefDict['REVISION_ID'] = 'unsigned long long'
        tabrowDefDict['BRANCH_ID'] = 'unsigned long long'
        tabrowDefDict['BRANCH_NAME'] = 'string'
        tabrowDefDict['NAME'] = 'string'
        tabrowDefDict['COMMENT'] = 'string'
        tabrowDefDict['CTIME'] = 'time stamp'
        tabrowValueDict = {}
        tabrowValueDict['REVISION_ID'] = revisionid
        tabrowValueDict['BRANCH_ID'] = parentid
        tabrowValueDict['BRANCH_NAME'] = parentname
        tabrowValueDict['NAME'] = name
        tabrowValueDict['COMMENT'] = comment
        tabrowValueDict['CTIME'] = coral.TimeStamp()
        db.insertOneRow(nameDealer.revisionTableName(), tabrowDefDict,
                        tabrowValueDict)
        return (revisionid, parentid, parentname)
    except:
        raise
Exemplo n.º 4
0
def branchInfoByName(schema,branchName):
    '''
    select (revision_id,branch_id) from revisions where name=:branchName
    '''
    try:
         qHandle=schema.newQuery()
         qHandle.addToTableList( nameDealer.revisionTableName() )
         qHandle.addToOutputList('REVISION_ID','revision_id')
         qHandle.addToOutputList('BRANCH_ID','branch_id')
         qCondition=coral.AttributeList()
         qCondition.extend('name','string')
         qCondition['name'].setData(branchName)
         qResult=coral.AttributeList()
         qResult.extend('revision_id','unsigned long long')
         qResult.extend('branch_id','unsigned long long')
         qHandle.defineOutput(qResult)
         qHandle.setCondition('NAME=:name',qCondition)
         cursor=qHandle.execute()
         revision_id=None
         branch_id=None
         while next(cursor):
             revision_id=cursor.currentRow()['revision_id'].data()
             branch_id=cursor.currentRow()['branch_id'].data()
         del qHandle
         return (revision_id,branch_id)
    except Exception as e :
        raise RuntimeError(' revisionDML.branchInfoByName: '+str(e))
Exemplo n.º 5
0
def 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
    '''
    result='tag'
    try:
        qHandle=schema.newQuery()
        qHandle.addToTableList( nameDealer.revisionTableName() )
        qHandle.addToOutputList('count(REVISION_ID)','nchildren')
        qCondition=coral.AttributeList()
        qCondition.extend('branch_name','string')
        qCondition['branch_name'].setData(name)
        qResult=coral.AttributeList()
        qResult.extend('nchildren','unsigned int')
        qHandle.defineOutput(qResult)
        conditionStr='BRANCH_NAME=:branch_name'
        qHandle.setCondition(conditionStr,qCondition)
        cursor=qHandle.execute()
        while next(cursor):
            if cursor.currentRow()['nchildren'].data()>0:
                result='branch'                
        del qHandle
        return result
    except :
        raise 
Exemplo n.º 6
0
def 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)
    '''
    try:
        parentid=None
        revisionid=0       
        if not parentname is None:
            qHandle=schema.newQuery()
            qHandle.addToTableList( nameDealer.revisionTableName() )
            qHandle.addToOutputList( 'REVISION_ID','revision_id' )
            qCondition=coral.AttributeList()
            qCondition.extend('parentname','string')
            qCondition['parentname'].setData(parentname)
            qResult=coral.AttributeList()
            qResult.extend('revision_id','unsigned long long')
            qHandle.defineOutput(qResult)
            qHandle.setCondition('NAME=:parentname',qCondition)
            cursor=qHandle.execute()
            while next(cursor):
                parentid=cursor.currentRow()['revision_id'].data()
            del qHandle
        else:
            parentname='ROOT'
        iddealer=idDealer.idDealer(schema)
        revisionid=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
        db=dbUtil.dbUtil(schema)
        tabrowDefDict={}
        tabrowDefDict['REVISION_ID']='unsigned long long'
        tabrowDefDict['BRANCH_ID']='unsigned long long'
        tabrowDefDict['BRANCH_NAME']='string'
        tabrowDefDict['NAME']='string'
        tabrowDefDict['COMMENT']='string'
        tabrowDefDict['CTIME']='time stamp'
        tabrowValueDict={}
        tabrowValueDict['REVISION_ID']=revisionid
        tabrowValueDict['BRANCH_ID']=parentid
        tabrowValueDict['BRANCH_NAME']=parentname
        tabrowValueDict['NAME']=name
        tabrowValueDict['COMMENT']=comment
        tabrowValueDict['CTIME']=coral.TimeStamp()
        db.insertOneRow(nameDealer.revisionTableName(),tabrowDefDict, tabrowValueDict )
        return (revisionid,parentid,parentname)
    except:
        raise
Exemplo n.º 7
0
def createUniqueConstraints(schema):
    '''
    '''
    try:
        revtable=schema.tableHandle(nameDealer.revisionTableName())
        revtable.schemaEditor().setUniqueConstraint('NAME','revisions_name_uc')
    except:
        raise
Exemplo n.º 8
0
def createUniqueConstraints(schema):
    '''
    '''
    try:
        revtable = schema.tableHandle(nameDealer.revisionTableName())
        revtable.schemaEditor().setUniqueConstraint('NAME',
                                                    'revisions_name_uc')
    except:
        raise
Exemplo n.º 9
0
def bookNewRevision(schema,datatableName):
    '''
    allocate new revision_id,data_id
    '''
    try:
        iddealer=idDealer.idDealer(schema)
        revision_id=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
        data_id=iddealer.generateNextIDForTable(datatableName)
        return (revision_id,data_id)
    except:
        raise
Exemplo n.º 10
0
def bookNewEntry(schema,datatableName):
    '''
    allocate new revision_id,entry_id,data_id
    '''
    try:
        entrytableName=nameDealer.entryTableName(datatableName)
        iddealer=idDealer.idDealer(schema)
        revision_id=iddealer.generateNextIDForTable( nameDealer.revisionTableName() )
        data_id=iddealer.generateNextIDForTable( datatableName)
        entry_id=iddealer.generateNextIDForTable( nameDealer.entryTableName(datatableName) )
        return (revision_id,entry_id,data_id)
    except:
        raise
Exemplo n.º 11
0
def 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()
    '''
    try:
        revisiontableName=nameDealer.revisionTableName()
        entrytableName=nameDealer.entryTableName(datatableName)
        revtableName=nameDealer.revmapTableName(datatableName)
        
        db=dbUtil.dbUtil(schema)
        tabrowDefDict={}
        tabrowDefDict['REVISION_ID']='unsigned long long'
        tabrowDefDict['BRANCH_ID']='unsigned long long'
        tabrowDefDict['BRANCH_NAME']='string'
        tabrowDefDict['CTIME']='time stamp'
        tabrowValueDict={}
        tabrowValueDict['REVISION_ID']=entryinfo[0]
        tabrowValueDict['BRANCH_ID']=branchinfo[0]
        tabrowValueDict['BRANCH_NAME']=branchinfo[1]
        tabrowValueDict['CTIME']=coral.TimeStamp()
        db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
        
        tabrowDefDict={}
        tabrowDefDict['REVISION_ID']='unsigned long long'
        tabrowDefDict['ENTRY_ID']='unsigned long long'    
        tabrowDefDict['NAME']='string'
        
        tabrowValueDict={}
        tabrowValueDict['REVISION_ID']=entryinfo[0]
        tabrowValueDict['ENTRY_ID']=entryinfo[1]
        tabrowValueDict['NAME']=entryinfo[2]
        db.insertOneRow(entrytableName,tabrowDefDict,tabrowValueDict)
    
        tabrowDefDict={}
        tabrowDefDict['REVISION_ID']='unsigned long long'
        tabrowDefDict['DATA_ID']='unsigned long long'
        tabrowValueDict={}
        tabrowValueDict['REVISION_ID']=entryinfo[0]
        tabrowValueDict['DATA_ID']=entryinfo[3]
        db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
    except:
        raise
Exemplo n.º 12
0
def 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
    '''
    try:
        result=None
        byname=False
        if isinstance(branch,str):
            byname=True
        qHandle=schema.newQuery()
        qHandle.addToTableList( nameDealer.entryTableName(datatableName),'e' )
        qHandle.addToTableList( nameDealer.revisionTableName(),'r' )
        qHandle.addToOutputList('e.ENTRY_ID','entry_id')
        qCondition=coral.AttributeList()
        qCondition.extend('entryname','string')
        qCondition['entryname'].setData(entryname)
        qConditionStr='r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname and '
        if byname:
            qCondition.extend('branch_name','string')
            qCondition['branch_name'].setData(branch)
            qConditionStr+='r.BRANCH_NAME=:branch_name'
        else:
            qCondition.extend('branch_id','unsigned long long')
            qCondition['branch_id'].setData(branch)
            qConditionStr+='r.BRANCH_ID=:branch_id'
        qResult=coral.AttributeList()
        qResult.extend('entry_id','unsigned long long')
        qHandle.defineOutput(qResult)
        qHandle.setCondition(qConditionStr,qCondition)
        cursor=qHandle.execute()
        while next(cursor):
            entry_id=cursor.currentRow()['entry_id'].data()
            result=entry_id
        del qHandle
        return result
    except :
        raise 
Exemplo n.º 13
0
def 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))
    '''
    try:
        revisiontableName=nameDealer.revisionTableName()
        revtableName=nameDealer.revmapTableName(datatableName)
        
        db=dbUtil.dbUtil(schema)
        tabrowDefDict={}
        tabrowDefDict['REVISION_ID']='unsigned long long'
        tabrowDefDict['BRANCH_ID']='unsigned long long'
        tabrowDefDict['BRANCH_NAME']='string'
        tabrowDefDict['CTIME']='time stamp'

        tabrowValueDict={}
        tabrowValueDict['REVISION_ID']=revisioninfo[0]
        tabrowValueDict['BRANCH_ID']=branchinfo[0]
        tabrowValueDict['BRANCH_NAME']=branchinfo[1]
        tabrowValueDict['CTIME']=coral.TimeStamp()
        
        db.insertOneRow(revisiontableName,tabrowDefDict,tabrowValueDict)
        
        tabrowDefDict={}
        tabrowDefDict['REVISION_ID']='unsigned long long'
        tabrowDefDict['DATA_ID']='unsigned long long'
        tabrowValueDict={}
        tabrowValueDict['REVISION_ID']=revisioninfo[0]
        tabrowValueDict['DATA_ID']=revisioninfo[1]
        db.insertOneRow(revtableName,tabrowDefDict,tabrowValueDict)
    except:
        raise    
Exemplo n.º 14
0
def createTables(schema):
    '''
    create new tables if not exist
    revisions,revisions_id,luminorms,luminorms_entries,luminorms_entries_id,fillscheme
    '''
    try:
        created=[]
        db=dbUtil.dbUtil(schema)
        if not schema.existsTable(nameDealer.fillschemeTableName()):
            print('creating fillscheme table')
            fillschemeTab=coral.TableDescription()
            fillschemeTab.setName( nameDealer.fillschemeTableName() )
            fillschemeTab.insertColumn( 'FILLSCHEME_ID','unsigned long long' )
            fillschemeTab.insertColumn( 'FILLSCHEMEPATTERN','string',128,False )
            fillschemeTab.insertColumn( 'CORRECTIONFACTOR','float' )
            fillschemeTab.setPrimaryKey( 'FILLSCHEME_ID' )
            db.createTable(fillschemeTab,withIdTable=True)
            created.append( nameDealer.fillschemeTableName() )
            
        if not schema.existsTable(nameDealer.revisionTableName()):
            print('creating revisions table')
            revisionsTab=coral.TableDescription()
            revisionsTab.setName( nameDealer.revisionTableName() )
            revisionsTab.insertColumn( 'REVISION_ID','unsigned long long')
            revisionsTab.insertColumn( 'BRANCH_ID','unsigned long long')
            revisionsTab.insertColumn( 'NAME', 'string',56,False)
            revisionsTab.insertColumn( 'BRANCH_NAME', 'string',56,False)
            revisionsTab.insertColumn( 'COMMENT', 'string',1024,False)
            revisionsTab.insertColumn( 'CTIME', 'time stamp',6)
            revisionsTab.setPrimaryKey( 'REVISION_ID' )
            revisionsTab.setUniqueConstraint(('NAME'))
            db.createTable(revisionsTab,withIdTable=True)
            created.append(nameDealer.revisionTableName())
            
        if not schema.existsTable(nameDealer.luminormTableName()):
            print('creating luminorms table')
            luminormsTab=coral.TableDescription()
            luminormsTab.setName( nameDealer.luminormTableName() )
            luminormsTab.insertColumn( 'DATA_ID','unsigned long long')
            luminormsTab.insertColumn( 'ENTRY_ID','unsigned long long')
            luminormsTab.insertColumn( 'ENTRY_NAME','string',56,False)
            luminormsTab.insertColumn( 'AMODETAG', 'string',28,False)
            luminormsTab.insertColumn( 'NORM_1', 'float')
            luminormsTab.insertColumn( 'EGEV_1', 'unsigned int')
            luminormsTab.insertColumn( 'NORM_2', 'float')
            luminormsTab.insertColumn( 'EGEV_2', 'unsigned int')
            luminormsTab.setPrimaryKey( 'DATA_ID' )
            db.createTable(luminormsTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
            created.append(nameDealer.luminormTableName())
  
        if not schema.existsTable(nameDealer.lumidataTableName()):
            print('creating lumidata table')
            lumidataTab=coral.TableDescription()
            lumidataTab.setName( nameDealer.lumidataTableName() )
            lumidataTab.insertColumn( 'DATA_ID','unsigned long long')
            lumidataTab.insertColumn( 'ENTRY_ID','unsigned long long')
            lumidataTab.insertColumn( 'ENTRY_NAME','string',56,False)
            lumidataTab.insertColumn( 'SOURCE', 'string',128,False)
            lumidataTab.insertColumn( 'RUNNUM', 'unsigned int')
            lumidataTab.insertColumn( 'NOMINALEGEV', 'float')
            lumidataTab.setPrimaryKey( 'DATA_ID' )
            db.createTable(lumidataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
            created.append(nameDealer.lumidataTableName())

        if not schema.existsTable(nameDealer.lumisummaryv2TableName() ):
            print('creating lumisummaryv2 table')
            summary=coral.TableDescription()
            summary.setName( nameDealer.lumisummaryv2TableName() )
            summary.insertColumn('DATA_ID','unsigned long long')
            summary.insertColumn('RUNNUM','unsigned int')
            summary.insertColumn('LUMILSNUM','unsigned int')
            summary.insertColumn('CMSLSNUM','unsigned int')
            summary.insertColumn('INSTLUMI','float')
            summary.insertColumn('INSTLUMIERROR','float')
            summary.insertColumn('INSTLUMIQUALITY','short')
            summary.insertColumn('BEAMSTATUS','string',28,False)
            summary.insertColumn('BEAMENERGY','float')
            summary.insertColumn('NUMORBIT','unsigned int')
            summary.insertColumn('STARTORBIT','unsigned int')
            summary.insertColumn('CMSBXINDEXBLOB','blob')
            summary.insertColumn('BEAMINTENSITYBLOB_1','blob')
            summary.insertColumn('BEAMINTENSITYBLOB_2','blob')
            summary.insertColumn('BXLUMIVALUE_OCC1','blob')
            summary.insertColumn('BXLUMIVALUE_OCC2','blob')
            summary.insertColumn('BXLUMIVALUE_ET','blob')
            summary.insertColumn('BXLUMIERROR_OCC1','blob')
            summary.insertColumn('BXLUMIERROR_OCC2','blob')
            summary.insertColumn('BXLUMIERROR_ET','blob')
            summary.insertColumn('BXLUMIQUALITY_OCC1','blob')
            summary.insertColumn('BXLUMIQUALITY_OCC2','blob')
            summary.insertColumn('BXLUMIQUALITY_ET','blob')
            summary.setPrimaryKey(('DATA_ID','LUMILSNUM'))
            db.createTable(summary,withIdTable=False)            
            created.append(nameDealer.lumisummaryv2TableName())
            
        #
        # This table exists in the old schema
        #
        if not schema.existsTable(nameDealer.cmsrunsummaryTableName()):
            print('creating cmsrunsummary table')
            cmsrunsummary=coral.TableDescription()
            cmsrunsummary.setName( nameDealer.cmsrunsummaryTableName() )
            cmsrunsummary.insertColumn('RUNNUM','unsigned int')
            cmsrunsummary.insertColumn('HLTKEY','string',128,False)
            cmsrunsummary.insertColumn('L1KEY','string',128,False)
            cmsrunsummary.insertColumn('FILLNUM','unsigned int')
            cmsrunsummary.insertColumn('SEQUENCE','string',56,False)
            cmsrunsummary.insertColumn('STARTTIME','time stamp',6)
            cmsrunsummary.insertColumn('STOPTIME','time stamp',6)
            cmsrunsummary.insertColumn('EGEV','unsigned int')
            cmsrunsummary.insertColumn('AMODETAG','string',28,False)
            cmsrunsummary.insertColumn('FILLSCHEME','string',128,False)
            cmsrunsummary.insertColumn('NCOLLIDINGBUNCHES','usigned int')
            cmsrunsummary.setPrimaryKey('RUNNUM')
            db.createTable(cmsrunsummary,withIdTable=False)
            created.append(nameDealer.cmsrunsummaryTableName())
        #
        #  This table exists in the old schema
        #
        if not schema.existsTable(nameDealer.trghltMapTableName()):
            print('creating trghltmap table')
            trghlt=coral.TableDescription()
            trghlt.setName( nameDealer.trghltMapTableName() )
            trghlt.insertColumn( 'HLTKEY','string',128,False )
            trghlt.insertColumn( 'HLTPATHNAME','string',256,False )
            trghlt.insertColumn( 'L1SEED','string' ,1024,False)
            trghlt.setNotNullConstraint('HLTKEY',True)
            trghlt.setNotNullConstraint('HLTPATHNAME',True)
            trghlt.setNotNullConstraint('L1SEED',True)
            db.createTable(trghlt,withIdTable=False)
            created.append(nameDealer.trghltMapTableName())      
        if not schema.existsTable(nameDealer.trgdataTableName()):
            print('creating trgdata table')
            trgdataTab=coral.TableDescription()
            trgdataTab.setName( nameDealer.trgdataTableName() )
            trgdataTab.insertColumn( 'DATA_ID','unsigned long long')
            trgdataTab.insertColumn( 'ENTRY_ID','unsigned long long')
            trgdataTab.insertColumn( 'ENTRY_NAME','string',56,False)
            trgdataTab.insertColumn( 'SOURCE', 'string',128,False)
            trgdataTab.insertColumn( 'RUNNUM', 'unsigned int')
            trgdataTab.insertColumn( 'BITZERONAME', 'string',56,False)
            trgdataTab.insertColumn( 'BITNAMECLOB', 'string',6000)
            trgdataTab.setPrimaryKey( 'DATA_ID' )
            db.createTable(trgdataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
            created.append(nameDealer.trgdataTableName())
        if not schema.existsTable(nameDealer.lstrgTableName()):
            print('creating lstrg table')
            lstrgTab=coral.TableDescription()
            lstrgTab.setName( nameDealer.lstrgTableName() )
            lstrgTab.insertColumn( 'DATA_ID','unsigned long long')
            lstrgTab.insertColumn( 'RUNNUM', 'unsigned int')
            lstrgTab.insertColumn( 'CMSLSNUM', 'unsigned int')
            lstrgTab.insertColumn( 'DEADTIMECOUNT', 'unsigned long long')
            lstrgTab.insertColumn( 'BITZEROCOUNT', 'unsigned int')
            lstrgTab.insertColumn( 'BITZEROPRESCALE', 'unsigned int')
            lstrgTab.insertColumn( 'DEADFRAC', 'float')
            lstrgTab.insertColumn( 'PRESCALEBLOB', 'blob')
            lstrgTab.insertColumn( 'TRGCOUNTBLOB', 'blob')
            lstrgTab.setPrimaryKey( ('DATA_ID','CMSLSNUM') )
            db.createTable(lstrgTab,withIdTable=False)            
            created.append( nameDealer.lstrgTableName() )

        if not schema.existsTable(nameDealer.hltdataTableName()):
            print('creating hltdata table')
            hltdataTab=coral.TableDescription()
            hltdataTab.setName( nameDealer.hltdataTableName() )
            hltdataTab.insertColumn( 'DATA_ID','unsigned long long')
            hltdataTab.insertColumn( 'ENTRY_ID','unsigned long long')
            hltdataTab.insertColumn( 'ENTRY_NAME','string',56,False)
            hltdataTab.insertColumn( 'RUNNUM', 'unsigned int')
            hltdataTab.insertColumn( 'SOURCE', 'string',128,False)
            hltdataTab.insertColumn( 'NPATH', 'unsigned int')
            hltdataTab.insertColumn( 'PATHNAMECLOB', 'string',6000)
            hltdataTab.setPrimaryKey( 'DATA_ID' )
            db.createTable(hltdataTab,withIdTable=True,withEntryTables=True,withRevMapTable=True)
            created.append(nameDealer.hltTableName())
            
        if not schema.existsTable(nameDealer.lshltTableName()):
            print('creating lshlt table')
            lshltTab=coral.TableDescription()
            lshltTab.setName( nameDealer.lshltTableName() )
            lshltTab.insertColumn( 'DATA_ID','unsigned long long')
            lshltTab.insertColumn( 'RUNNUM', 'unsigned int')
            lshltTab.insertColumn( 'CMSLSNUM', 'unsigned int')
            lshltTab.insertColumn( 'PRESCALEBLOB', 'blob')
            lshltTab.insertColumn( 'HLTCOUNTBLOB', 'blob')
            lshltTab.insertColumn( 'HLTACCEPTBLOB', 'blob')
            db.createTable(lshltTab,withIdTable=False)
            lshltTab.setPrimaryKey( ('DATA_ID','CMSLSNUM') )
            created.append(nameDealer.lshltTableName())          

            
        if not schema.existsTable(nameDealer.lumivalidationTableName()):
            print('creating lumivalidation  table')
            lumivalidation=coral.TableDescription()
            lumivalidation.setName( nameDealer.lumivalidationTableName() )
            lumivalidation.insertColumn( 'RUNNUM','unsigned int' )
            lumivalidation.insertColumn( 'CMSLSNUM','unsigned int' )
            lumivalidation.insertColumn( 'FLAG','string',28,False )
            lumivalidation.insertColumn( 'COMMENT','string',1024,False )
            lumivalidation.setPrimaryKey( ('RUNNUM','CMSLSNUM') )
            lumivalidation.setNotNullConstraint('FLAG',True)
            db.createTable(lumivalidation,withIdTable=False)
            created.append(nameDealer.lumivalidationTableName())
        return created
    except :
        raise 
Exemplo n.º 15
0
def createTables(schema):
    '''
    create new tables if not exist
    revisions,revisions_id,luminorms,luminorms_entries,luminorms_entries_id,fillscheme
    '''
    try:
        created = []
        db = dbUtil.dbUtil(schema)
        if not schema.existsTable(nameDealer.fillschemeTableName()):
            print('creating fillscheme table')
            fillschemeTab = coral.TableDescription()
            fillschemeTab.setName(nameDealer.fillschemeTableName())
            fillschemeTab.insertColumn('FILLSCHEME_ID', 'unsigned long long')
            fillschemeTab.insertColumn('FILLSCHEMEPATTERN', 'string', 128,
                                       False)
            fillschemeTab.insertColumn('CORRECTIONFACTOR', 'float')
            fillschemeTab.setPrimaryKey('FILLSCHEME_ID')
            db.createTable(fillschemeTab, withIdTable=True)
            created.append(nameDealer.fillschemeTableName())

        if not schema.existsTable(nameDealer.revisionTableName()):
            print('creating revisions table')
            revisionsTab = coral.TableDescription()
            revisionsTab.setName(nameDealer.revisionTableName())
            revisionsTab.insertColumn('REVISION_ID', 'unsigned long long')
            revisionsTab.insertColumn('BRANCH_ID', 'unsigned long long')
            revisionsTab.insertColumn('NAME', 'string', 56, False)
            revisionsTab.insertColumn('BRANCH_NAME', 'string', 56, False)
            revisionsTab.insertColumn('COMMENT', 'string', 1024, False)
            revisionsTab.insertColumn('CTIME', 'time stamp', 6)
            revisionsTab.setPrimaryKey('REVISION_ID')
            revisionsTab.setUniqueConstraint(('NAME'))
            db.createTable(revisionsTab, withIdTable=True)
            created.append(nameDealer.revisionTableName())

        if not schema.existsTable(nameDealer.luminormTableName()):
            print('creating luminorms table')
            luminormsTab = coral.TableDescription()
            luminormsTab.setName(nameDealer.luminormTableName())
            luminormsTab.insertColumn('DATA_ID', 'unsigned long long')
            luminormsTab.insertColumn('ENTRY_ID', 'unsigned long long')
            luminormsTab.insertColumn('ENTRY_NAME', 'string', 56, False)
            luminormsTab.insertColumn('AMODETAG', 'string', 28, False)
            luminormsTab.insertColumn('NORM_1', 'float')
            luminormsTab.insertColumn('EGEV_1', 'unsigned int')
            luminormsTab.insertColumn('NORM_2', 'float')
            luminormsTab.insertColumn('EGEV_2', 'unsigned int')
            luminormsTab.setPrimaryKey('DATA_ID')
            db.createTable(luminormsTab,
                           withIdTable=True,
                           withEntryTables=True,
                           withRevMapTable=True)
            created.append(nameDealer.luminormTableName())

        if not schema.existsTable(nameDealer.lumidataTableName()):
            print('creating lumidata table')
            lumidataTab = coral.TableDescription()
            lumidataTab.setName(nameDealer.lumidataTableName())
            lumidataTab.insertColumn('DATA_ID', 'unsigned long long')
            lumidataTab.insertColumn('ENTRY_ID', 'unsigned long long')
            lumidataTab.insertColumn('ENTRY_NAME', 'string', 56, False)
            lumidataTab.insertColumn('SOURCE', 'string', 128, False)
            lumidataTab.insertColumn('RUNNUM', 'unsigned int')
            lumidataTab.insertColumn('NOMINALEGEV', 'float')
            lumidataTab.setPrimaryKey('DATA_ID')
            db.createTable(lumidataTab,
                           withIdTable=True,
                           withEntryTables=True,
                           withRevMapTable=True)
            created.append(nameDealer.lumidataTableName())

        if not schema.existsTable(nameDealer.lumisummaryv2TableName()):
            print('creating lumisummaryv2 table')
            summary = coral.TableDescription()
            summary.setName(nameDealer.lumisummaryv2TableName())
            summary.insertColumn('DATA_ID', 'unsigned long long')
            summary.insertColumn('RUNNUM', 'unsigned int')
            summary.insertColumn('LUMILSNUM', 'unsigned int')
            summary.insertColumn('CMSLSNUM', 'unsigned int')
            summary.insertColumn('INSTLUMI', 'float')
            summary.insertColumn('INSTLUMIERROR', 'float')
            summary.insertColumn('INSTLUMIQUALITY', 'short')
            summary.insertColumn('BEAMSTATUS', 'string', 28, False)
            summary.insertColumn('BEAMENERGY', 'float')
            summary.insertColumn('NUMORBIT', 'unsigned int')
            summary.insertColumn('STARTORBIT', 'unsigned int')
            summary.insertColumn('CMSBXINDEXBLOB', 'blob')
            summary.insertColumn('BEAMINTENSITYBLOB_1', 'blob')
            summary.insertColumn('BEAMINTENSITYBLOB_2', 'blob')
            summary.insertColumn('BXLUMIVALUE_OCC1', 'blob')
            summary.insertColumn('BXLUMIVALUE_OCC2', 'blob')
            summary.insertColumn('BXLUMIVALUE_ET', 'blob')
            summary.insertColumn('BXLUMIERROR_OCC1', 'blob')
            summary.insertColumn('BXLUMIERROR_OCC2', 'blob')
            summary.insertColumn('BXLUMIERROR_ET', 'blob')
            summary.insertColumn('BXLUMIQUALITY_OCC1', 'blob')
            summary.insertColumn('BXLUMIQUALITY_OCC2', 'blob')
            summary.insertColumn('BXLUMIQUALITY_ET', 'blob')
            summary.setPrimaryKey(('DATA_ID', 'LUMILSNUM'))
            db.createTable(summary, withIdTable=False)
            created.append(nameDealer.lumisummaryv2TableName())

        #
        # This table exists in the old schema
        #
        if not schema.existsTable(nameDealer.cmsrunsummaryTableName()):
            print('creating cmsrunsummary table')
            cmsrunsummary = coral.TableDescription()
            cmsrunsummary.setName(nameDealer.cmsrunsummaryTableName())
            cmsrunsummary.insertColumn('RUNNUM', 'unsigned int')
            cmsrunsummary.insertColumn('HLTKEY', 'string', 128, False)
            cmsrunsummary.insertColumn('L1KEY', 'string', 128, False)
            cmsrunsummary.insertColumn('FILLNUM', 'unsigned int')
            cmsrunsummary.insertColumn('SEQUENCE', 'string', 56, False)
            cmsrunsummary.insertColumn('STARTTIME', 'time stamp', 6)
            cmsrunsummary.insertColumn('STOPTIME', 'time stamp', 6)
            cmsrunsummary.insertColumn('EGEV', 'unsigned int')
            cmsrunsummary.insertColumn('AMODETAG', 'string', 28, False)
            cmsrunsummary.insertColumn('FILLSCHEME', 'string', 128, False)
            cmsrunsummary.insertColumn('NCOLLIDINGBUNCHES', 'usigned int')
            cmsrunsummary.setPrimaryKey('RUNNUM')
            db.createTable(cmsrunsummary, withIdTable=False)
            created.append(nameDealer.cmsrunsummaryTableName())
        #
        #  This table exists in the old schema
        #
        if not schema.existsTable(nameDealer.trghltMapTableName()):
            print('creating trghltmap table')
            trghlt = coral.TableDescription()
            trghlt.setName(nameDealer.trghltMapTableName())
            trghlt.insertColumn('HLTKEY', 'string', 128, False)
            trghlt.insertColumn('HLTPATHNAME', 'string', 256, False)
            trghlt.insertColumn('L1SEED', 'string', 1024, False)
            trghlt.setNotNullConstraint('HLTKEY', True)
            trghlt.setNotNullConstraint('HLTPATHNAME', True)
            trghlt.setNotNullConstraint('L1SEED', True)
            db.createTable(trghlt, withIdTable=False)
            created.append(nameDealer.trghltMapTableName())
        if not schema.existsTable(nameDealer.trgdataTableName()):
            print('creating trgdata table')
            trgdataTab = coral.TableDescription()
            trgdataTab.setName(nameDealer.trgdataTableName())
            trgdataTab.insertColumn('DATA_ID', 'unsigned long long')
            trgdataTab.insertColumn('ENTRY_ID', 'unsigned long long')
            trgdataTab.insertColumn('ENTRY_NAME', 'string', 56, False)
            trgdataTab.insertColumn('SOURCE', 'string', 128, False)
            trgdataTab.insertColumn('RUNNUM', 'unsigned int')
            trgdataTab.insertColumn('BITZERONAME', 'string', 56, False)
            trgdataTab.insertColumn('BITNAMECLOB', 'string', 6000)
            trgdataTab.setPrimaryKey('DATA_ID')
            db.createTable(trgdataTab,
                           withIdTable=True,
                           withEntryTables=True,
                           withRevMapTable=True)
            created.append(nameDealer.trgdataTableName())
        if not schema.existsTable(nameDealer.lstrgTableName()):
            print('creating lstrg table')
            lstrgTab = coral.TableDescription()
            lstrgTab.setName(nameDealer.lstrgTableName())
            lstrgTab.insertColumn('DATA_ID', 'unsigned long long')
            lstrgTab.insertColumn('RUNNUM', 'unsigned int')
            lstrgTab.insertColumn('CMSLSNUM', 'unsigned int')
            lstrgTab.insertColumn('DEADTIMECOUNT', 'unsigned long long')
            lstrgTab.insertColumn('BITZEROCOUNT', 'unsigned int')
            lstrgTab.insertColumn('BITZEROPRESCALE', 'unsigned int')
            lstrgTab.insertColumn('DEADFRAC', 'float')
            lstrgTab.insertColumn('PRESCALEBLOB', 'blob')
            lstrgTab.insertColumn('TRGCOUNTBLOB', 'blob')
            lstrgTab.setPrimaryKey(('DATA_ID', 'CMSLSNUM'))
            db.createTable(lstrgTab, withIdTable=False)
            created.append(nameDealer.lstrgTableName())

        if not schema.existsTable(nameDealer.hltdataTableName()):
            print('creating hltdata table')
            hltdataTab = coral.TableDescription()
            hltdataTab.setName(nameDealer.hltdataTableName())
            hltdataTab.insertColumn('DATA_ID', 'unsigned long long')
            hltdataTab.insertColumn('ENTRY_ID', 'unsigned long long')
            hltdataTab.insertColumn('ENTRY_NAME', 'string', 56, False)
            hltdataTab.insertColumn('RUNNUM', 'unsigned int')
            hltdataTab.insertColumn('SOURCE', 'string', 128, False)
            hltdataTab.insertColumn('NPATH', 'unsigned int')
            hltdataTab.insertColumn('PATHNAMECLOB', 'string', 6000)
            hltdataTab.setPrimaryKey('DATA_ID')
            db.createTable(hltdataTab,
                           withIdTable=True,
                           withEntryTables=True,
                           withRevMapTable=True)
            created.append(nameDealer.hltTableName())

        if not schema.existsTable(nameDealer.lshltTableName()):
            print('creating lshlt table')
            lshltTab = coral.TableDescription()
            lshltTab.setName(nameDealer.lshltTableName())
            lshltTab.insertColumn('DATA_ID', 'unsigned long long')
            lshltTab.insertColumn('RUNNUM', 'unsigned int')
            lshltTab.insertColumn('CMSLSNUM', 'unsigned int')
            lshltTab.insertColumn('PRESCALEBLOB', 'blob')
            lshltTab.insertColumn('HLTCOUNTBLOB', 'blob')
            lshltTab.insertColumn('HLTACCEPTBLOB', 'blob')
            db.createTable(lshltTab, withIdTable=False)
            lshltTab.setPrimaryKey(('DATA_ID', 'CMSLSNUM'))
            created.append(nameDealer.lshltTableName())

        if not schema.existsTable(nameDealer.lumivalidationTableName()):
            print('creating lumivalidation  table')
            lumivalidation = coral.TableDescription()
            lumivalidation.setName(nameDealer.lumivalidationTableName())
            lumivalidation.insertColumn('RUNNUM', 'unsigned int')
            lumivalidation.insertColumn('CMSLSNUM', 'unsigned int')
            lumivalidation.insertColumn('FLAG', 'string', 28, False)
            lumivalidation.insertColumn('COMMENT', 'string', 1024, False)
            lumivalidation.setPrimaryKey(('RUNNUM', 'CMSLSNUM'))
            lumivalidation.setNotNullConstraint('FLAG', True)
            db.createTable(lumivalidation, withIdTable=False)
            created.append(nameDealer.lumivalidationTableName())
        return created
    except:
        raise