Class DecoratedBinaryDeltaCompressor

All Implemented Interfaces:
DeltaCompressor

public class DecoratedBinaryDeltaCompressor extends ExternalizableHelper implements DeltaCompressor
A DeltaCompressor implementation that works with decorated binary values.

The delta format is composed of a leading byte that indicates the format; the format indicator byte is one of the DECO_* field values. If the delta value does not begin with one of the leading DECO_* indicators, then the entire delta is the delta for the "value" portion of the decorated result. The grammar follows:

DecoratedBinaryDelta:
  DECO_DELETE_ALL OptionalValueDelta
  DecorationDeltaList DECO_TERM OptionalValueDelta
  DECO_NO_CHANGES-opt ValueDelta
  null

OptionalValueDelta:
  VALUE_NO_CHANGES
  VALUE_CHANGES-opt ValueDelta

ValueDelta:
  Binary (as defined by the underlying DeltaCompressor)

DecorationDeltaList:
  DecorationDelta
  DecorationDeltaList DecorationDelta

DecorationDelta:
  DECO_INSERT DecorationId Binary
  DECO_UPDATE DecorationId BinaryDelta
  DECO_DELETE DecorationId

BinaryDelta:
  Binary (as returned by the BinaryDeltaCompressor)

Binary:
  Length <bytes>

DecorationId:
Length:
  <packed-integer>
Author:
cp 2009.01.20
  • Constructor Details

    • DecoratedBinaryDeltaCompressor

      public DecoratedBinaryDeltaCompressor(DeltaCompressor compressorValue)
      Construct a DecoratedBinaryDeltaCompressor.
      Parameters:
      compressorValue - the compressor responsible for performing delta compression on the underlying Binary value (i.e. the DECO_VALUE decoration)
  • Method Details

    • extractDelta

      public ReadBuffer extractDelta(ReadBuffer bufOld, ReadBuffer bufNew)
      Compare an old value to a new value and generate a delta that represents the changes that must be made to the old value in order to transform it into the new value. The generated delta must be a ReadBuffer of non-zero length.

      If the old value is null, the generated delta must be a "replace", meaning that applying it to any value must produce the specified new value.

      Specified by:
      extractDelta in interface DeltaCompressor
      Parameters:
      bufOld - the old value
      bufNew - the new value; must not be null
      Returns:
      the changes that must be made to the old value in order to transform it into the new value, or null to indicate no change
    • applyDelta

      public ReadBuffer applyDelta(ReadBuffer bufOld, ReadBuffer bufDelta)
      Apply a delta to an old value in order to create a new value.
      Specified by:
      applyDelta in interface DeltaCompressor
      Parameters:
      bufOld - the old value
      bufDelta - the delta information returned from DeltaCompressor.extractDelta(ReadBuffer, ReadBuffer) to apply to the old value
      Returns:
      the new value
    • toString

      public String toString()
      Overrides:
      toString in class Object