9 modified files
lcio/doc
diff -u -r1.63 -r1.64
--- versions.readme 8 Nov 2007 19:35:37 -0000 1.63
+++ versions.readme 9 Nov 2007 20:21:09 -0000 1.64
@@ -15,6 +15,9 @@
- added event weight: LCEvent.getWeight() (Java/C++)
+ - added LCWriter::setCompressionLevel(int level) (C++)
+
+
=====================
v01-08-05
=====================
lcio/sio/include
diff -u -r1.5 -r1.6
--- SIO_stream.h 16 Oct 2007 16:22:45 -0000 1.5
+++ SIO_stream.h 9 Nov 2007 20:21:09 -0000 1.6
@@ -1,5 +1,5 @@
// ----------------------------------------------------------------------------
-// CVS $Id: SIO_stream.h,v 1.5 2007/10/16 16:22:45 gaede Exp $
+// CVS $Id: SIO_stream.h,v 1.6 2007/11/09 20:21:09 gaede Exp $
// ----------------------------------------------------------------------------
// => Controller for a single SIO stream.
// ----------------------------------------------------------------------------
@@ -54,6 +54,10 @@
SIO_64BITINT lastRecordStart() { return recPos ; }
unsigned int seek(SIO_64BITINT pos) ;
+ // set compression level: -1:default, 0, no compression, 1-9 compression
+ // note if level==0 user should set compression off for all records !
+ void setCompressionLevel( int level ) ;
+
private:
SIO_stream( const char *, unsigned int, SIO_verbosity );
~SIO_stream();
@@ -86,7 +90,7 @@
SIO_verbosity verbosity; // Reporting level
SIO_64BITINT recPos ; // start Position of last record read
-
+ int compLevel ; // compression level
friend class SIO_streamManager; // Access to constructor/destructor
friend class SIO_record; // Access to buffer
lcio/sio/src
diff -u -r1.4 -r1.5
--- SIO_stream.cc 16 Oct 2007 16:22:45 -0000 1.4
+++ SIO_stream.cc 9 Nov 2007 20:21:09 -0000 1.5
@@ -1,5 +1,5 @@
// ----------------------------------------------------------------------------
-// CVS $Id: SIO_stream.cc,v 1.4 2007/10/16 16:22:45 gaede Exp $
+// CVS $Id: SIO_stream.cc,v 1.5 2007/11/09 20:21:09 gaede Exp $
// ----------------------------------------------------------------------------
// => Controller for a single SIO stream.
// ----------------------------------------------------------------------------
@@ -58,6 +58,7 @@
state = SIO_STATE_CLOSED;
verbosity = i_verbosity;
+compLevel = Z_DEFAULT_COMPRESSION ;
}
// ----------------------------------------------------------------------------
@@ -388,6 +389,29 @@
// ----------------------------------------------------------------------------
SIO_verbosity SIO_stream::getVerbosity() { return( verbosity ); }
+
+// ----------------------------------------------------------------------------
+// Set compresision level
+// ----------------------------------------------------------------------------
+void SIO_stream::setCompressionLevel(int level) {
+
+ // zlib knows comp levels: -1/Z_DEFAULT_COMPRESSION, 1-9
+ if( level < 0 )
+
+ compLevel = Z_DEFAULT_COMPRESSION ;
+
+ else if( level > 9 )
+
+ compLevel == 9 ;
+
+ else
+
+ compLevel = level ;
+
+}
+
+
+
// ----------------------------------------------------------------------------
// Associate a file name and a mode with this stream and open the file.
// ----------------------------------------------------------------------------
@@ -514,7 +538,7 @@
z_strm->opaque = 0;
z_stat = (mode == SIO_MODE_READ) ? inflateInit( z_strm )
- : deflateInit( z_strm, Z_DEFAULT_COMPRESSION );
+ : deflateInit( z_strm, compLevel );
if( z_stat != Z_OK )
{
lcio/src/aid/IO
diff -u -r1.9 -r1.10
--- LCWriter.aid 11 May 2005 00:40:45 -0000 1.9
+++ LCWriter.aid 9 Nov 2007 20:21:09 -0000 1.10
@@ -30,6 +30,25 @@
public void open(const String& filename , int writeMode ) throws IOException ;
+ /** Set the compression level - needs to be called before open() otherwise
+ * call will have no effect. If not called the Writer will use default compression.<br>
+ * Valid compression levels are:
+ * <ul>
+ * <li> level < 0 : default compression </li>
+ * <li> level == 0 : no compression</li>
+ * <li> level > 0 : compression level (typically 1 (fastest) - 9 (best compression))
+ * </li>
+ * </ul>
+ *
+ * Status: (v01-09)<br>
+ * C++: experimental code - don't use for production<br>
+ * Java: not implemented
+ *
+ *@param level compression level
+ */
+ public void setCompressionLevel(int level) ;
+
+
/** Writes the given run header to file.
*
*@throws IOException
lcio/src/cpp/include/SIO
diff -u -r1.16 -r1.17
--- SIOWriter.h 11 May 2005 00:40:45 -0000 1.16
+++ SIOWriter.h 9 Nov 2007 20:21:09 -0000 1.17
@@ -60,6 +60,22 @@
*/
virtual void open(const std::string & filename, int writeMode)throw (IO::IOException, std::exception) ;
+ /** Set the compression level - needs to be called before open() otherwise
+ * call will have no effect. If not called the Writer will use default compression.<br>
+ * Valid compression levels are:
+ * <ul>
+ * <li> level < 0 : default compression </li>
+ * <li> level == 0 : no compression</li>
+ * <li> level > 0 : 1 (fastest) - 9 (best compression)
+ * </li>
+ * </ul>
+ * Experimental code - don't use for production.
+ *
+ *@param level compression level
+ */
+ virtual void setCompressionLevel(int level) ;
+
+
/** Writes the given run header to file.
*
*@throws IOException
@@ -98,10 +114,8 @@
protected:
- static SIO_record *_evtRecord ;
- static SIO_record *_hdrRecord ;
- static SIO_record *_runRecord ;
SIO_stream *_stream ;
+ int _compressionLevel ;
private:
@@ -109,6 +123,12 @@
SIORunHeaderHandler *_runHandler ;
std::vector<SIO_block*> _connectedBlocks ;
+ protected:
+
+ static SIO_record *_evtRecord ;
+ static SIO_record *_hdrRecord ;
+ static SIO_record *_runRecord ;
+
}; // class
} // namespace.
lcio/src/cpp/src/EXAMPLE
diff -u -r1.52 -r1.53
--- recjob.cc 26 Apr 2007 16:45:22 -0000 1.52
+++ recjob.cc 9 Nov 2007 20:21:09 -0000 1.53
@@ -66,7 +66,10 @@
// open outputfile
lcWrt = LCFactory::getInstance()->createLCWriter() ;
- try{ lcWrt->open( OUTFILEN , LCIO::WRITE_NEW ) ; }
+ try{
+ lcWrt->setCompressionLevel( 9 ) ;
+ lcWrt->open( OUTFILEN , LCIO::WRITE_NEW ) ;
+ }
catch(IOException& e){
cout << "[RunEventProcessor()] Can't open file for writing - "
lcio/src/cpp/src/EXAMPLE
diff -u -r1.55 -r1.56
--- simjob.cc 8 Nov 2007 19:35:37 -0000 1.55
+++ simjob.cc 9 Nov 2007 20:21:09 -0000 1.56
@@ -61,11 +61,16 @@
if( argc > 1 ) { FILEN = argv[1] ; }
- if( rn==0 )
+ lcWrt->setCompressionLevel( 0 ) ;
+
+ if( rn==0 ){
+ // lcWrt->setCompressionLevel( 0 ) ;
lcWrt->open( FILEN , LCIO::WRITE_NEW ) ;
- else
- lcWrt->open( FILEN , LCIO::WRITE_APPEND ) ;
+ }else{
+ // lcWrt->setCompressionLevel( 9 ) ;
+ lcWrt->open( FILEN , LCIO::WRITE_APPEND ) ;
+ }
// NB: in order to test writing multiple files we create a new LCWriter
// for every run even though we are in fact writing to one file only;
// so for a simple job writing one file the
lcio/src/cpp/src/SIO
diff -u -r1.34 -r1.35
--- SIOWriter.cc 1 Feb 2007 08:54:56 -0000 1.34
+++ SIOWriter.cc 9 Nov 2007 20:21:09 -0000 1.35
@@ -30,13 +30,17 @@
namespace SIO {
- SIO_record * SIOWriter::_evtRecord ;
- SIO_record * SIOWriter::_hdrRecord ;
- SIO_record * SIOWriter::_runRecord ;
+ SIO_record * SIOWriter::_evtRecord = 0 ;
+ SIO_record * SIOWriter::_hdrRecord = 0 ;
+ SIO_record * SIOWriter::_runRecord = 0 ;
- SIOWriter::SIOWriter() : _hdrHandler(0), _runHandler(0) {
-
+
+ SIOWriter::SIOWriter() : _stream(0),
+ _compressionLevel(-1),
+ _hdrHandler(0),
+ _runHandler(0) {
+
#ifdef DEBUG
SIO_streamManager::setVerbosity( SIO_ALL ) ;
SIO_recordManager::setVerbosity( SIO_ALL ) ;
@@ -54,8 +58,6 @@
_runHandler = new SIORunHeaderHandler( LCSIO::RUNBLOCKNAME ) ;
_hdrHandler = new SIOEventHandler( LCSIO::HEADERBLOCKNAME ) ;
- // evtP = new LCEvent* ;
-
LCIOExceptionHandler::createInstance() ;
}
@@ -130,10 +132,11 @@
if( _stream == 0 )
throw IOException( std::string( "[SIOWriter::open()] Bad or duplicate stream name: "
+ stream_name )) ;
-// + std::string(stream_name) )) ;
-// delete[] stream_name ;
-
+ // SIO_stream takes any value and maps it to [-1,0,1...,9]
+ _stream->setCompressionLevel( _compressionLevel ) ;
+
+
unsigned int status = 0 ;
switch( writeMode )
{
@@ -160,10 +163,15 @@
_evtRecord = SIO_recordManager::add( LCSIO::EVENTRECORDNAME ) ;
- _hdrRecord->setCompress( LCSIO::COMPRESSION ) ;
- _evtRecord->setCompress( LCSIO::COMPRESSION ) ;
- _runRecord->setCompress( LCSIO::COMPRESSION ) ;
-
+
+ _hdrRecord->setCompress( _compressionLevel != 0 ) ;
+ _evtRecord->setCompress( _compressionLevel != 0 ) ;
+ _runRecord->setCompress( _compressionLevel != 0 ) ;
+
+ }
+
+ void SIOWriter::setCompressionLevel(int level) {
+ _compressionLevel = level ;
}
@@ -188,6 +196,10 @@
if( _stream->getState()== SIO_STATE_OPEN ){
+ _hdrRecord->setCompress( _compressionLevel != 0 ) ;
+ _evtRecord->setCompress( _compressionLevel != 0 ) ;
+ _runRecord->setCompress( _compressionLevel != 0 ) ;
+
// write LCRunHeader record
unsigned int status = _stream->write( LCSIO::RUNRECORDNAME ) ;
@@ -296,16 +308,21 @@
}
void SIOWriter::writeEvent(const LCEvent* evt) throw(IOException, std::exception) {
-
+
+
//here we set up the collection handlers
-
+
try{ setUpHandlers( evt) ;
}catch(...){
throw IOException( "[SIOWriter::writeEvent] could not set up handlers " ) ;
}
+ _hdrRecord->setCompress( _compressionLevel != 0 ) ;
+ _evtRecord->setCompress( _compressionLevel != 0 ) ;
+ _runRecord->setCompress( _compressionLevel != 0 ) ;
+
if( _stream->getState()== SIO_STATE_OPEN ){
// need to set the event in event header handler
lcio/src/java/hep/lcio/implementation/sio
diff -u -r1.13 -r1.14
--- SIOLCWriter.java 7 Nov 2007 20:46:23 -0000 1.13
+++ SIOLCWriter.java 9 Nov 2007 20:21:10 -0000 1.14
@@ -19,7 +19,7 @@
/**
*
* @author Tony Johnson
- * @version $Id: SIOLCWriter.java,v 1.13 2007/11/07 20:46:23 jeremy Exp $
+ * @version $Id: SIOLCWriter.java,v 1.14 2007/11/09 20:21:10 gaede Exp $
*/
class SIOLCWriter implements LCWriter
{
@@ -42,6 +42,10 @@
writer = new SIOWriter(new FileOutputStream(filename,append));
}
+ public void setCompressionLevel(int level) {
+ // not yet ...
+ }
+
public void writeEvent(LCEvent evt) throws IOException
{
SIOEvent.write(evt, writer);
CVSspam 0.2.8