Skip to content

Commit

Permalink
Merge pull request #562 from rlcee/dbtool_210812
Browse files Browse the repository at this point in the history
add three new dbTool functions
  • Loading branch information
brownd1978 authored Aug 19, 2021
2 parents 1b84e24 + fd1636b commit 92957f1
Show file tree
Hide file tree
Showing 5 changed files with 913 additions and 144 deletions.
56 changes: 47 additions & 9 deletions DbService/inc/DbTool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//

#include <map>
#include <list>
#include "Offline/DbService/inc/DbReader.hh"
#include "Offline/DbService/inc/DbSql.hh"
#include "Offline/DbService/inc/DbEngine.hh"
Expand Down Expand Up @@ -43,10 +44,11 @@ namespace mu2e {
int printIov();
int printGroup();
int printExtension();
int printVersions();
int printPurposes();
int printTables();
int printLists();
int printVersion();
int printPurpose();
int printTable();
int printList();
int printSet();

int printCIDLine(int cid, int indent=0);
int printIOVLine(int iov, int details=0, int indent=0);
Expand All @@ -57,21 +59,46 @@ namespace mu2e {

int commitCalibration();
int commitCalibrationTable(DbTable::cptr_t const& ptr,
bool qdr=false, bool admin=false);
bool admin=false);
int commitCalibrationList(DbTableCollection& coll,
bool qai=false, bool qag=false,
bool qdr=false, bool admin=false);
bool admin=false);
int commitIov(int& iid, int cid=0, std::string iovtext="");
int commitGroup(int& gid, std::vector<int> iids=std::vector<int>());
int commitExtension();
int commitExtension(int& eid, std::string purpose="",
std::string version="",
std::vector<int> gids=std::vector<int>());
int commitTable();
int commitList();
int commitPurpose();
int commitVersion();
int commitPatch();
int verifySet();

int findPidVid(std::string purpose, std::string version, int& pid, int& vid);
int testUrl();

private:

// a couple of structures, useful in some operations
class eIoV {
public:
eIoV():_iid(0),_cid(0) {}
eIoV(int iid, int cid, DbIoV const& iov):_iid(iid),_cid(cid),_iov(iov) {}
int iid() {return _iid;}
int cid() {return _cid;}
DbIoV& iov() {return _iov;}
void setIid(int iid) {_iid = iid;}
private:
int _iid;
int _cid;
DbIoV _iov;
};
// map key is tid
typedef std::map<int,std::list<eIoV>> eiovMap;

// look up purpose and version IDs, given text or numbers
int findPidVid(std::string purpose, std::string version, int& pid, int& vid);

int prettyTable(std::string title, std::string csv);
int prettyColumns(std::vector<std::string> titles,
std::vector<std::vector<std::string> > entries);
Expand All @@ -80,7 +107,18 @@ namespace mu2e {
int getArgs(map_ss& fArgs);
int help();
std::vector<int> intList(std::string const& arg);
private:
std::vector<mu2e::DbIoV> runList(std::string const& arg);

// expand a gid into a vetor of iovs for each tid
// extend because it does not zero eset
int extendEiovMap(int gid, eiovMap& eset, int& minrun, int& maxrun);

// when committing several items, sometime the later items depend
// on fnding the earlier items in the cached val structure
// this is a way to refresh the val structure after the earlier commits
// Take caution with local caching of val info..
int refresh();


int _verbose;
bool _pretty;
Expand Down
Loading

0 comments on commit 92957f1

Please sign in to comment.