TDbi Namespace Reference

Typedefs

typedef Int_t Task
 Concept Package-wide namespace of utilities and typedef/enums.

Enumerations

enum  TaskTypes { kAnyTask = -1, kDefaultTask = 0 }
enum  TypeRegimes { kRootRegime = 0, kSQLRegime = 1 }
enum  DataTypes {
  kUnknown, kBool, kChar, kUChar,
  kTiny, kUTiny, kShort, kUShort,
  kInt, kUInt, kLong, kULong,
  kFloat, kDouble, kString, kTString,
  kDate
}
enum  DbTypes { kMySQL = 0 }
enum  AbortTest { kDisabled, kTableMissing, kDataMissing }
enum  { kMAXLOCALSEQNO = 99999999, kMAXTABLENAMELEN = 80 }

Functions

std::string GetVldDescr (const char *tableName, Bool_t isTemporary=false)
void SetLogLevel (int level)
 > Return SQL needed to create VLD table.
Int_t GetTimeGate (const std::string &tableName)
 Time gates for each table in secs. Used to trim validity searches.
void SetTimeGate (const std::string &tableName, Int_t timeGate)
std::string MakeDateTimeString (const TVldTimeStamp &timeStamp)
 DateTime conversion utilities.
TVldTimeStamp MakeTimeStamp (const std::string &sqlDateTime, Bool_t *ok=0)
Bool_t NotGlobalSeqNo (UInt_t seqNo)
 SeqNo utilities.

Typedef Documentation

typedef Int_t TDbi::Task

Concept Package-wide namespace of utilities and typedef/enums.

Purpose To provide standard of utilities and typedef/enums.

Contact: A.Finch@lancaster.ac.uk

Definition at line 40 of file TDbi.hxx.


Enumeration Type Documentation

anonymous enum
Enumerator:
kMAXLOCALSEQNO 
kMAXTABLENAMELEN 

Definition at line 78 of file TDbi.hxx.

00078        { kMAXLOCALSEQNO   = 99999999,    // Max local SeqNo.
00079          kMAXTABLENAMELEN = 80};         // Max length of table name.

Enumerator:
kDisabled 
kTableMissing 
kDataMissing 

Definition at line 73 of file TDbi.hxx.

00073                { kDisabled,
00074                  kTableMissing,
00075                  kDataMissing
00076  };

Enumerator:
kUnknown 
kBool 
kChar 
kUChar 
kTiny 
kUTiny 
kShort 
kUShort 
kInt 
kUInt 
kLong 
kULong 
kFloat 
kDouble 
kString 
kTString 
kDate 

Definition at line 50 of file TDbi.hxx.

00050                { kUnknown,
00051                  kBool,      // concept
00052                  kChar,      // concept
00053                  kUChar,     // concept
00054                  kTiny,
00055                  kUTiny,
00056                  kShort,
00057                  kUShort,
00058                  kInt,       // concept
00059                  kUInt,      // concept
00060                  kLong,
00061                  kULong,
00062                  kFloat,     // concept
00063                  kDouble,
00064                  kString,    // concept
00065                  kTString,
00066                  kDate       // concept
00067  };

Enumerator:
kMySQL 

Definition at line 70 of file TDbi.hxx.

00070              {  kMySQL         = 0
00071  };

Enumerator:
kAnyTask 
kDefaultTask 

Definition at line 42 of file TDbi.hxx.

00042                {  kAnyTask     = -1,   // Use to disable task selection in context queries.
00043                   kDefaultTask = 0
00044  };

Enumerator:
kRootRegime 
kSQLRegime 

Definition at line 46 of file TDbi.hxx.

00046                  { kRootRegime = 0,
00047                    kSQLRegime  = 1
00048 };


Function Documentation

Int_t TDbi::GetTimeGate ( const std::string &  tableName  ) 

Time gates for each table in secs. Used to trim validity searches.

Definition at line 89 of file TDbi.cxx.

References fgTimegateTable, SetTimeGate(), and SK_DBI_Debug.

Referenced by ClassImp(), TDbiDBProxy::FindTimeBoundaries(), TDbiValidityRecBuilder::MakeGapRec(), and TDbiDBProxy::QueryValidity().

00089                                                   {
00090 
00091 //  Purpose: Get a suitable time gate for table.
00092 
00093 //  Program Notes:-
00094 //  =============
00095 
00096 //  A time gate is applied to all primary (validity) queries to save time
00097 //  and ensure that gaps are not missed. Ideally the gate needs to be
00098 //  of order of a typical validity range.  Much longer and unneeded
00099 //  VLD records are processed, much shorter and the query results will
00100 //  expire too soon.  Both increase I/O.
00101 //
00102 //  The system provides a default for each table and TDbiValidityRecBuilder
00103 //  updates it if grossly wrong.
00104 
00105   // Set default if looking up table for the first time.
00106   std::map<std::string,Int_t>::iterator
00107       tablePtr = fgTimegateTable.find(tableName);
00108   if ( tablePtr == fgTimegateTable.end()
00109      ) TDbi::SetTimeGate(tableName,10*24*60*60);
00110 
00111   SK_DBI_Debug( "Returning time gate " << fgTimegateTable[tableName]
00112                           << " for " << tableName << "  ");
00113   return fgTimegateTable[tableName];
00114 
00115 }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string TDbi::GetVldDescr ( const char *  tableName,
Bool_t  isTemporary = false 
)

Definition at line 119 of file TDbi.cxx.

Referenced by TDbiCascader::CreateTemporaryTable().

00120                                                              {
00121 //
00122 //
00123 //  Purpose:  Return string "create [temporary] table tableNameXXX" to make table xxxVLD
00124 //
00125 //  Program Notes:-
00126 //  =============
00127 
00128 //  If the format of Validity Tables is changed then this function must
00129 //  be updated as that format is hardwired into an SQL CREATE TABLE
00130 //  command in this function.
00131 
00132   string sql;
00133   sql += "create ";
00134   if ( isTemporary ) sql += "temporary ";
00135   sql += "table ";
00136   sql += tableName;
00137   sql += "VLD ( ";
00138   sql += "  SEQNO integer not null primary key,";
00139   sql += "  TIMESTART datetime not null,";
00140   sql += "  TIMEEND datetime not null,";
00141   sql += "  EPOCH tinyint,";
00142   sql += "  REALITY tinyint,";
00143   sql += "  DETECTORMASK tinyint,";
00144   sql += "  SIMMASK tinyint,";
00145   sql += "  TASK integer,";
00146   sql += "  AGGREGATENO integer,";
00147   sql += "  CREATIONDATE datetime not null,";
00148   sql += "  INSERTDATE datetime not null ) ";
00149   return sql;
00150 }

Here is the caller graph for this function:

string TDbi::MakeDateTimeString ( const TVldTimeStamp timeStamp  ) 

DateTime conversion utilities.

Definition at line 154 of file TDbi.cxx.

References TVldTimeStamp::AsString().

Referenced by TDbiDBProxy::FindTimeBoundaries(), TDbiOutRowStream::operator<<(), TDbiDBProxy::QueryValidity(), TDbiRollbackDates::Set(), TDbiSqlValPacket::Store(), and UnixTimeToDateTime().

00154                                                               {
00155 //
00156 //
00157 //  Purpose: Convert TVldTimeStamp to SQL DateTime string.
00158 //
00159 //  Arguments:
00160 //    timeStamp    in    TVldTimeStamp to be converted.
00161 //
00162 //  Return: SQL DateTime string corresponding to TVldTimeStamp.
00163 //
00164 //  Contact:   N. West
00165 //
00166 //  Specification:-
00167 //  =============
00168 //
00169 //  o Return SQL DateTime string corresponding to TVldTimeStamp.
00170 
00171 //  Program Notes:-
00172 //  =============
00173 
00174 //  The format of a  SQL DateTime string is:-
00175 //
00176 //            YYYY-MM-DD HH:MM:SS
00177 //    e.g.    2001-01-03 00:00:00
00178 //            0123456789012345678901234567890123"
00179 
00180  return timeStamp.AsString("s");
00181 
00182 }

Here is the call graph for this function:

Here is the caller graph for this function:

TVldTimeStamp TDbi::MakeTimeStamp ( const std::string &  sqlDateTime,
Bool_t *  ok = 0 
)

Definition at line 185 of file TDbi.cxx.

References TVldTimeStamp::GetDate(), and SK_DBI_Severe.

Referenced by DateTimeToUnixTime(), TDbiDBProxy::FindTimeBoundaries(), TDbiInRowStream::operator>>(), and TDbiRollbackDates::Set().

00186                                             {
00187 //
00188 //
00189 //  Purpose:  Convert SQL DateTime string to TVldTimeStamp.
00190 //
00191 //  Arguments:
00192 //    sqlDateTime  in   SQL DateTime string to be convered.
00193 //    ok           in    Optional return flag
00194 //                       If not supplied, report illegal dates
00195 //
00196 //  Return:  TVldTimeStamp corresponding to SQL DateTime string.
00197 //
00198 //  Contact:   N. West
00199 //
00200 //  Specification:-
00201 //  =============
00202 //
00203 //  o  Return TVldTimeStamp corresponding to SQL DateTime string.
00204 
00205 //  Program Notes:-
00206 //  =============
00207 
00208 //  Note that there is only white space between day and hour
00209 //  so no need for dummy separator.
00210 
00211   struct date {
00212     int year;
00213     int month;
00214     int day;
00215     int hour;
00216     int min;
00217     int sec;};
00218   char dummy;
00219 
00220   static string lo = "1970-01-01 00:00:00";
00221   static string hi = "2038-01-19 03:14:07";
00222 
00223   // Set up defaults from 0:0am today.
00224   TVldTimeStamp nowTS;
00225   int nowDate = nowTS.GetDate();
00226   date defaultDate = {nowDate/10000, nowDate/100%100, nowDate%100,0,0,0};
00227   date input       = defaultDate;
00228 
00229   istringstream in(sqlDateTime);
00230   in >> input.year >> dummy >> input.month >> dummy >> input.day
00231      >> input.hour >> dummy >> input.min   >> dummy >> input.sec;
00232 
00233   if ( ok ) *ok = kTRUE;
00234   if (  sqlDateTime < lo || sqlDateTime > hi ) {
00235     if ( ok ) *ok = kFALSE;
00236     else {
00237       static int bad_date_count = 0;
00238       if ( ++bad_date_count <= 20 ) {
00239         const char* last = (bad_date_count == 20) ? "..Last Message.. " : "";
00240         SK_DBI_Severe(  "Bad date string: " << sqlDateTime
00241                             << " parsed as "
00242                             << input.year  << " "
00243                             << input.month << " "
00244                             << input.day   << " "
00245                             << input.hour  << " "
00246                             << input.min   << " "
00247                             << input.sec
00248                             << "\n    Outside range " << lo
00249                             << " to " << hi << last << "  ");
00250       }
00251     }
00252 
00253     input = defaultDate;
00254   }
00255 
00256   return TVldTimeStamp(input.year,input.month,input.day,
00257                       input.hour,input.min,input.sec);
00258 
00259 }

Here is the call graph for this function:

Here is the caller graph for this function:

Bool_t TDbi::NotGlobalSeqNo ( UInt_t  seqNo  ) 

SeqNo utilities.

Definition at line 262 of file TDbi.cxx.

References kMAXLOCALSEQNO.

00262                                         {
00263   return seqNo <= kMAXLOCALSEQNO;
00264 }

void TDbi::SetLogLevel ( int  level  ) 

> Return SQL needed to create VLD table.

Definition at line 269 of file TDbi.cxx.

00269                                 {
00270 //
00271 //
00272 //  Purpose:  Set MessageService log level for package.
00273 //
00274 //  Arguments:
00275 //    level        in    Log level.
00276 //
00277 //  Return:    None.
00278 //
00279 //  Contact:   N. West
00280 //
00281 //  Specification:-
00282 //  =============
00283 //
00284 //  o  Set MessageService log level for package.
00285 
00286 //  Program Notes:-
00287 //  =============
00288 
00289 //  None.
00290 
00291 
00292 
00293 }

void TDbi::SetTimeGate ( const std::string &  tableName,
Int_t  timeGate 
)

Definition at line 297 of file TDbi.cxx.

References fgTimegateTable, SK_DBI_Debug, and SK_DBI_Warn.

Referenced by ClassImp(), and GetTimeGate().

00297                                                                  {
00298 
00299 //  Purpose: Set a time gate for table.
00300 
00301 //  Program Notes:  See GetTimeGate.
00302 
00303   if ( timeGate > 15 && timeGate <= 100*24*60*60 ) {
00304     fgTimegateTable[tableName] = timeGate;
00305     SK_DBI_Debug( "Setting time gate " << timeGate
00306                             << " for " << tableName << "  ");
00307   }
00308   else {
00309     SK_DBI_Warn( "Ignoring  invalid time gate setting " << timeGate
00310                              << " for " << tableName << "  ");
00311   }
00312 }

Here is the caller graph for this function:


Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1