]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
implementation of compression for ROOT objects, default level 5, new common argument...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Sep 2008 12:31:47 +0000 (12:31 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Sep 2008 12:31:47 +0000 (12:31 +0000)
HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTComponent.h

index fa8be1b336afdd06e15982b14d2ec9aad6475c0a..0f8871de59b818a47fa007eddda382fa97c53797 100644 (file)
@@ -41,6 +41,11 @@ using namespace std;
 #include <cassert>
 #include <stdint.h>
 
+/**
+ * default compression level for ROOT objects
+ */
+#define ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION 5
+
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTComponent);
 
@@ -81,7 +86,8 @@ AliHLTComponent::AliHLTComponent()
   fEventType(gkAliEventTypeUnknown),
   fComponentArgs(),
   fEventDoneData(NULL),
-  fEventDoneDataSize(0)
+  fEventDoneDataSize(0),
+  fCompressionLevel(ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION)
 {
   // see header file for class documentation
   // or
@@ -185,6 +191,18 @@ int AliHLTComponent::Init(const AliHLTAnalysisEnvironment* comenv, void* environ
            HLTError("wrong parameter for argument %s, hex number expected", argument.Data());
            iResult=-EINVAL;
          }
+         // -object-compression=
+       } else if (argument.BeginsWith("-object-compression=")) {
+         argument.ReplaceAll("-object-compression=", "");
+         if (argument.IsDigit()) {
+           fCompressionLevel=argument.Atoi();
+           if (fCompressionLevel<0 || fCompressionLevel>9) {
+             HLTWarning("invalid compression level %d, setting to default %d", fCompressionLevel, ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION);
+             fCompressionLevel=ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION;
+           }
+         } else {
+           HLTError("wrong parameter for argument -object-compression, number expected");
+         }
        } else {
          pArguments[iNofChildArgs++]=argv[i];
        }
@@ -1044,14 +1062,32 @@ int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& d
   int iResult=0;
   if (pObject) {
     AliHLTMessage msg(kMESS_OBJECT);
+    msg.SetCompressionLevel(fCompressionLevel);
     msg.WriteObject(pObject);
     Int_t iMsgLength=msg.Length();
     if (iMsgLength>0) {
+      // Matthias Sep 2008
+      // NOTE: AliHLTMessage does implement it's own SetLength method
+      // which is not architecture independent. The original SetLength
+      // stores the size always in network byte order.
+      // I'm trying to remember the rational for that, might be that
+      // it was just some lack of knowledge. Want to change this, but
+      // has to be done carefullt to be backward compatible.
       msg.SetLength(); // sets the length to the first (reserved) word
-      assert(msg.Buffer()!=NULL);
-      iResult=InsertOutputBlock(msg.Buffer(), iMsgLength, dt, spec, pHeader, headerSize);
+
+      // does nothing if the level is 0
+      msg.Compress();
+
+      char *mbuf = msg.Buffer();
+      if (msg.CompBuffer()) {
+       msg.SetLength(); // set once more to have to byte order
+       mbuf = msg.CompBuffer();
+       iMsgLength = msg.CompLength();
+      }
+      assert(mbuf!=NULL);
+      iResult=InsertOutputBlock(mbuf, iMsgLength, dt, spec, pHeader, headerSize);
       if (iResult>=0) {
-       HLTDebug("object %s (%p) size %d inserted to output", pObject->ClassName(), pObject, iMsgLength);
+       HLTDebug("object %s (%p) size %d compression %d inserted to output", pObject->ClassName(), pObject, iMsgLength, msg.GetCompressionLevel());
       }
     } else {
       HLTError("object serialization failed for object %p", pObject);
index 2e3e20e2ef5cb33b2d2af1c7825cb6811992891a..cecfa5dbe769c7c1edf5585ac7d7db919d90d2fc 100644 (file)
@@ -279,6 +279,13 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  * Further rules:
  * - avoid big static arrays in the component, allocate the memory at runtime
  *
+ * @section alihlt_component_arguments Default arguments
+ * The component base class provides some default arguments:
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -object-compression=level     <br>
+ *      compression level for ROOT objects, default is defined by
+ *      @ref ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION
+ *
  * @ingroup alihlt_component
  * @section alihltcomponent-members Class members
  */
@@ -1448,6 +1455,9 @@ class AliHLTComponent : public AliHLTLogging {
   /** Reserved size of the memory stored at fEventDoneData */
   unsigned long fEventDoneDataSize;                                //! transient
 
-  ClassDef(AliHLTComponent, 8)
+  /** Comression level for ROOT objects */
+  int fCompressionLevel;                                           //! transient
+
+  ClassDef(AliHLTComponent, 9)
 };
 #endif