The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
XMLCatalogTestRead.cpp File Reference
#include "XMLFileCatalog.h"
Include dependency graph for XMLCatalogTestRead.cpp:

Go to the source code of this file.

Functions

int testXMLFileCatalogRead (int argc, char **argv)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 18 of file XMLCatalogTestRead.cpp.

18{ return testXMLFileCatalogRead( argc, argv ); }
int testXMLFileCatalogRead(int argc, char **argv)

◆ testXMLFileCatalogRead()

int testXMLFileCatalogRead ( int argc,
char ** argv )

Definition at line 72 of file XMLCatalogTest.cpp.

72 {
73 std::vector<std::string> fids;
74 std::string fname = "file:test.xml";
75 if ( argc > 1 ) fname = argv[1];
76 bool prt = argc < 2;
77 time_t start = time( nullptr );
78 XMLFileCatalog c( fname, nullptr );
79 c.init();
80 std::cout << "File loaded in " << time( nullptr ) - start << " seconds. " << std::endl;
81 start = time( nullptr );
82 c.getFID( fids );
83 std::cout << "FIDs scanned in " << time( nullptr ) - start << " seconds. " << std::endl;
84 start = time( nullptr );
85 size_t mult = prt ? 1 : 10;
86 std::cout << mult * fids.size() << std::endl;
87 for ( size_t i = 0, tot = ( mult * fids.size() ); i < tot; ++i ) {
88 size_t ent = i % fids.size();
89 if ( ent == 0 ) std::cout << i << std::endl;
90 std::string fid = fids[ent];
91 XMLFileCatalog::Files pfn, lfn;
92 XMLFileCatalog::Attributes attrs;
93 c.getLFN( fid, lfn );
94 for ( auto& elem : lfn ) {
95 if ( !c.existsLFN( elem.first ) ) {
96 std::cout << "Error LFN existence of :" << elem.second << std::endl;
97 return 1;
98 }
99 std::string f = c.lookupLFN( elem.first );
100 if ( f != fid ) {
101 std::cout << "Error LFN lookup of :" << elem.second << std::endl;
102 return 1;
103 }
104 }
105 c.getPFN( fid, pfn );
106 for ( auto& elem : pfn ) {
107 if ( !c.existsPFN( elem.first ) ) {
108 std::cout << "Error PFN existence of :" << elem.second << std::endl;
109 return 1;
110 }
111 std::string f = c.lookupPFN( elem.first );
112 if ( f != fid ) {
113 std::cout << "Error PFN lookup of :" << elem.second << std::endl;
114 return 1;
115 }
116 }
117 c.getMetaData( fid, attrs );
118 size_t n = lfn.size() > pfn.size() ? lfn.size() : pfn.size();
119 n = n > attrs.size() ? n : attrs.size();
120 if ( prt ) {
121 std::cout << "FID:" << fid << std::endl;
122 for ( size_t j = 0; j < n; ++j ) {
123 if ( j < lfn.size() )
124 std::cout << lfn[j].first << " ";
125 else
126 std::cout << " ";
127 if ( j < pfn.size() )
128 std::cout << pfn[j].first << " ";
129 else
130 std::cout << " ";
131 if ( j < attrs.size() )
132 std::cout << attrs[j].first << " " << attrs[j].second << " ";
133 else
134 std::cout << " ";
135 std::cout << std::endl;
136 }
137 }
138 }
139 time_t end = time( nullptr ) - start;
140 std::cout << "Used " << end << " seconds (" << (long)fids.size() * mult << " entries)."
141 << " Corresponding to " << float( end ) / float( fids.size() * mult ) << " entries/second." << std::endl;
142 return 0;
143}
This class constitutes the core of the XML based FileCatalog API for POOL.
list argv
Definition gaudirun.py:327