Logo ROOT  
Reference Guide
df027_SQliteDependencyOverVersion.C File Reference

Detailed Description

View in nbviewer Open in SWAN Plot the ROOT downloads based on the version reading a remote sqlite3 file.

This tutorial uses the Reduce method which allows to extract the minimum time stored in the SQlite3 database. The next step is to create a TH1F Histogram, which will be filled with the values stored in two different columns from the database. This procedure is simplified with a lambda expression that takes as parameters the values stored in the "Time" and "Version" columns.

void df027_SQliteDependencyOverVersion () {
auto rdfb = ROOT::RDF::MakeSqliteDataFrame("http://root.cern/files/root_download_stats.sqlite", "SELECT * FROM accesslog;" );
auto minTimeStr = *rdfb.Reduce([](std::string a, std::string b) {return std::min(a, b);}, "Time", std::string("Z"));
std::cout << "Minimum time is '" << minTimeStr << "'" << std::endl;
double minTime = TDatime(minTimeStr.c_str()).Convert();
double now = TDatime().Convert();
auto rdf = rdfb.Define("datime", [](const std::string &time){return TDatime(time.c_str()).Convert();}, {"Time"});
auto h614 = rdf.Filter([](const std::string &v){ return 0 == v.find("6.14");}, {"Version"})
.Histo1D({"h614", "Download time for version 6.14", 16, minTime, now}, {"datime"});
auto h616 = rdf.Filter([](const std::string &v){ return 0 == v.find("6.16");}, {"Version"})
.Histo1D({"h616", "Download time for version 6.16", 16, minTime, now}, {"datime"});
auto h618 = rdf.Filter([](const std::string &v){ return 0 == v.find("6.18");}, {"Version"})
.Histo1D({"h618", "Download time for version 6.18", 16, minTime, now}, {"datime"});
// Add here a newer version!
auto histoList = {h614, h616, h618};
auto canvases = new std::vector<TCanvas*>(histoList.size());
auto histoIdx = 0U;
for (auto histo : histoList) {
canvases->at(histoIdx) = new TCanvas();
histo->GetXaxis()->SetNdivisions(512, kFALSE);
const Bool_t kFALSE
Definition: RtypesCore.h:101
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
R__EXTERN TStyle * gStyle
Definition: TStyle.h:414
The Canvas class.
Definition: TCanvas.h:23
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
Definition: TDatime.cxx:182
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition: TStyle.cxx:1590
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition: TStyle.cxx:1808
RDataFrame MakeSqliteDataFrame(std::string_view fileName, std::string_view query)
Factory method to create a SQlite RDataFrame.
Definition: RSqliteDS.cxx:546
auto * a
Definition: textangle.C:12
August 2018
Alexandra-Maria Dobrescu

Definition in file df027_SQliteDependencyOverVersion.C.