Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Select a compression algorithm.

    While there are many compression algorithms to choose from, we currently support: 
    1. DEFLATE (zlibZLIB RFC 1950)
    2. GZIP

  2. Create the payload and encode it using Google Protocol Buffers.

    This results in a typical encoded array of bytes that would normally (no compression) be published to an MQTT Server.

  3. Compress the payload bytes using one of the above algorithms.

  4. Create a new payload to wrap the compressed bytes.

    This new payload should have UUID set to "SPBV1.0_COMPRESSED" and the same timestamp and sequence number as the original compressed payload. The compressed bytes should be stored in the "body" field of this new payload. A single metric should be added to the new payload to specify the algorithm used to compress the original payload. If not "algorithm" metric is present, it will be assumed that the DEFLATE algorithm was used.

    EXAMPLES

    1. Example: Payload compression with no algorithm specified (defaults to DEFLATE)

      No Format
      {
          "uuid" : "SPBV1.0_COMPRESSED",
          "timestamp" : 1486144502122,
          "seq" : 0,
          "body" : <compressed-encoded-payload>
      }


    2. Example: Payload compression with DEFLATE algorithm

      No Format
      {
          "uuid" : "SPBV1.0_COMPRESSED",
          "timestamp" : 1486144502122,
          "seq" : 0,
          "body" : <compressed-encoded-payload>
          "metrics" : [ {
              "name" : "algorithm",
              "dataType" : "String",
              "value" : "DEFLATE"
          } ]
      }


    3. Example: Payload compression with GZIP algorithm

      No Format
      {
          "uuid" : "SPBV1.0_COMPRESSED",
          "timestamp" : 1486144502122,
          "seq" : 0,
          "body" : <compressed-encoded-payload>
          "metrics" : [ {
              "name" : "algorithm",
              "dataType" : "String",
              "value" : "GZIP"
          } ]
      }


  5. Finally, encode the new payload using Google Protocol Buffers and it is ready to be published.