Typedefs | |
| typedef Int_t | Task |
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 { kUnknownDbType = -1, kMySQL = 0, kOracle = 1 } |
| 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 VldTimeStamp &timeStamp) |
| VldTimeStamp | MakeTimeStamp (const std::string &sqlDateTime, Bool_t *ok=0) |
| Bool_t | NotGlobalSeqNo (UInt_t seqNo) |
|
|
|
|
|
Definition at line 79 of file Dbi.h. 00079 { kMAXLOCALSEQNO = 99999999, // Max local SeqNo.
00080 kMAXTABLENAMELEN = 80}; // Max length of table name.
|
|
|
Definition at line 74 of file Dbi.h. 00074 { kDisabled,
00075 kTableMissing,
00076 kDataMissing
00077 };
|
|
|
Definition at line 49 of file Dbi.h. 00049 { kUnknown,
00050 kBool, // concept
00051 kChar, // concept
00052 kUChar, // concept
00053 kTiny,
00054 kUTiny,
00055 kShort,
00056 kUShort,
00057 kInt, // concept
00058 kUInt, // concept
00059 kLong,
00060 kULong,
00061 kFloat, // concept
00062 kDouble,
00063 kString, // concept
00064 kTString,
00065 kDate // concept
00066 };
|
|
|
Definition at line 69 of file Dbi.h. 00069 { kUnknownDbType = -1,
00070 kMySQL = 0,
00071 kOracle = 1
00072 };
|
|
|
Definition at line 41 of file Dbi.h. 00041 { kAnyTask = -1, // Use to disable task selection in context queries.
00042 kDefaultTask = 0
00043 };
|
|
|
Definition at line 45 of file Dbi.h. 00045 { kRootRegime = 0,
00046 kSQLRegime = 1
00047 };
|
|
|
Time gates for each table in secs. Used to trim validity searches.
Definition at line 88 of file Dbi.cxx. References fgTimegateTable, MSG, and SetTimeGate(). Referenced by DbiValidityRecBuilder::DbiValidityRecBuilder(), DbiDBProxy::FindTimeBoundaries(), DbiValidityRecBuilder::MakeGapRec(), and DbiDBProxy::QueryValidity(). 00088 {
00089
00090 // Purpose: Get a suitable time gate for table.
00091
00092 // Program Notes:-
00093 // =============
00094
00095 // A time gate is applied to all primary (validity) queries to save time
00096 // and ensure that gaps are not missed. Ideally the gate needs to be
00097 // of order of a typical validity range. Much longer and unneeded
00098 // VLD records are processed, much shorter and the query results will
00099 // expire too soon. Both increase I/O.
00100 //
00101 // The system provides a default for each table and DbiValidityRecBuilder
00102 // updates it if grossly wrong.
00103
00104 // Set default if looking up table for the first time.
00105 std::map<std::string,Int_t>::iterator
00106 tablePtr = fgTimegateTable.find(tableName);
00107 if ( tablePtr == fgTimegateTable.end()
00108 ) Dbi::SetTimeGate(tableName,10*24*60*60);
00109
00110 MSG("Dbi",Msg::kDebug) << "Returning time gate " << fgTimegateTable[tableName]
00111 << " for " << tableName << endl;
00112 return fgTimegateTable[tableName];
00113
00114 }
|
|
||||||||||||
|
Definition at line 118 of file Dbi.cxx. Referenced by DbiCascader::CreateTemporaryTable(), and DTFtest(). 00119 {
00120 //
00121 //
00122 // Purpose: Return string "create [temporary] table tableNameXXX" to make table xxxVLD
00123 //
00124 // Program Notes:-
00125 // =============
00126
00127 // If the format of Validity Tables is changed then this function must
00128 // be updated as that format is hardwired into an SQL CREATE TABLE
00129 // command in this function.
00130
00131 string sql;
00132 sql += "create ";
00133 if ( isTemporary ) sql += "temporary ";
00134 sql += "table ";
00135 sql += tableName;
00136 sql += "VLD ( ";
00137 sql += " SEQNO integer not null primary key,";
00138 sql += " TIMESTART datetime not null,";
00139 sql += " TIMEEND datetime not null,";
00140 sql += " DETECTORMASK tinyint,";
00141 sql += " SIMMASK tinyint,";
00142 sql += " TASK integer,";
00143 sql += " AGGREGATENO integer,";
00144 sql += " CREATIONDATE datetime not null,";
00145 sql += " INSERTDATE datetime not null ) ";
00146 return sql;
00147 }
|
|
|
Definition at line 151 of file Dbi.cxx. References VldTimeStamp::AsString(). Referenced by DbmLogFile::LogMsg(), and DbiRollbackDates::Set(). 00151 {
00152 //
00153 //
00154 // Purpose: Convert VldTimeStamp to SQL DateTime string.
00155 //
00156 // Arguments:
00157 // timeStamp in VldTimeStamp to be converted.
00158 //
00159 // Return: SQL DateTime string corresponding to VldTimeStamp.
00160 //
00161 // Contact: N. West
00162 //
00163 // Specification:-
00164 // =============
00165 //
00166 // o Return SQL DateTime string corresponding to VldTimeStamp.
00167
00168 // Program Notes:-
00169 // =============
00170
00171 // The format of a SQL DateTime string is:-
00172 //
00173 // YYYY-MM-DD HH:MM:SS
00174 // e.g. 2001-01-03 00:00:00
00175 // 0123456789012345678901234567890123"
00176
00177 return timeStamp.AsString("s");
00178
00179 }
|
|
||||||||||||
|
Definition at line 182 of file Dbi.cxx. References VldTimeStamp::GetDate(), and MSG. Referenced by DbiSqlValPacket::Fill(), DbmModule::LogEntry(), DbiResultSet::operator>>(), and DbmModule::Query(). 00183 {
00184 //
00185 //
00186 // Purpose: Convert SQL DateTime string to VldTimeStamp.
00187 //
00188 // Arguments:
00189 // sqlDateTime in SQL DateTime string to be convered.
00190 // ok in Optional return flag
00191 // If not supplied, report illegal dates
00192 //
00193 // Return: VldTimeStamp corresponding to SQL DateTime string.
00194 //
00195 // Contact: N. West
00196 //
00197 // Specification:-
00198 // =============
00199 //
00200 // o Return VldTimeStamp corresponding to SQL DateTime string.
00201
00202 // Program Notes:-
00203 // =============
00204
00205 // Note that there is only white space between day and hour
00206 // so no need for dummy separator.
00207
00208 struct date {
00209 int year;
00210 int month;
00211 int day;
00212 int hour;
00213 int min;
00214 int sec;};
00215 char dummy;
00216
00217 static string lo = "1970-01-01 00:00:00";
00218 static string hi = "2038-01-19 03:14:07";
00219
00220 // Set up defaults from 0:0am today.
00221 VldTimeStamp nowTS;
00222 int nowDate = nowTS.GetDate();
00223 date defaultDate = {nowDate/10000, nowDate/100%100, nowDate%100,0,0,0};
00224 date input = defaultDate;
00225
00226 istringstream in(sqlDateTime);
00227 in >> input.year >> dummy >> input.month >> dummy >> input.day
00228 >> input.hour >> dummy >> input.min >> dummy >> input.sec;
00229
00230 if ( ok ) *ok = kTRUE;
00231 if ( sqlDateTime < lo || sqlDateTime > hi ) {
00232 if ( ok ) *ok = kFALSE;
00233 else {
00234 static int bad_date_count = 0;
00235 if ( ++bad_date_count <= 20 ) {
00236 const char* last = (bad_date_count == 20) ? "..Last Message.. " : "";
00237 MSG("Dbi",Msg::kError)
00238 << "Bad date string: " << sqlDateTime
00239 << " parsed as "
00240 << input.year << " "
00241 << input.month << " "
00242 << input.day << " "
00243 << input.hour << " "
00244 << input.min << " "
00245 << input.sec
00246 << "\n Outside range " << lo
00247 << " to " << hi << last << endl;
00248 }
00249 }
00250
00251 input = defaultDate;
00252 }
00253
00254 return VldTimeStamp(input.year,input.month,input.day,
00255 input.hour,input.min,input.sec);
00256
00257 }
|
|
|
Definition at line 260 of file Dbi.cxx. Referenced by DbmModule::Import(). 00260 {
00261 return seqNo <= kMAXLOCALSEQNO;
00262 }
|
|
|
> Return SQL needed to create VLD table.
Definition at line 267 of file Dbi.cxx. References MsgService::GetStream(), MsgService::Instance(), and MsgStream::SetLogLevel(). Referenced by main(). 00267 {
00268 //
00269 //
00270 // Purpose: Set MessageService log level for package.
00271 //
00272 // Arguments:
00273 // level in Log level.
00274 //
00275 // Return: None.
00276 //
00277 // Contact: N. West
00278 //
00279 // Specification:-
00280 // =============
00281 //
00282 // o Set MessageService log level for package.
00283
00284 // Program Notes:-
00285 // =============
00286
00287 // None.
00288
00289 MsgService::Instance()->GetStream("Dbi")->SetLogLevel(level);
00290
00291 }
|
|
||||||||||||
|
Definition at line 295 of file Dbi.cxx. References fgTimegateTable, and MSG. Referenced by DbiValidityRecBuilder::DbiValidityRecBuilder(), and GetTimeGate(). 00295 {
00296
00297 // Purpose: Set a time gate for table.
00298
00299 // Program Notes: See GetTimeGate.
00300
00301 if ( timeGate > 15 && timeGate <= 100*24*60*60 ) {
00302 fgTimegateTable[tableName] = timeGate;
00303 MSG("Dbi",Msg::kDebug) << "Setting time gate " << timeGate
00304 << " for " << tableName << endl;
00305 }
00306 else {
00307 MSG("Dbi",Msg::kWarning) << "Ignoring invalid time gate setting " << timeGate
00308 << " for " << tableName << endl;
00309 }
00310 }
|
1.3.9.1