Note that there are some explanatory texts on larger screens.

plurals
  1. POwcf conditional compression
    primarykey
    data
    text
    <p>I recently plugged in a custom encoder (uses binary encoder to do the actual encoding and Gzip compresser to compress the byte array). It works fine. The issue now is for small message size it actually inflates the byte array. I would like to know if there is a way to avoid this. Specifically if there is a way I can apply condition compression and decompression.</p> <p>I did try to do something like - place a condition </p> <pre><code>if(buffer.Count &lt;= 5000) skip compression </code></pre> <p>But the problem is on the other end decompression will happen even if the bytes are not compressed. I hope this makes sense.</p> <p>Following are the functions where compression and decompression happens (code snippet from CompactMessageEncoder)</p> <pre><code>public override Message ReadMessage(ArraySegment&lt;byte&gt; buffer, BufferManager bufferManager, string contentType) { ArraySegment&lt;byte&gt; decompressedBuffer = DecompressBuffer(buffer, bufferManager); LogWrite("Decompressed from {0} bytes to {1} bytes", buffer.Count, decompressedBuffer.Count); Message returnMessage = _innerEncoder.ReadMessage(decompressedBuffer, bufferManager); returnMessage.Properties.Encoder = this; return returnMessage; } public override ArraySegment&lt;byte&gt; WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset) { var buffer = _innerEncoder.WriteMessage(message, maxMessageSize, bufferManager, messageOffset); var compressedBuffer = CompressBuffer(buffer, bufferManager, messageOffset); LogWrite("Compressed from {0} bytes to {1} bytes", buffer.Count, compressedBuffer.Count); return compressedBuffer; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload