Page MenuHomeHEPForge

hugeNtupleRead.cc
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

hugeNtupleRead.cc

#include <iostream>
#include <fstream>
#include <cstdlib>
#include "test_utils.hh"
#include "geners/MultiFileArchive.hh"
#include "npstat/stat/ArchivedNtuple.hh"
#include "npstat/stat/NtupleReference.hh"
using namespace npstat;
using namespace std;
using namespace gs;
static const char* filename;
void usage_and_exit(const char* prog)
{
cerr << "\nUsage: " << parse_progname(prog)
<< " filename\n" << endl;
exit(1);
}
void read_big_tuple()
{
MultiFileArchive ar(filename, "r", "Huge ntuple test");
if (!ar.isReadable())
{
std::cerr << "Failed to open archive \"" << ar.name()
<< "\" for reading" << std::endl;
return;
}
CPP11_auto_ptr<ArchivedNtuple<unsigned long long> > nt =
NtupleReference<ArchivedNtuple<unsigned long long> >(
ar, "example ntuple", "my category").get(0);
unsigned long long buf[10];
const unsigned long nrows = nt->nRows();
const unsigned long ncols = nt->nColumns();
assert(ncols == sizeof(buf)/sizeof(buf[0]));
for (unsigned long i=0; i<nrows; ++i)
{
nt->rowContents(i, buf, ncols);
for (unsigned long j=0; j<ncols; ++j)
if (buf[j] != i*ncols + j)
{
std::cout << "Bad value at row " << i << " and column " << j
<< std::endl;
exit(1);
}
}
}
int main(int argc, char const* argv[])
{
if (argc != 2)
usage_and_exit(argv[0]);
filename = argv[1];
const double t = time_of_run(read_big_tuple, 1);
std::cout << "Program took " << t/1000000 << " sec" << std::endl;
exit(0);
}

File Metadata

Mime Type
text/x-c
Expires
Tue, Sep 30, 4:39 AM (13 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6560787
Default Alt Text
hugeNtupleRead.cc (1 KB)

Event Timeline