| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Functions
XMLCatalogTest.cpp File Reference
`#include "XMLFileCatalog.h"`
`#include <cstdio>`
`#include <ctime>`
`#include <iostream>`
`#include <sstream>`
Include dependency graph for XMLCatalogTest.cpp:

Go to the source code of this file.

## Functions
int | testXMLFileCatalogWrite (int argc, char **argv)
int | testXMLFileCatalogRead (int argc, char **argv)

## Function Documentation

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

Definition at line 63 of file XMLCatalogTest.cpp.

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

int testXMLFileCatalogWrite | ( | int | argc,
|  | char ** | argv
| ) |  |

Definition at line 9 of file XMLCatalogTest.cpp.

10 {
11 int nwrite = 10;
12 std::string fname = "file:test.xml";
13 if ( argc > 1 ) fname = argv[1];
14 if ( argc > 2 ) nwrite = ::atol( argv[2] );
15 XMLFileCatalog c( fname, nullptr );
16 c.init();
17 std::vector<std::string> fids;
18 c.getFID( fids );
19 time_t start = time( nullptr );
20 for ( size_t n = fids.size(), i = n; i < n + nwrite; ++i ) {
21 std::ostringstream txt;
22 if ( 0 == ( ( i - n ) % 10000 ) ) std::cout << i - n << std::endl;
23 std::string fid = c.createFID();
24 c.registerFID( fid );
25 txt << "PFN1_Test_" << i << ".dat";
26 c.registerPFN( fid, txt.str(), "ROOT" );
27 c.registerPFN( fid, txt.str(), "ROOT" );
28 txt.str( "" );
29 txt << "PFN2_Test_" << i << ".dat";
30 c.registerPFN( fid, txt.str(), "ROOT" );
31 txt.str( "" );
32 txt << "PFN3_Test_" << i << ".dat";
33 c.registerPFN( fid, txt.str(), "ROOT" );
34 txt.str( "" );
35 txt << "lfn1_Test_" << i << ".dat";
36 c.registerLFN( fid, txt.str() );
37 txt.str( "" );
38 txt << "lfn2_Test_" << i << ".dat";
39 c.registerLFN( fid, txt.str() );
40 txt.str( "" );
41 txt << "lfn3_Test_" << i << ".dat";
42 c.registerLFN( fid, txt.str() );
43 c.setMetaData( fid, "Name1", "Value1" );
44 c.setMetaData( fid, "Name1", "Value111" );
45 c.setMetaData( fid, "Name2", "Value2" );
46 c.setMetaData( fid, "Name3", "Value3" );
47 }
48 time_t end = time( nullptr ) - start;
49 std::cout << "Used " << end << " seconds."
50 << " corresponding to " << float( end ) / float( nwrite ) << " entries/second." << std::endl;
51 if ( c.dirty() ) {
52 c.commit();
53 time_t saved = time( nullptr ) - ( start + end );
54 std::cout << "Used " << saved << " seconds."
55 << " corresponding to " << float( saved ) / float( nwrite ) << " entries/second." << std::endl;
56 } else {
57 std::cout << "Error: Catalog is not dirty after inserting records." << std::endl;
58 return 1;
59 }
60 return 0;
61 }
gaudirun.c
c
Definition: gaudirun.py:407
gaudirun.argv
list argv
Definition: gaudirun.py:235
std::endl
T endl(T...args)
plotSpeedupsPyRoot.time
time
Definition: plotSpeedupsPyRoot.py:154
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:228
std::ostringstream
STL class.
IOTest.start
start
Definition: IOTest.py:99
std::ostringstream::str
T str(T...args)
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
plotBacklogPyRoot.argc
argc
Definition: plotBacklogPyRoot.py:138
std::vector::size
T size(T...args)
std::vector< std::string >
Gaudi::XMLFileCatalog
This class constitutes the core of the XML based FileCatalog API for POOL.
Definition: XMLFileCatalog.h:26
std::cout