/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::rationalizeRG::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
 args
 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 42 of file rationalizeRG.py.


Constructor & Destructor Documentation

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

Target is just being used for table creation and table name

Definition at line 53 of file rationalizeRG.py.

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

Member Function Documentation

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

Definition at line 75 of file rationalizeRG.py.

00076                           :
00077         """
00078         Drop the target tables and ``LOCALSEQNO`` refernence   
00079         harmless warning regarding non-existing tables on first run 
00080         """  
00081         self.delete_target()
00082         self.create_target()

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

Definition at line 83 of file rationalizeRG.py.

00084                            :
00085         assert self.db.sect == 'tmp_offline_db' 
00086         self.db("drop table if exists %(tname)s, %(tname)sVld" % self )      
00087         self.db("delete from LOCALSEQNO where TABLENAME='%(tname)s'" % self )

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

Definition at line 88 of file rationalizeRG.py.

00089                            :
00090         self.tgt().CreateDatabaseTables(0,  self['tname'] )

def DybDbi::rationalizeRG::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 91 of file rationalizeRG.py.

00092                                 :
00093         """
00094         Traverse all validity records in source table, ordered by SEQNO
00095                 
00096         #. validityrec reader covers full payload for a seqno doing eg ``select * from T where SEQNO=113``   etc...
00097            (expect validityrec readers to be immune to rollback as just plucking payload from a SEQNO) 
00098 
00099         #. hmm are feeler queries prior to writing being impacted by the rollback ?
00100 
00101         """
00102         from DybDbi import Rollback, TimeStamp
00103         seqs = seqnos if len(seqnos)>0 else self.vsrc.seqnos
00104         log.info("rationalize  %s seqs : %s ... %s " % ( len(seqs) , repr(seqs[0:10]), repr(seqs[-10:]) ))
00105         overlay = TimeStamp(0,0) 
00106 
00107         nseq = len(seqs)
00108         for iseq,seqno in enumerate(seqs):          
00109             vrec = self.vsrc(seqno)
00110             log.debug("I am in seqno %s with insertdate %s " % ( seqno, vrec.insertdate))
00111             assert vrec.seqno == seqno
00112 
00113             self.mpr.vrec = vrec           ## update SvcMode of the mapper, based on INSERTDATE timestamp of the vrec etc..
00114             self.mpr.svcMode.context().SetTimeStamp(vrec.versiondate); ## Add this to base timestamp of Mapr based on VERSIONDATE instead
00115            
00116             wrt = self.tgt.Wrt().Clone()
00117 
00118             task = self.args.task
00119             if self.args.overlay:
00120                 versiondate = overlay
00121             else:
00122                 versiondate = vrec.versiondate 
00123 
00124 
00125             wrt.ctx( contextrange=vrec.contextrange, subsite=vrec.subsite, task=task, versiondate=versiondate, tablename=self['tname'] ) 
00126 
00127             rpt = self.src.Rpt().Clone()
00128             rpt.ctx( validityrec=vrec )     
00129             n = len(rpt)
00130 
00131             log.debug("vrec seqno %s n %s " % (vrec.seqno, n ))
00132 
00133             if self.args.identity:
00134                 for row in rpt:
00135                     newrow = self.tgt(row.GetSensorId(),row.GetSpeHigh(),row.GetSpeHighError(),row.GetSigmaSpeHigh(),row.GetSpeHighFitQual())                   
00136                     wrt.Write(newrow)
00137             else:
00138                 with Rollback(vrec.versiondate):
00139                     if self.cmap:
00140                         log.debug("purging the cable cache ")
00141                         self.cmap.GetTableProxy().GetCache().Purge()
00142                     for row in rpt:
00143                         channelid = self.mpr(row.sensorid)
00144                         log.debug("sensorid %s channelid %s " % ( row.sensorid.asString(), channelid.asString() )) 
00145                         assert self.tgt.__name__ == 'GCalibPmtFineGain', "wrong target class %s " % self.tgt
00146                         newrow = self.tgt(channelid,row.GetSpeHigh(),row.GetSpeHighError(),row.GetSigmaSpeHigh(),row.GetSpeHighFitQual())                   
00147                         wrt.Write(newrow)
00148                     pass
00149             wseqno = wrt.Close()
00150             #assert wseqno == seqno, ("seqno are mis-aligned", seqno, wseqno )
00151             log.info("wrote [%-3s/%-3s] seqno %s into %s, originating from vrec.insertdate %s " %(iseq+1,nseq,seqno,wseqno,vrec.insertdate) )
00152             pass
00153 
00154 
00155 


Member Data Documentation

Definition at line 62 of file rationalizeRG.py.

Definition at line 62 of file rationalizeRG.py.

Definition at line 62 of file rationalizeRG.py.

Definition at line 62 of file rationalizeRG.py.

Definition at line 62 of file rationalizeRG.py.

Definition at line 62 of file rationalizeRG.py.

Definition at line 62 of file rationalizeRG.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