ATLAS Offline Software
Loading...
Searching...
No Matches
v5_DataWriter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <time.h>
6#include <sstream>
7#include <stdlib.h>
8#include "v5_Guid.h"
9#include "ers/ers.h"
10
11#include <boost/shared_ptr.hpp>
12
14#include "EventStorage/DataWriterCallBack.h"
15#include "EventStorage/FileNameCallback.h"
16#include "EventStorage/RawFileName.h"
17#include "EventStorage/EventStorageIssues.h"
18#include "EventStorage/SimpleFileName.h"
19#include "v5_DataBuffer.h"
20
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <unistd.h>
24#include <stdio.h>
25
26using namespace std;
27using namespace offline_EventStorage_v5;
28using EventStorage::DataWriterCallBack;
29using EventStorage::DWError;
30using EventStorage::FileNameCallback;
31using EventStorage::SimpleFileName;
32
33namespace{
34 char *
35 charAddress(auto & val){
36 return reinterpret_cast<char *>(&val);
37 }
38 const char *
39 ccharAddress(const auto & val){
40 return reinterpret_cast<const char *>(&val);
41 }
42
43 Bytef * //Bytef is defined in zlib
44 bytefAddress(auto & val){
45 return reinterpret_cast<Bytef *>(&val);
46 }
47 const Bytef * //Bytef is defined in zlib
48 cbytefAddress(auto & val){
49 return reinterpret_cast<const Bytef *>(&val);
50 }
51
52}
53
54// constructors
56DataWriter(const string& writingPath,
57 boost::shared_ptr<FileNameCallback> theFNCB,
58 const run_parameters_record& rPar,
59 const std::string& project,
60 const std::string& streamType,
61 const std::string& streamName,
62 const std::string& stream,
63 const unsigned int lumiBlockNumber,
64 const std::string& applicationName,
65 const std::vector<std::string>& fmdStrings,
66 const CompressionType compression,
67 const unsigned int compLevel)
68{
69 initDW(writingPath, theFNCB, rPar, project, streamType, streamName, stream, lumiBlockNumber, applicationName, fmdStrings, compression, compLevel);
70
71}
72
74DataWriter(const string& writingPath,
75 const string& fileNameCore,
76 const run_parameters_record& rPar,
77 const freeMetaDataStrings& fmdStrings,
78 const unsigned int startIndex,
79 const CompressionType compression,
80 const unsigned int compLevel)
81{
82 boost::shared_ptr<daq::RawFileName>
83 fileName(new daq::RawFileName(fileNameCore));
84
85 if ( fileName->hasValidCore() ) {
86 m_project = fileName->project();
87 m_streamType = fileName->streamType();
88 m_streamName = fileName->streamName();
89 m_stream = fileName->stream();
90 m_lumiBlockNumber = fileName->lumiBlockNumber();
91 m_applicationName = fileName->applicationName();
92 } else {
93 std::stringstream mystream;
94 mystream << "FileName " << fileName->fileName()
95 << " has failed interpretation."
96 << " The file header will have no values for "
97 << " project, stream, lumiBlock and appName";
98 ERS_DEBUG(1,mystream.str());
99 // EventStorage::RawFileNameIssue myissue(ERS_HERE, mystream.str().c_str() );
100 // ers::warning(myissue);
101 m_project = "";
102 m_streamType = "";
103 m_streamName = "";
104 m_stream = "";
107 }
108
109 fileName->setFileSequenceNumber(startIndex);
110
111 initDW(writingPath, fileName, rPar, m_project, m_streamType, m_streamName,
113 fmdStrings, compression,compLevel);
114
115}
116
117
119DataWriter(const string& writingPath,
120 const string& fileNameCore,
121 const run_parameters_record& rPar,
122 const std::string& project,
123 const std::string& streamType,
124 const std::string& streamName,
125 const std::string& stream,
126 const unsigned int lumiBlockNumber,
127 const std::string& applicationName,
128 const std::vector<std::string>& fmdStrings,
129 const CompressionType compression,
130 const unsigned int compLevel)
131{
132 boost::shared_ptr<FileNameCallback> fileName(new SimpleFileName(fileNameCore));
133 initDW(writingPath, fileName, rPar, project, streamType, streamName, stream, lumiBlockNumber, applicationName, fmdStrings, compression, compLevel);
134
135}
136
137// destructor
139{
140 ERS_DEBUG(1,"DataWriter::~DataWriter() called.");
141
142 m_file_end_record.status = 1; // This identifies the end of the sequence.
144
145 delete m_compressed;
146
147 ERS_DEBUG(1,"DataWriter::~DataWriter() finished.");
148}
149
150
152initDW(const string& writingPath,
153 boost::shared_ptr<FileNameCallback> theFNCB,
154 const run_parameters_record& rPar,
155 const std::string& project,
156 const std::string& streamType,
157 const std::string& streamName,
158 const std::string& stream,
159 const unsigned int lumiBlockNumber,
160 const std::string& applicationName,
161 const std::vector<std::string>& fmdStrings,
162 const CompressionType compression,
163 const unsigned int compLevel)
164{
166 m_streamType = streamType;
167 m_streamName = streamName;
168 m_stream = stream;
169 m_lumiBlockNumber = lumiBlockNumber;
170 m_applicationName = applicationName;
171
172 m_filenamecallback = theFNCB;
173
177 m_cFileMB = 0.0;
178 m_runMB = 0.0;
179 m_latestPosition = -1;
180
181 m_writePath = writingPath;
182 m_nextWritePath = "";
183 //m_fileNameCore = fileNameCore;
184
186 // m_file_name_strings.appName = getAppName(fileNameCore);
187 m_file_name_strings.fileNameCore = m_filenamecallback->getCoreName();
188
189 setRunParamsRecord(rPar);
190
191 m_file_start_record.sizeLimit_MB = 0;
192 m_file_start_record.sizeLimit_dataBlocks = 0;
194
195 m_cFileOpen=false;
196 m_openFailed = false;
197
198 m_callBack = NULL;
199
200 m_fmdStrings = fmdStrings;
201
202 m_compression = compression;
203 m_complevel = compLevel;
204 m_compressed = new DataBuffer();
205
206 // add stream, project, compression, lumiBlock
207 // (if they are valid) to meta-data:
208 m_fmdStrings.push_back("Stream=" + m_stream );
209 m_fmdStrings.push_back("Project=" + m_project );
210 std::ostringstream o;
212 m_fmdStrings.push_back("LumiBlock=" + o.str());
213
215 m_fmdStrings.push_back(offline_EventStorage_v5::compressiontag +
216 "=" + offline_EventStorage_v5::type_to_string(m_compression));
217 }
218
219 m_check = ::adler32(0L, Z_NULL, 0);
220
221 m_guid = "";
222 m_next_guid = "";
223 this->spaceForGuid();
224 this->openNextFile();
225
226}
227
228
229// */
230
231
232//date and time utility
233void DataWriter::date_timeAsInt(uint32_t &getDate, uint32_t &getTime) const
234{
235 long a_time;
236 time(&a_time);
237
238 struct tm t;
239 localtime_r( &a_time, &t);
240
241 getDate= 1000000*t.tm_mday+
242 10000*(1+t.tm_mon)+
243 1900+t.tm_year;
244
245 getTime= 10000*t.tm_hour+
246 100*t.tm_min+
247 t.tm_sec ;
248}
249
250
252{
253
254 if(m_openFailed) return false;
255
256 if(m_cFileOpen)
257 {
258 return m_cFile.good();
259 }
260 else
261 {
262 return true;
263 }
264
265}
266
267
268// configuration
269DWError DataWriter::setMaxFileMB(const unsigned int& maxFileMB)
270{
271 m_file_start_record.sizeLimit_MB = maxFileMB;
272 return EventStorage::DWOK;
273}
274
275DWError DataWriter::setMaxFileNE(const unsigned int& maxFileNE)
276{
277 m_file_start_record.sizeLimit_dataBlocks = maxFileNE;
278 return EventStorage::DWOK;
279}
280
282{
283 // accept the params, whatever they are
284 // run number is in this record (and only there)
291 m_internal_run_parameters_record.detector_mask_1of2 = rPar.detector_mask & 0xFFFFFFFF;
292 m_internal_run_parameters_record.detector_mask_2of2 = (rPar.detector_mask>> 32);
295}
296
297// output of data
298DWError DataWriter::putData(const unsigned int& dataSize, const void *event)
299{
300
301 uint32_t todisk;
302 iovec_const iov;
303 iov.iov_base = event;
304 iov.iov_len = dataSize;
305 return this->putData(1, &iov, todisk);
306}
307
308// output of scattered data using iovec
309DWError DataWriter::putData(const unsigned int& entries, const struct iovec * my_iovec)
310{
311 uint32_t todisk;
312 return this->putData(entries, my_iovec, todisk);
313}
314
315DWError DataWriter::putData(const unsigned int& dataSize, const void *event, uint32_t& sizeToDisk){
316
317 iovec_const iov;
318 iov.iov_base = event;
319 iov.iov_len = dataSize;
320 return this->putData(1, &iov, sizeToDisk);
321}
322
323DWError DataWriter::putData(const unsigned int& entries, const iovec_const * my_iovec, uint32_t& sizeToDisk){
324 return this->putData_implementation(entries, my_iovec, sizeToDisk);
325}
326
327
328DWError DataWriter::putPrecompressedData(const unsigned int& dataSize,
329 const void *event){
330
331 iovec_const iov;
332 iov.iov_base = event;
333 iov.iov_len = dataSize;
334 return this->putPrecompressedData(1, &iov);
335}
336
337
338DWError DataWriter::putPrecompressedData(const unsigned int& entries,
339 const iovec_const* my_iovec){
340
341 uint32_t todisk;
342 return this->putData_implementation(entries, my_iovec, todisk, true);
343}
344
345
346DWError DataWriter::putData_implementation(const unsigned int& entries, const iovec_const * my_iovec, uint32_t& sizeToDisk, bool precompressed){
347
348 ERS_DEBUG(3,"DataWriter::putData called for an iovec.");
350
351 if(!m_cFileOpen) return EventStorage::DWNOOK;
352
353 if(!m_cFile.good()) return EventStorage::DWNOOK;
354
355 // calculate events size
356 unsigned int dataSize = 0;
357 for(unsigned int i = 0; i<entries; i++) {
358 dataSize += my_iovec[i].iov_len;
359 }
360
361
362
363 sizeToDisk = dataSize;
364
365
366 // apply limits
367 if(m_file_start_record.sizeLimit_MB>0) {
368 double eventMB=static_cast<double>(dataSize)/(1024*1024);
369 double dataMB=m_cFileMB+eventMB;
370 if(static_cast<unsigned int>(dataMB+0.5) >
371 m_file_start_record.sizeLimit_MB) {
372 ERS_DEBUG(3,"Approaching file size limit in MB.");
373 nextFile();
374 }
375 }
376
377 if((m_file_start_record.sizeLimit_dataBlocks>0) &&
378 (m_file_end_record.events_in_file >= m_file_start_record.sizeLimit_dataBlocks)){
379 ERS_DEBUG(3,"Approaching file size limit in number of events.");
380 nextFile();
381 }
382
383 //Here we should compress, so that we have the effective size
384 //for the event record
385 if(m_compression == ZLIB && !precompressed){
386 try{
387 offline_EventStorage_v5::zlibcompress(*m_compressed, sizeToDisk,
388 entries, my_iovec, dataSize, m_complevel);
389 }catch(offline_EventStorage_v5::CompressionIssue& ex){
390 EventStorage::WritingIssue ci(ERS_HERE, "Data compression failed.", ex);
391 ers::error(ci);
392 return EventStorage::DWNOOK;
393 }
394 }
395
396 // prepare the event record
398 dsR.data_block_number = m_file_end_record.events_in_run + 1;
399 dsR.data_block_size = sizeToDisk;
400
401 // remember the position
402 m_latestPosition = m_cFile.tellg();
403
404 // write the event record followed by event data
406
407
408 if(m_compression != ZLIB || precompressed){
409 for (unsigned int i =0; i<entries; i++){
410 m_cFile.write(static_cast<const char*>(my_iovec[i].iov_base),
411 my_iovec[i].iov_len);
412
413 m_check = ::adler32(m_check,
414 static_cast<const Bytef *>(my_iovec[i].iov_base),
415 my_iovec[i].iov_len);
416 }
417 }else{
418 m_cFile.write(static_cast<const char *>(m_compressed->handle()), sizeToDisk);
419 m_check = ::adler32(m_check,
420 static_cast<const Bytef *>(m_compressed->handle()),
421 sizeToDisk);
422 }
423
424 // update statistics
425 m_cFileMB += static_cast<double>(sizeToDisk)/(1024*1024);
426 m_runMB += static_cast<double>(sizeToDisk)/(1024*1024);
427 m_file_end_record.events_in_file++;
428 m_file_end_record.events_in_run++;
429
430 ERS_DEBUG(3,"Event "<< m_file_end_record.events_in_run<<" is written at offset "<<m_latestPosition);
431
432 if(!m_cFile.good()) return EventStorage::DWNOOK;
433
434 return EventStorage::DWOK;
435}
436
437
439{
440 return m_latestPosition;
441}
442
443// statistics
444unsigned int DataWriter::eventsInFile() const
445{
446 return m_file_end_record.events_in_file;
447}
448
450{
451 return m_file_end_record.events_in_run;
452}
453
454unsigned int DataWriter::dataMB_InFile() const
455{
456 return static_cast<unsigned int>(m_cFileMB+0.5);
457}
458
460{
461 return static_cast<unsigned int>(m_runMB+0.5);
462}
463
464// closes the current file
466{
467 ERS_DEBUG(3,"DataWriter::closeFile() called.");
468
469 // do statistics
470 m_file_end_record.data_in_file = static_cast<unsigned int>(m_cFileMB+0.5);
471 m_file_end_record.data_in_run = static_cast<unsigned int>(m_runMB+0.5);
472
474
475 // write eof record
477
478 m_cFile.close();
479 std::ostringstream oss;
480 oss.width(8);
481 (void)oss.fill('0');
482 oss << std::hex << std::uppercase <<m_check;
483 std::string checksum = oss.str();
484 m_check = ::adler32(0L, Z_NULL, 0);
485
486 // rename the file
487 ERS_DEBUG(3,"Rename file " << nameFile(UNFINISHED) << endl
488 << "to " << nameFile(FINISHED));
489 if (::rename(nameFile(UNFINISHED).c_str(), nameFile(FINISHED).c_str()) == -1) {
490
491 EventStorage::WritingIssue ci(ERS_HERE, "Rename failed.");
492 ers::error(ci);
493 return EventStorage::DWNOOK;
494 }
495
496 // check if the file is there
498 {
499 ERS_DEBUG(2,"Finished file "<<nameFile(FINISHED));
500 if(m_callBack != NULL) {
501 ERS_DEBUG(3,"Execute callback from DataWriter.");
502 m_callBack->FileWasClosed(
503 m_filenamecallback->getCurrentFileName(),
508 m_guid,
509 std::move(checksum),
510 m_file_end_record.events_in_file,
512 m_file_start_record.file_number,
515 );
516 }
517
518 // now we can substitute new directory, if specified
519 if(m_nextWritePath != "") {
522 ERS_DEBUG(3,"New writing path became effective. The path is "
523 <<m_writePath);
524 }
525 m_cFileOpen = false;
526
527 try{
528 m_filenamecallback->advance();
529 }catch(EventStorage::ES_SingleFile &e){
530 //If opennext file is called, it
531 // will fail there
532 }
533 return EventStorage::DWOK;
534 }
535 return EventStorage::DWNOOK;
536}
537
538// closes the current file and opens another one
540{
541 ERS_DEBUG(2,"DataWriter::nextFile() called.");
542
543 DWError we=closeFile();
544
545/* if (m_freename)
546 {
547 EventStorage::ES_SingleFile ci(ERS_HERE, "DataWriter called with freename = 1. DataWriter wants to go to next file, but cannot, since indexing is forbidden. Either deactive freename (so files can be indexed, or increase the file size limit (or turn it off)");
548 throw ci;
549 }*/
550
551 openNextFile();
552 if(m_openFailed) we=EventStorage::DWNOOK;
553 return we;
554}
555
556bool DataWriter::fileExists(const string& name) const
557{
558 ifstream test(name.c_str(),ios::binary | ios::in);
559 bool isThere = test.good();
560 test.close();
561
562 return isThere;
563}
564
566{
567 m_cFileMB=0.0;
568 m_file_end_record.events_in_file=0;
569
570 try{
571 m_file_start_record.file_number = m_filenamecallback->getIndex();
572 }catch(EventStorage::ES_SingleFile &e){
573 m_file_start_record.file_number++;
574 }
576
577 ERS_DEBUG(2,"Trying to open file "<<nameFile(UNFINISHED));
578
581 {
582
584 string err = "found an existing file with name " + nameFile(UNFINISHED);
585 EventStorage::WritingIssue ci(ERS_HERE, err.c_str());
586 ers::warning(ci);
587
588 } else {
589
590 string err = "found an existing file with name " + nameFile(FINISHED);
591 EventStorage::WritingIssue ci(ERS_HERE, err.c_str());
592 ers::warning(ci);
593 }
594 m_filenamecallback->fileAlreadyExists();
595
596 m_file_start_record.file_number = m_filenamecallback->getIndex();
597
598 ostringstream oss;
599 oss << "increase file number to ";
600 oss << m_file_start_record.file_number;
601 EventStorage::WritingIssue ci(ERS_HERE, oss.str().c_str());
602 ers::warning(ci);
603 }
604 ERS_DEBUG(2,"OK to write file with number "<<m_file_start_record.file_number);
605
606 ERS_DEBUG(2,"Opening file: " << nameFile(UNFINISHED));
607
608 m_cFile.clear();
609 m_cFile.open(nameFile(UNFINISHED).c_str(),
610 ios::out | ios::app | ios::binary);
611
612 m_check = ::adler32(0L, Z_NULL, 0);
613
616
617 this->replaceGuid();
618
619 ERS_DEBUG(3,"Writing "<<m_fmdStrings.size()<<" metadata strings.");
622 ERS_DEBUG(3,"Status of the file. good() returns "<<m_cFile.good());
623 m_cFileOpen = m_cFile.good();
624 m_openFailed = !m_cFile.good();
625
626 if((m_callBack != NULL) && m_cFileOpen) {
627 ERS_DEBUG(3,"Execute callback from DataWriter.");
628 m_callBack->FileWasOpened(
629 m_filenamecallback->getCurrentFileName(),
634 m_guid,
636 m_file_start_record.file_number,
638 );
639 }
640}
641
643{
644 ostringstream n;
645 n << m_writePath << "/";
646 n << m_filenamecallback->getCurrentFileName((FINISHED == fs)?false:true);
647 string name = n.str();
648 return name;
649}
650
651void DataWriter::cd(const string& writingPath) {
652 m_nextWritePath = writingPath;
653 ERS_DEBUG(3,"Directory changed to "<<m_nextWritePath
654 <<" (effective for hext file).");
655}
656
658
659 bool inT=false;
660 if((m_nextWritePath != "") &&
661 (m_nextWritePath != m_writePath)) inT=true;
662 return inT;
663
664}
665
666void DataWriter::file_record(void *ri, const void *pi) {
667
668 uint32_t *record = reinterpret_cast<uint32_t *>(ri);
669 const uint32_t *pattern = reinterpret_cast<const uint32_t *>(pi);
670 int size=pattern[1];
671
672 for(int i=0; i<size; i++) {
673 if(pattern[i] != 0) {
674 m_cFile.write(reinterpret_cast<const char*>(pattern+i),sizeof(uint32_t));
675 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>(pattern+i),sizeof(uint32_t));
676 } else {
677 m_cFile.write(reinterpret_cast<char*>(record+i),sizeof(uint32_t));
678 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>(record+i),sizeof(uint32_t));
679 }
680 }
681}
682
683
685
686 const char *cName = nst.appName.c_str();
687 const char *cTag = nst.fileNameCore.c_str();
688
689 uint32_t sizeName = nst.appName.size();
690 uint32_t sizeTag = nst.fileNameCore.size();
691
692 m_cFile.write(ccharAddress(offline_EventStorage_v5::file_name_strings_marker),sizeof(uint32_t));
693 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>
695 sizeof(uint32_t));
696
697 m_cFile.write(charAddress(sizeName),sizeof(uint32_t));
698 m_check = ::adler32(m_check,cbytefAddress(sizeName),sizeof(uint32_t));
699 m_cFile.write(cName,sizeName);
700 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>(cName),sizeName);
701
702 char ns = sizeName % 4;
703 if(ns){
704 m_cFile.write(" ",4-ns);
705 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>(" "),4-ns);
706 }
707
708 m_cFile.write(charAddress(sizeTag),sizeof(uint32_t));
709 m_check = ::adler32(m_check,bytefAddress(sizeTag),sizeof(uint32_t));
710 m_cFile.write(cTag,sizeTag);
711 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>(cTag),sizeTag);
712
713 ns = sizeTag % 4;
714 if(ns){
715 m_cFile.write(" ",4-ns);
716 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>(" "),4-ns);
717 }
718
719}
720
722{
723 ERS_DEBUG(2,"Writing the metadata strings.");
724
725 m_cFile.write(ccharAddress(offline_EventStorage_v5::free_strings_marker),sizeof(uint32_t));
726 m_check = ::adler32(m_check, reinterpret_cast<const Bytef*>
728 sizeof(uint32_t));
729
730 uint32_t nstrings = fmdStrings.size();
731 m_cFile.write(charAddress(nstrings),sizeof(uint32_t));
732 m_check = ::adler32(m_check, bytefAddress(nstrings),
733 sizeof(uint32_t));
734
735 vector<string>::const_iterator it;
736 for(it=fmdStrings.begin(); it!=fmdStrings.end(); ++it) {
737
738 const char *cst = it->c_str();
739 uint32_t slen = it->size();
740
741 m_cFile.write(charAddress(slen),sizeof(uint32_t));
742 m_check = ::adler32(m_check,bytefAddress(slen),sizeof(uint32_t));
743 m_cFile.write(cst,slen);
744 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>(cst),slen);
745 char ns = slen % 4;
746 if(ns){
747 m_cFile.write(" ",4-ns);
748 m_check = ::adler32(m_check,reinterpret_cast<const Bytef*>(" "),4-ns);
749 }
750 }
751}
752
753void DataWriter::registerCallBack(DataWriterCallBack *pUserCBclass) {
754 m_callBack = pUserCBclass;
755 if(m_callBack != NULL) {
756 m_callBack->FileWasOpened(
757 m_filenamecallback->getCurrentFileName(),
762 m_guid,
764 m_file_start_record.file_number,
766 );
767 }
768}
769
771 string e("");
772 m_fmdStrings.insert(m_fmdStrings.begin(),e);
773}
774
776 using namespace std;
777
778 if (m_next_guid == ""){
780 m_guid = g.toString();
781 }else{
783 m_next_guid = "";
784 }
785
786 m_fmdStrings[0] = "GUID=" + m_guid;
787}
788
789void DataWriter::setGuid(const std::string& Guid){
791}
792
793
794uint64_t DataWriter::getFileSize(const std::string& fileNameCore) const
795{
796 struct stat64 tmp;
797 if (::stat64(fileNameCore.c_str(), &tmp) == -1) {
798 EventStorage::WritingIssue ci(ERS_HERE, "stat64 failed.");
799 ers::error(ci);
800 return 0;
801 }
802
803 return tmp.st_size;
804}
805
806
static Double_t fs
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)
#define pi
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition Guid.h:25
void date_timeAsInt(uint32_t &getDate, uint32_t &getTime) const
void initDW(const std::string &writingPath, boost::shared_ptr< EventStorage::FileNameCallback > theFNCB, const run_parameters_record &rPar, const std::string &project, const std::string &streamType, const std::string &streamName, const std::string &stream, const unsigned int lumiBlockNumber, const std::string &applicationName, const std::vector< std::string > &fmdStrings, const CompressionType compression, const unsigned int compLevel)
EventStorage::DWError putPrecompressedData(const unsigned int &dataSize, const void *event)
Write a single block of data already compressed.
EventStorage::DWError setMaxFileMB(const unsigned int &maxFileMB)
max size of 1 file in MB.
EventStorage::DWError putData_implementation(const unsigned int &entries, const iovec_const *my_iovec, uint32_t &sizeToDisk, bool precompressed=false)
void registerCallBack(EventStorage::DataWriterCallBack *pUserCBclass)
If you want to define actions to be taken when a file is open or closed register your call-back class...
internal_run_parameters_record m_internal_run_parameters_record
void file_record(void *ri, const void *pi)
std::string nameFile(const FileStatus &fs) const
get the name of the current file
EventStorage::DataWriterCallBack * m_callBack
EventStorage::DWError closeFile()
Close the currently open file.
offline_EventStorage_v5::iovec_const iovec_const
~DataWriter()
destructor, the way to close the sequence of files
unsigned int dataMB_InFileSequence() const
number of mega bytes written to the file sequence
bool fileExists(const std::string &name) const
void cd(const std::string &writingPath)
set another writing path
bool good() const
feedback to user
EventStorage::DWError setMaxFileNE(const unsigned int &maxFileNE)
max size of 1 file in number of data blocks (or events) 1 putData call is one block
uint64_t getFileSize(const std::string &fileNameCore) const
unsigned int dataMB_InFile() const
number of mega bytes written to the current file
unsigned int eventsInFileSequence() const
number of events written to the file sequence
int64_t getPosition() const
get the offset of the latest written event; one should call it AFTER putData(...)
void setGuid(const std::string &Guid)
Externally set the GUID for the next file in this sequence.
boost::shared_ptr< EventStorage::FileNameCallback > m_filenamecallback
void setRunParamsRecord(const run_parameters_record &rPar)
CompressionType getCompression() const
Returns the compression type for this file.
bool inTransition() const
The file currently open is not closed immediately after cd() this method will return true if we are i...
EventStorage::DWError putData(const unsigned int &dataSize, const void *event)
Write a single block of data.
EventStorage::DWError nextFile()
close the file and open next one immediately
unsigned int eventsInFile() const
number of events written to the currently open file
double entries
Definition listroot.cxx:49
const file_end_record file_end_pattern
const data_separator_record data_separator_pattern
void reset_record(void *ri, const void *pi)
std::vector< std::string > freeMetaDataStrings
const internal_run_parameters_record run_parameters_pattern
const file_start_record file_start_pattern
STL namespace.