/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes
DybDbi::rationalize::DbiRationalizer Class Reference

List of all members.

Public Member Functions

def __init__
def reset_target
def delete_target
def create_target
def __call__

Public Attributes

 db
 src
 vsrc
 tgt
 cmap
 mpr

Detailed Description

Usage::

     db = DB("tmp_offline_db")
     assert db.sect == os.environ['DBCONF']
     dc = DbiRationalizer( db , GCalibPmtSpec, GCalibPmtSpecCleaner )
     dc.reset_target()
     dc()

Definition at line 38 of file rationalize.py.


Constructor & Destructor Documentation

def DybDbi::rationalize::DbiRationalizer::__init__ (   self,
  db,
  src,
  tgt,
  cmap = None 
)
:param db: ``DybPython.DB`` instance
:param src: source DybDbi class, eg GTableName
:param tgt: target DybDbi class, eg GTableNameCleanup

Target is just being used for table creation and table name

Definition at line 49 of file rationalize.py.

00050                                                    :
00051         """
00052         :param db: ``DybPython.DB`` instance
00053         :param src: source DybDbi class, eg GTableName
00054         :param tgt: target DybDbi class, eg GTableNameCleanup
00055 
00056         Target is just being used for table creation and table name
00057 
00058         """
00059         from DybDbi import Mapr
00060         assert db.sect == os.environ['DBCONF']
00061         self.db = db
00062         self.src = src         
00063         self.vsrc = Vrb(src)         
00064         self.tgt = tgt          
00065         self.cmap = cmap
00066         self.mpr = Mapr()     ## 
00067         self['tname'] = tgt.__name__[1:]   # G prefix convention
        

Member Function Documentation

def DybDbi::rationalize::DbiRationalizer::reset_target (   self)
Drop the target ``GTableNameCleanup`` tables and ``LOCALSEQNO`` refernence   
harmless warning regarding non-existing tables on first run 

Definition at line 68 of file rationalize.py.

00069                           :
00070         """
00071         Drop the target ``GTableNameCleanup`` tables and ``LOCALSEQNO`` refernence   
00072         harmless warning regarding non-existing tables on first run 
00073         """  
00074         self.delete_target()
00075         self.create_target()

def DybDbi::rationalize::DbiRationalizer::delete_target (   self)

Definition at line 76 of file rationalize.py.

00077                            :
00078         assert self.db.sect == 'tmp_offline_db' 
00079         self.db("drop table if exists %(tname)s, %(tname)sVld" % self )      
00080         self.db("delete from LOCALSEQNO where TABLENAME='%(tname)s'" % self )

def DybDbi::rationalize::DbiRationalizer::create_target (   self)

Definition at line 81 of file rationalize.py.

00082                            :
00083         self.tgt().CreateDatabaseTables(0,  self['tname'] )

def DybDbi::rationalize::DbiRationalizer::__call__ (   self,
  seqnos 
)
Traverse all validity records in source table, ordered by SEQNO

#. validityrec reader covers full payload for a seqno doing eg ``select * from T where SEQNO=113``   etc...
   (expect validityrec readers to be immune to rollback as just plucking payload from a SEQNO) 

#. hmm are feeler queries prior to writing being impacted by the rollback ?

Definition at line 84 of file rationalize.py.

00085                                 :
00086         """
00087         Traverse all validity records in source table, ordered by SEQNO
00088                 
00089         #. validityrec reader covers full payload for a seqno doing eg ``select * from T where SEQNO=113``   etc...
00090            (expect validityrec readers to be immune to rollback as just plucking payload from a SEQNO) 
00091 
00092         #. hmm are feeler queries prior to writing being impacted by the rollback ?
00093 
00094         """
00095         from DybDbi import Rollback
00096         seqs = seqnos if len(seqnos)>0 else self.vsrc.seqnos
00097         log.info("rationalize  %s seqs : %s " % ( len(seqs) , repr(seqs) ))
00098         for seqno in seqs:
00099             vrec = self.vsrc(seqno) 
00100             assert vrec.seqno == seqno
00101 
00102             self.mpr.vrec = vrec           ## update SvcMode of the mapper, based on INSERTDATE timestamp of the vrec etc..
00103 
00104             wrt = self.tgt.Wrt().Clone()
00105             wrt.ctx( contextrange=vrec.contextrange, subsite=vrec.subsite, task=vrec.task, versiondate=vrec.versiondate, tablename=self['tname'] ) 
00106 
00107             rpt = self.src.Rpt().Clone()
00108             rpt.ctx( validityrec=vrec )     
00109             n = len(rpt)
00110 
00111             log.debug("vrec seqno %s n %s " % (vrec.seqno, n ))
00112 
00113             with Rollback(vrec.insertdate):
00114                 if self.cmap:
00115                     log.info("purging the cable cache ")
00116                     self.cmap.GetTableProxy().GetCache().Purge()
00117                 for row in rpt:
00118                     channelid = self.mpr(row.sensorid)
00119                     log.debug("sensorid %s channelid %s " % ( row.sensorid.asString(), channelid.asString() )) 
00120                     assert self.tgt.__name__ == 'GCalibPmtFineGain', "wrong target class %s " % self.tgt
00121                     newrow = self.tgt(channelid,row.GetSpeHigh(),row.GetSpeHighError(),row.GetSigmaSpeHigh(),row.GetSpeHighFitQual())
00122                     wrt.Write(newrow)
00123                 pass
00124                 
00125             wseqno = wrt.Close()
00126             assert wseqno == seqno, ("seqno are mis-aligned", seqno, wseqno )
00127             log.info("wrote seqno %s " % seqno )
00128             pass


Member Data Documentation

Definition at line 56 of file rationalize.py.

Definition at line 56 of file rationalize.py.

Definition at line 56 of file rationalize.py.

Definition at line 56 of file rationalize.py.

Definition at line 56 of file rationalize.py.

Definition at line 56 of file rationalize.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:57:24 for DybDbi by doxygen 1.7.4