MIDAS
Loading...
Searching...
No Matches
WriterLZ4 Class Reference
Inheritance diagram for WriterLZ4:
Collaboration diagram for WriterLZ4:

Public Member Functions

 WriterLZ4 (LOG_CHN *log_chn, WriterInterface *wr)
 
 ~WriterLZ4 ()
 
int wr_open (LOG_CHN *log_chn, int run_number)
 
int wr_write (LOG_CHN *log_chn, const void *data, const int size)
 
int wr_close (LOG_CHN *log_chn, int run_number)
 
std::string wr_get_file_ext ()
 
std::string wr_get_chain ()
 
- Public Member Functions inherited from WriterInterface
 WriterInterface ()
 
virtual ~WriterInterface ()
 

Private Attributes

WriterInterfacefWr
 
MLZ4F_compressionContext_t fContext
 
MLZ4F_preferences_t fPrefs
 
charfBuffer
 
int fBufferSize
 
int fBlockSize
 

Additional Inherited Members

- Public Attributes inherited from WriterInterface
bool fTrace
 
double fBytesIn
 
double fBytesOut
 

Detailed Description

Definition at line 1422 of file mlogger.cxx.

Constructor & Destructor Documentation

◆ WriterLZ4()

WriterLZ4::WriterLZ4 ( LOG_CHN log_chn,
WriterInterface wr 
)
inline

Definition at line 1425 of file mlogger.cxx.

1426 {
1427 if (fTrace)
1428 printf("WriterLZ4: path [%s]\n", log_chn->path.c_str());
1429
1430 assert(wr != NULL);
1431
1432 fBuffer = NULL;
1433 fWr = wr;
1434 fBufferSize = 0;
1435 fBlockSize = 0;
1436 }
int fBlockSize
Definition mlogger.cxx:1613
WriterInterface * fWr
Definition mlogger.cxx:1608
int fBufferSize
Definition mlogger.cxx:1612
char * fBuffer
Definition mlogger.cxx:1611
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~WriterLZ4()

WriterLZ4::~WriterLZ4 ( )
inline

Definition at line 1438 of file mlogger.cxx.

1439 {
1440 if (fTrace)
1441 printf("WriterLZ4: destructor\n");
1442
1443 FREE(fBuffer);
1444 DELETE(fWr);
1445 }
#define FREE(ptr)
Definition mlogger.cxx:367
#define DELETE(ptr)
Definition mlogger.cxx:368
Here is the call graph for this function:

Member Function Documentation

◆ wr_close()

int WriterLZ4::wr_close ( LOG_CHN log_chn,
int  run_number 
)
inlinevirtual

Implements WriterInterface.

Definition at line 1545 of file mlogger.cxx.

1546 {
1547 int xstatus = SUCCESS;
1549
1550 if (fTrace)
1551 printf("WriterLZ4: close path [%s]\n", log_chn->path.c_str());
1552
1553 log_chn->handle = 0;
1554
1555 /* write End of Stream mark */
1557
1560 cm_msg(MERROR, "WriterLZ4::wr_close", "LZ4F_compressEnd() error %d (%s)", (int)errorCode, MLZ4F_getErrorName(errorCode));
1561 return SS_FILE_ERROR;
1562 }
1563
1565
1566 fBytesIn += 0;
1568
1569 if (status != SUCCESS) {
1570 if (xstatus == SUCCESS)
1571 xstatus = status;
1572 }
1573
1574 /* close downstream writer */
1575
1577
1578 if (status != SUCCESS) {
1579 if (xstatus == SUCCESS)
1580 xstatus = status;
1581 }
1582
1583 /* free resources */
1584
1585 free(fBuffer);
1586 fBuffer = NULL;
1587 fBufferSize = 0;
1588
1590 if (MLZ4F_isError(errorCode)) {
1591 cm_msg(MERROR, "WriterLZ4::wr_close", "LZ4F_freeCompressionContext() error %d (%s)", (int)errorCode, MLZ4F_getErrorName(errorCode));
1592 if (xstatus == SUCCESS)
1594 }
1595
1596 return xstatus;
1597 }
virtual int wr_close(LOG_CHN *log_chn, int run_number)=0
virtual int wr_write(LOG_CHN *log_chn, const void *data, const int size)=0
MLZ4F_compressionContext_t fContext
Definition mlogger.cxx:1609
#define SS_FILE_ERROR
Definition midas.h:669
#define SUCCESS
Definition mcstd.h:54
#define MERROR
Definition midas.h:559
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
INT run_number[2]
Definition mana.cxx:246
DWORD status
Definition odbhist.cxx:39
Here is the call graph for this function:

◆ wr_get_chain()

std::string WriterLZ4::wr_get_chain ( )
inlinevirtual

Implements WriterInterface.

Definition at line 1603 of file mlogger.cxx.

1603 {
1604 return "lz4 | " + fWr->wr_get_chain();
1605 }
virtual std::string wr_get_chain()=0
Here is the call graph for this function:

◆ wr_get_file_ext()

std::string WriterLZ4::wr_get_file_ext ( )
inlinevirtual

Reimplemented from WriterInterface.

Definition at line 1599 of file mlogger.cxx.

1599 {
1600 return ".lz4" + fWr->wr_get_file_ext();
1601 }
virtual std::string wr_get_file_ext()
Definition mlogger.cxx:414
Here is the call graph for this function:

◆ wr_open()

int WriterLZ4::wr_open ( LOG_CHN log_chn,
int  run_number 
)
inlinevirtual

Implements WriterInterface.

Definition at line 1447 of file mlogger.cxx.

1448 {
1449 int status;
1451
1452 if (fTrace)
1453 printf("WriterLZ4: open path [%s]\n", log_chn->path.c_str());
1454
1456 if (status != SUCCESS) {
1457 return status;
1458 }
1459
1461 if (MLZ4F_isError(errorCode)) {
1462 cm_msg(MERROR, "WriterLZ4::wr_open", "LZ4F_createCompressionContext() error %d (%s)", (int)errorCode, MLZ4F_getErrorName(errorCode));
1463 return SS_FILE_ERROR;
1464 }
1465
1467 fBlockSize = 4*1024*1024;
1469 fBufferSize *= 2; // kludge
1470 fBuffer = (char*)malloc(fBufferSize);
1471 if (fBuffer == NULL) {
1472 cm_msg(MERROR, "WriterLZ4::wr_open", "Cannot malloc() %d bytes for an LZ4 compression buffer, block size %d, errno %d (%s)", fBufferSize, fBlockSize, errno, strerror(errno));
1473 return SS_FILE_ERROR;
1474 }
1475
1476 MEMZERO(fPrefs);
1477
1478 fPrefs.compressionLevel = 0; // 0=fast, non-zero=???
1479 fPrefs.autoFlush = 0; // ???
1480 fPrefs.frameInfo.contentChecksumFlag = MLZ4F_contentChecksumEnabled;
1481 fPrefs.frameInfo.blockSizeID = blockSizeId;
1482
1484
1487 cm_msg(MERROR, "WriterLZ4::wr_open", "LZ4F_compressBegin() error %d (%s)", (int)errorCode, MLZ4F_getErrorName(errorCode));
1488 return SS_FILE_ERROR;
1489 }
1490
1492
1493 fBytesIn += 0;
1495
1496 if (status != SUCCESS) {
1497 return SS_FILE_ERROR;
1498 }
1499
1500 log_chn->handle = 9999;
1501
1502 return SUCCESS;
1503 }
virtual int wr_open(LOG_CHN *log_chn, int run_number)=0
MLZ4F_preferences_t fPrefs
Definition mlogger.cxx:1610
#define MEMZERO(obj)
Definition mlogger.cxx:365
Here is the call graph for this function:

◆ wr_write()

int WriterLZ4::wr_write ( LOG_CHN log_chn,
const void data,
const int  size 
)
inlinevirtual

Implements WriterInterface.

Definition at line 1505 of file mlogger.cxx.

1506 {
1507 const char* ptr = (const char*)data;
1508 int remaining = size;
1509
1510 if (fTrace)
1511 printf("WriterLZ4: write path [%s], size %d\n", log_chn->path.c_str(), size);
1512
1513 while (remaining > 0) {
1514 int wsize = remaining;
1515
1516 if (wsize > fBlockSize)
1517 wsize = fBlockSize;
1518
1520
1521 if (MLZ4F_isError(outSize)) {
1522 int errorCode = outSize;
1523 cm_msg(MERROR, "WriterLZ4::wr_write", "LZ4F_compressUpdate() with %d bytes, block size %d, buffer size %d, write size %d, remaining %d bytes, error %d (%s)", wsize, fBlockSize, fBufferSize, size, remaining, (int)errorCode, MLZ4F_getErrorName(errorCode));
1524 return SS_FILE_ERROR;
1525 }
1526
1527 if (outSize > 0) {
1529
1530 fBytesIn += wsize;
1532
1533 if (status != SUCCESS) {
1534 return SS_FILE_ERROR;
1535 }
1536 }
1537
1538 ptr += wsize;
1539 remaining -= wsize;
1540 }
1541
1542 return SUCCESS;
1543 }
void * data
Definition mana.cxx:268
Here is the call graph for this function:

Member Data Documentation

◆ fBlockSize

int WriterLZ4::fBlockSize
private

Definition at line 1613 of file mlogger.cxx.

◆ fBuffer

char* WriterLZ4::fBuffer
private

Definition at line 1611 of file mlogger.cxx.

◆ fBufferSize

int WriterLZ4::fBufferSize
private

Definition at line 1612 of file mlogger.cxx.

◆ fContext

MLZ4F_compressionContext_t WriterLZ4::fContext
private

Definition at line 1609 of file mlogger.cxx.

◆ fPrefs

MLZ4F_preferences_t WriterLZ4::fPrefs
private

Definition at line 1610 of file mlogger.cxx.

◆ fWr

WriterInterface* WriterLZ4::fWr
private

Definition at line 1608 of file mlogger.cxx.


The documentation for this class was generated from the following file: