#ifndef DBIVALIDITYRECBUILDER_H #define DBIVALIDITYRECBUILDER_H /** * * $Id: IDbiValidityRecBuilder.hxx,v 1.1 2011/01/18 05:49:20 finch Exp $ * * \class COMET::IDbiValidityRecBuilder * * * \brief * Concept Constructor for the set of effective IDbiValidityRec * objects for the current query. * * \brief * Purpose Parse a IDbiInRowStream from a validity query and build * TDbiValidityRecs for the best, with COMET::IVldRange trimmed by neighbouring * validity records of higher priority. For non-aggregated tables * there will only be one IDbiValidityRec, but for aggregated data, * there will be one for each aggregate * * Contact: A.Finch@lancaster.ac.uk * * */ #include #include #include #include "IDbi.hxx" #include "IDbiValidityRec.hxx" #include "IVldContext.hxx" namespace COMET { class IDbiDBProxy; } namespace COMET { class IDbiValidityRecBuilder { public: // Typedefs and enums enum { kMAX_AGGREGATE_NO = 1000 }; // Constructors and destructors IDbiValidityRecBuilder(const IDbiDBProxy& proxy, const COMET::IVldContext& vc, const IDbi::Task& task, Int_t selectDbNo = -1, Bool_t findFullTimeWindow = true); IDbiValidityRecBuilder(const IDbiDBProxy& proxy, const std::string& context, const IDbi::Task& task); IDbiValidityRecBuilder(const IDbiValidityRec& vr, const std::string tableName); virtual ~IDbiValidityRecBuilder(); // State testing member functions std::string GetL2CacheName() const; IDbi::Task GetTask() const { return fTask; } UInt_t GetNumValidityRec() const { return fVRecs.size(); } /// Get index of AggNo or -1 if missing. Int_t IndexOfAggno(Int_t aggNo) const; Bool_t IsExtendedContext() const { return fIsExtendedContext; } const IDbiValidityRec& GetValidityRec(Int_t rowNo) const; const IDbiValidityRec& GetValidityRecFromAggNo(Int_t aggNo) const { return this->GetValidityRec(this->IndexOfAggno(aggNo)); } const IDbiValidityRec& GetValidityRecFromSeqNo(UInt_t SeqNo) const; Bool_t NonAggregated() const { return ! this->IsExtendedContext() && this->GetNumValidityRec() == 1; } // State changing member functions private: // State changing member functions /// Add new aggregate into tables and return its index UInt_t AddNewAgg(const IDbiValidityRec& vrec,Int_t aggNo); /// Add new aggregate gap into tables and return its index UInt_t AddNewGap(Int_t aggNo); void MakeGapRec(const COMET::IVldContext& vc, const std::string& tableName, Bool_t findFullTimeWindow = true); // Data members IDbiValidityRec fGap; // Default (gap) validity record /// True for extended context query. Bool_t fIsExtendedContext; IDbi::Task fTask; // Query task /// Table of effective ValidityRecs. /// For context specific queries indexed by row number 0,.. /// The first row is guaranteed to correspond to aggregate -1, /// although this may be a gap. Other aggregates may come in any order. /// For extended context queries first entry is a gap (to be consistent /// with aggregated query) and all entries are filled in the order they /// are loaded. std::vector fVRecs; /// Map of Aggregate number to index in fVRecs. std::map fAggNoToIndex; ClassDef(IDbiValidityRecBuilder,0) // Creator of eff. ValidityRecs }; }; #endif // DBIVALIDITYRECBUILDER_H