DbiResultKey Class Reference

#include <DbiResultKey.h>

List of all members.

Classes

struct  VRecKey

Public Member Functions

 DbiResultKey (const DbiResultKey *that=0)
 DbiResultKey (std::string tableName, std::string rowName, UInt_t seqno, VldTimeStamp ts)
 .....................................................................
virtual ~DbiResultKey ()
std::string AsString () const
Float_t Compare (const DbiResultKey *that) const
Int_t GetNumVrecs () const
std::string GetTableRowName () const
Bool_t IsEqualTo (const DbiResultKey *that) const
void AddVRecKey (UInt_t seqno, VldTimeStamp ts)

Static Public Member Functions

static const DbiResultKeyGetEmptyKey ()

Private Attributes

std::string fTableName
 Name of database table.
std::string fRowName
 Name of row objects.
std::list< DbiResultKey::VRecKeyfVRecKeys
 Key for individual DbiValidityRec.
Int_t fNumVRecKeys
 Optimisation: list::size() is slow!

Static Private Attributes

static DbiResultKey fgEmptyKey

Detailed Description

Id
DbiResultKey.h,v 1.8 2007/01/28 01:44:20 rhatcher Exp

Definition at line 34 of file DbiResultKey.h.


Constructor & Destructor Documentation

DbiResultKey::DbiResultKey ( const DbiResultKey that = 0  ) 

Definition at line 35 of file DbiResultKey.cxx.

References Msg::kVerbose, LEA_CTOR, and MSG.

00035                                                             :
00036 fNumVRecKeys(0)
00037 {
00038 //
00039 //
00040 //  Purpose:  Default constructor
00041 //
00042 
00043   LEA_CTOR    //Leak Checker
00044 
00045   MSG("Dbi", Msg::kVerbose) << "Creating DbiResultKey" << endl;
00046   if ( that ) *this = *that;
00047 }

DbiResultKey::DbiResultKey ( std::string  tableName,
std::string  rowName,
UInt_t  seqno,
VldTimeStamp  ts 
)

.....................................................................

Definition at line 51 of file DbiResultKey.cxx.

References AddVRecKey(), Msg::kVerbose, LEA_CTOR, and MSG.

00054                                             :
00055 fTableName(tableName),
00056 fRowName(rowName),
00057 fNumVRecKeys(0)
00058 {
00059 //
00060 //
00061 //  Purpose:  Standard constructor
00062 //
00063 //  Contact:   N. West
00064 //
00065 //  Specification:-
00066 //  =============
00067 //
00068 //  o  Create DbiResultKey.
00069 
00070   LEA_CTOR    //Leak Checker
00071 
00072   MSG("Dbi", Msg::kVerbose) << "Creating DbiResultKey" << endl;
00073 
00074   this->AddVRecKey(seqno,ts);
00075 }

DbiResultKey::~DbiResultKey (  )  [virtual]

Definition at line 79 of file DbiResultKey.cxx.

References Msg::kVerbose, LEA_DTOR, and MSG.

00079                             {
00080 //
00081 //
00082 //  Purpose: Destructor
00083 //
00084 //  Contact:   N. West
00085 //
00086 //  Specification:-
00087 //  =============
00088 //
00089 //  o  Destroy DbiResultKey
00090 
00091   LEA_DTOR    //Leak Checker
00092 
00093   MSG("Dbi", Msg::kVerbose) << "Destroying DbiResultKey" << endl;
00094 
00095 }


Member Function Documentation

void DbiResultKey::AddVRecKey ( UInt_t  seqno,
VldTimeStamp  ts 
)

Definition at line 99 of file DbiResultKey.cxx.

References fNumVRecKeys, and fVRecKeys.

Referenced by DbiResultAgg::CreateKey(), and DbiResultKey().

00099                                                            {
00100 //
00101 //
00102 //  Purpose:  Add a DbiValidityRec key.
00103 //
00104 
00105   fVRecKeys.push_back(VRecKey(seqno,ts));
00106   ++fNumVRecKeys;
00107 
00108 }

std::string DbiResultKey::AsString (  )  const

Definition at line 112 of file DbiResultKey.cxx.

References VldTimeStamp::AsString(), fNumVRecKeys, fRowName, fTableName, and fVRecKeys.

Referenced by DbiRecord::AdoptKey(), and DbiRecord::DeleteKey().

00112                                        {
00113 //
00114 //
00115 //  Purpose:  Return a string that summarises this key giving:-
00116 //            1)  The table and row names.
00117 //            2)  The number of validity records (aggregates)
00118 //            3)  The range of SEQNOs
00119 //            4)  The range of CREATIONDATEs.
00120 
00121   ostringstream os;
00122   os << "Table:" << fTableName << " row:" << fRowName;
00123   if ( fVRecKeys.empty() ) os << " No vrecs";
00124   else {
00125     os << ".  " << fNumVRecKeys << " vrec";
00126     if ( fNumVRecKeys > 1 ) os << "s (seqno min..max;creationdate min..max):";
00127     else                    os << " (seqno;creationdate):";
00128     os << " ";
00129     std::list<VRecKey>::const_iterator itr    = fVRecKeys.begin();
00130     std::list<VRecKey>::const_iterator itrEnd = fVRecKeys.end();
00131     UInt_t seqnoMin    = itr->SeqNo;
00132     UInt_t seqnoMax    = seqnoMin;
00133     VldTimeStamp tsMin = itr->CreationDate;
00134     VldTimeStamp tsMax = tsMin;
00135     ++itr;
00136     while ( itr != itrEnd ) {
00137       UInt_t       seqno = itr->SeqNo;
00138       VldTimeStamp ts    = itr->CreationDate;
00139       if ( seqno < seqnoMin ) seqnoMin = seqno;
00140       if ( seqno > seqnoMax ) seqnoMax = seqno;
00141       if (    ts < tsMin    ) tsMin    = ts;
00142       if (    ts > tsMax    ) tsMax    = ts;
00143       ++itr;
00144     }
00145     os << seqnoMin;
00146     if ( seqnoMin < seqnoMax ) os << ".." << seqnoMax;
00147     os << ";" << tsMin.AsString("s");
00148     if ( tsMin < tsMax ) os << ".." <<  tsMax.AsString("s");
00149   }
00150   return string(os.str());
00151 
00152 }

Float_t DbiResultKey::Compare ( const DbiResultKey that  )  const

Definition at line 155 of file DbiResultKey.cxx.

References fRowName, fTableName, fVRecKeys, GetNumVrecs(), Msg::kDebug, and MSG.

Referenced by IsEqualTo().

00155                                                             {
00156 //
00157 //
00158 //  Purpose:  Compare 2 DbiResultKeys
00159 //
00160 //  Return:    = -2. Table names don't match.
00161 //             = -1. Table names match but row names don't 
00162 //                   i.e. contain different DbiTableRow sub-classes.
00163 //             >= f  Table and row names match and fraction f of the
00164 //                   SEQNOs have same creation date.
00165 //                   So f = 1.  = perfect match.
00166 
00167 //  Program Notes:-
00168 //  =============
00169 
00170 //  None.
00171 
00172   // Check in table and row names.
00173   if ( fTableName != that->fTableName ) return -2.;
00174   if ( fRowName   != that->fRowName   ) return -1.;
00175 
00176   // Pick the key with the most entries and compare the other to it.
00177 
00178   MSG("Dbi",Msg::kDebug) << "Comparing " << *this << " to " 
00179                         << *that << endl;
00180 
00181   const DbiResultKey* keyBig   = this;
00182   const DbiResultKey* keySmall = that;
00183   if ( that->GetNumVrecs() > this->GetNumVrecs() ) {
00184     keyBig   = that;
00185     keySmall = this;
00186   }
00187   int numVrecs = keyBig->GetNumVrecs();
00188   if ( numVrecs == 0 ) return 0.;
00189 
00190   std::map<UInt_t,VldTimeStamp> seqnoToCreationDate;
00191   std::list<DbiResultKey::VRecKey>::const_iterator itrEnd = keyBig->fVRecKeys.end();
00192   for (  std::list<DbiResultKey::VRecKey>::const_iterator itr = keyBig->fVRecKeys.begin();
00193          itr != itrEnd;
00194          ++itr ) seqnoToCreationDate[itr->SeqNo] = itr->CreationDate;
00195   float match = 0;
00196   itrEnd = keySmall->fVRecKeys.end();
00197   for (  std::list<DbiResultKey::VRecKey>::const_iterator itr = keySmall->fVRecKeys.begin();
00198          itr != itrEnd;
00199          ++itr ) {
00200     MSG("Dbi",Msg::kDebug) << "Comparing seqno " << itr->SeqNo << " with creation date " << itr->CreationDate
00201                          << " to " <<  seqnoToCreationDate[itr->SeqNo] << endl;
00202     if ( seqnoToCreationDate[itr->SeqNo] == itr->CreationDate ) ++match;
00203   }
00204   MSG("Dbi",Msg::kDebug) << "Match results: " << match << " out of " << numVrecs << endl;
00205 
00206   return match/numVrecs;
00207 
00208 }

static const DbiResultKey* DbiResultKey::GetEmptyKey (  )  [inline, static]

Definition at line 53 of file DbiResultKey.h.

References fgEmptyKey.

Referenced by DbiResultPtr< T >::GetKey(), and DbiResult::GetKey().

00053 { return &fgEmptyKey; }

Int_t DbiResultKey::GetNumVrecs (  )  const [inline]

Definition at line 54 of file DbiResultKey.h.

References fNumVRecKeys.

Referenced by Compare().

00054 { return fNumVRecKeys; }

std::string DbiResultKey::GetTableRowName (  )  const

Definition at line 212 of file DbiResultKey.cxx.

References fRowName, and fTableName.

00212                                               {
00213 //
00214 //
00215 //  Purpose:  Return TableName::RowName
00216 
00217   ostringstream os;
00218   os << fTableName << "::" << fRowName;
00219   return os.str();
00220 
00221 }

Bool_t DbiResultKey::IsEqualTo ( const DbiResultKey that  )  const [inline]

Member Data Documentation

Definition at line 73 of file DbiResultKey.h.

Referenced by GetEmptyKey().

Int_t DbiResultKey::fNumVRecKeys [private]

Optimisation: list::size() is slow!

Definition at line 87 of file DbiResultKey.h.

Referenced by AddVRecKey(), AsString(), and GetNumVrecs().

std::string DbiResultKey::fRowName [private]

Name of row objects.

Definition at line 81 of file DbiResultKey.h.

Referenced by AsString(), Compare(), and GetTableRowName().

std::string DbiResultKey::fTableName [private]

Name of database table.

Definition at line 78 of file DbiResultKey.h.

Referenced by AsString(), Compare(), and GetTableRowName().

Key for individual DbiValidityRec.

Definition at line 84 of file DbiResultKey.h.

Referenced by AddVRecKey(), AsString(), and Compare().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1