AliRoot Core  edcc906 (edcc906)
AliElasticSearchRootTest.C
Go to the documentation of this file.
1 
33 char *hostName="localhost:9200";
35 
36 void InitElastic();
37 void testExportBinary();
38 void testGetIndexLayout();
39 void testSelect();
40 
41 
42 void AliElasticSearchRootTest(char *phostName=0){
43  if (phostName) hostName=phostName;
44  ::Info("AliElasticSearchRoot::AliElasticSearchRootTest","KeyValue-Begin");
45  InitElastic();
49  testSelect();
50  ::Info("AliElasticSearchRoot::AliElasticSearchRootTest","KeyValue-EndOK");
51 }
52 
53 void InitElastic(){
54  pelastic=new AliElasticSearchRoot(hostName,kFALSE,1);
55  pelastic->SetCertificate(); // default certification="--insecure --cacert CERNRootCertificationAuthority2.crt --netrc-file $HOME/.globus/.elastic/.netrc"
56  pelastic->ls();
57  pelastic->Print();
58 }
59 
65  // Example export MC production table
66  ::Info("AliElasticSearchRoot::ExportBinary","KeyValue-Begin");
68  TTree * tree = info.GetTreeMCPassGuess();
69  TString exportInfo="%IprodName:";
70  Int_t nBranches = tree->GetListOfBranches()->GetEntries();
71  for (Int_t iBranch=0; iBranch<nBranches; iBranch++){
72  exportInfo+= tree->GetListOfBranches()->At(iBranch)->GetName();
73  if (iBranch<nBranches) exportInfo+=":";
74  }
75  Int_t entries = AliTreePlayer::selectWhatWhereOrderBy(tree,exportInfo.Data(),"1", "", 0,100000, "elastic","mctableAnchor.json");
76  pelastic->ExportBinary("/alice_mc/passguess/","mctableAnchor.json","xxx");
77  ::Info("AliElasticSearchRoot::ExportBinary","KeyValue-EndOK");
78  //
79  tree = info.GetTree("QA.TPC","LHC15n","pass2","Logbook");
80  //TObjArray * branches = AliTreePlayer::selectMetadata(tree, "[class==\"dEdx||DCA\"]",0);
81  // 2.) Example all branches of the TPC QA
82  exportInfo="%Irun:";
83  nBranches = tree->GetListOfBranches()->GetEntries();
84  for (Int_t iBranch=0; iBranch<nBranches; iBranch++){
85  exportInfo+= tree->GetListOfBranches()->At(iBranch)->GetName();
86  exportInfo+=":";
87  }
88 
89  entries = AliTreePlayer::selectWhatWhereOrderBy(tree,exportInfo.Data(),"1", "", 0,100000, "elastic","qatpcbulk.json");
90  pelastic->ExportBinary("/alice/qatpcbulk/","qatpcbulk.json","xxx");
91  // 3. export selected branches of the TPC QA
92  TString exportInfo="%ILogbook.LHCperiod:%Ipass.GetName():%Irun:%Prun:";
93  exportInfo+="period.GetName():pass.GetName():run:Logbook.run:";
94  exportInfo+="meanTPCncl:meanMIP;1.5:meanMIPele;1.5:";
95  exportInfo+="grdcar_neg_ASidePhi.fY:grdcar_neg_CSidePhi.fY:grdcar_pos_ASidePhi.fY:grdcar_pos_CSidePhi.fY";
96 
97  entries = AliTreePlayer::selectWhatWhereOrderBy(tree,exportInfo.Data(),"1", "", 0,100000, "elastic","qatpc_test0.json");
98  pelastic->ExportBinary("/alice/qatpc_test0/","qatpc_test0.json","xxx");
99 
100 }
101 
103  ::Info("AliElasticSearchRoot::testExportClass","KeyValue-Begin");
105  TTree *tree = info.GetTree("QA.TPC","LHC15n","pass2","Logbook");
106  TString exportInfo="%Irun:";
107  exportInfo+="period.GetName():";
108  exportInfo+="period.:";
109  exportInfo+="run:";
110  exportInfo+="grdcar_neg_ASidePhi.";
111  Int_t entries = AliTreePlayer::selectWhatWhereOrderBy(tree,exportInfo.Data(),"1", "", 0,100000, "elastic","qatpc_testClass.json");
112  pelastic->ExportBinary("/alice/qatpc_testClass1/","qatpc_testClass.json","xxx");
113  ::Info("AliElasticSearchRoot::testExportClass","KeyValue-End");
114 }
115 
116 void testExportClass() {
117  ::Info("AliElasticSearchRoot::testExportClass","KeyValue-Begin");
119  TTree *tree = info.GetTree("QA.TPC","LHC15n","pass2","Logbook:QA.ITS:QA.TRD");
120  //
121 
122 }
123 
125  //
126  // elastic.GetInde xLayout("/alice/logbook_test0/")->Print();
127  ::Info("AliElasticSearchRoot::GetIndexLayout","KeyValue-Begin");
128  pelastic->GetIndexLayout("alice_mc","passguess","text").Tokenize("\n")->Print();
129  pelastic->GetIndexLayout("alice_mc","passguess",0,kTRUE).Tokenize("\n")->Print();
130  pelastic->GetIndexLayout("alice","qatpc_test0","float").Tokenize("\n")->Print();
131  pelastic->GetIndexLayout("alice","qatpc_test0",0,kTRUE).Tokenize("\n")->Print();
132  //
133  ::Info("AliElasticSearchRoot::GetIndexLayout","KeyValue-EndOK");
134 }
135 
136 void testSelect(){
137  ::Info("AliElasticSearchRoot::select","KeyValue-Begin");
138  TString select="";
139  select= pelastic->select("/alice/qatpc_test0/","*","run>240000&&run<246844&&meanMIP>50",0,1000,"jqEQueryStat,jqEQueryHeader");
140  select= pelastic->select("/alice/qatpc_test0/","*","run>240000&&run<246844&&meanMIP>50",0,1000,"jqEQueryArrayNamed,jqEQueryStat,jqEQueryHeader");
141 
142  select= pelastic->select("/alice/qatpcbulk/","*","run>0&&meanMIP>0",0,1000,",jqEQueryHeader,jqEQueryStat");
143 
144  ::Info("AliElasticSearchRoot::select","KeyValue-EndOK");
145 }
AliElasticSearchRoot - C++ interface to the Elastic –> root tree like- using gSystem->GetFromPipe, Exec, Elastic, painless scripting, curl, jq.
TTree * GetTreeMCPassGuess()
TObjArray * GetIndexLayout(const char *indexName)
void InitElastic()
TTree * tree
char * hostName
TString select(const char *indexName, TString fields, TString query, Int_t first, Int_t size, TString filterArray="")
AliExternalInfo info
void AliElasticSearchRootTest(char *phostName=0)
void Print(Option_t *option="") const
TTree * GetTree(TString type, TString period, TString pass, Int_t buildIndex=1)
static Int_t selectWhatWhereOrderBy(TTree *tree, TString what, TString where, TString orderBy, Int_t firstentry, Int_t nentries, TString outputFormat, TString outputName)
AliElasticSearchRoot * pelastic
void testGetIndexLayout()
void testSelect()
This class gives you an interface to different trees of information spread throughout ALICE...
Int_t ExportBinary(std::string indexName, std::string jsonFile, std::string option)
void SetCertificate(std::string certification="--cacert $HOME/.globus/CERNGridCertificationAuthority.crt --netrc-file $HOME/.globus/.elastic/.netrc")
void testExportClass()
virtual void ls(Option_t *option="") const
List indices in the Elastic server.
void testExportBinary()