Show / Hide Table of Contents

Class BinaryDeltaCompressor

An IDeltaCompressor implementation that works with opaque (binary) values.

Inheritance
object
BinaryDeltaCompressor
Implements
IDeltaCompressor
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.IO
Assembly: Coherence.dll
Syntax
public class BinaryDeltaCompressor : IDeltaCompressor
Remarks

The delta format is composed of a leading byte that indicates the format; the format indicator byte is one of the FMT_* field values. If the delta value does not begin with one of the FMT_* indicators, then the delta value is itself the new value. If the delta is null, then it indicates no change. The grammar follows:

BinaryDelta:
  FMT_EMPTY
  FMT_BINDIFF BinaryChangeList-opt OP_TERM
  FMT_REPLACE-opt Bytes
  null

BinaryChangeList:
  OP_EXTRACT Offset Length BinaryChangeList-opt
  OP_APPEND Length Bytes BinaryChangeList-opt

Offset:
Length:
  packed-integer

Bytes:
  byte Bytes-opt

Fields

DELTA_TRUNCATE

A delta value that indicates an empty new value.

Declaration
protected static readonly Binary DELTA_TRUNCATE
Field Value
Type Description
Binary

FMT_BINDIFF

A format indicator (the first byte of the binary delta) that indicates that the new value is formed by applying a series of modifications to the old value. The possible modifications are defined by the OP_* constants.

Declaration
protected const byte FMT_BINDIFF = 244
Field Value
Type Description
byte

FMT_EMPTY

A format indicator (the first byte of the binary delta) that indicates that the new value is a zero-length binary value.

Declaration
protected const byte FMT_EMPTY = 246
Field Value
Type Description
byte

FMT_REPLACE

A format indicator (the first byte of the binary delta) that indicates that the new value is found in its entirety in the delta value. In other words, other than the first byte, the delta is itself the new value.

Declaration
protected const byte FMT_REPLACE = 245
Field Value
Type Description
byte

MIN_BLOCK

Minimum length of an "extract" block to encode.

Declaration
protected const int MIN_BLOCK = 12
Field Value
Type Description
int

NO_BINARY

An empty Binary object.

Declaration
protected static readonly Binary NO_BINARY
Field Value
Type Description
Binary

OP_APPEND

A binary delta operator that instructs the {@link #applyDelta} method to copy the following bytes from the delta value and append them to the new value. The format is the one-byte OP_APPEND indicator followed by a packed int length and then a series of bytes. The length indicates the length of the series of bytes to copy from the delta value and append to the new value.

Declaration
protected const byte OP_APPEND = 2
Field Value
Type Description
byte

OP_EXTRACT

A binary delta operator that instructs the ApplyDelta(Binary, Binary) method to extract bytes from the old value and append them to the new value. The format is the one-byte OP_EXTRACT indicator followed by a packed int offset and packed int length. The offset and length indicate the region of the old value to extract and append to the new value.

Declaration
protected const byte OP_EXTRACT = 1
Field Value
Type Description
byte

OP_TERM

A binary delta operator that instructs the {@link #applyDelta} method that the delta has been fully applied.

Declaration
protected const byte OP_TERM = 3
Field Value
Type Description
byte

Methods

ApplyDelta(Binary, Binary)

Apply a delta to an old value in order to create a new value.

Declaration
public Binary ApplyDelta(Binary binOld, Binary binDelta)
Parameters
Type Name Description
Binary binOld

The old value.

Binary binDelta

The delta information returned from ExtractDelta(Binary, Binary) to apply to the old value.

Returns
Type Description
Binary

The new value.

CreateDelta(Binary, Binary)

Actually create a delta in the binary delta format. This method is designed to be overridden by subclasses that have more intimate knowledge of the contents of the buffers.

Declaration
protected Binary CreateDelta(Binary binOld, Binary binNew)
Parameters
Type Name Description
Binary binOld

The old value.

Binary binNew

The new value.

Returns
Type Description
Binary

A delta in the binary delta format.

EnsureWriter(DataWriter, int)

Make sure that a DataWriter exists if one doesn't already.

Declaration
protected static DataWriter EnsureWriter(DataWriter writer, int cbMax)
Parameters
Type Name Description
DataWriter writer

The existing DataWriter or null.

int cbMax

The expected resulting size of the write buffer

Returns
Type Description
DataWriter

A DataWriter, never null

ExtractDelta(Binary, Binary)

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.

Declaration
public Binary ExtractDelta(Binary binOld, Binary binNew)
Parameters
Type Name Description
Binary binOld

The old value.

Binary binNew

The new value.

Returns
Type Description
Binary

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.

FinalizeDelta(DataWriter)

Convert an open delta output stream into a finalized Binary delta.

Declaration
protected static Binary FinalizeDelta(DataWriter writer)
Parameters
Type Name Description
DataWriter writer

The delta writer.

Returns
Type Description
Binary

Finalized Binary delta.

WriteAppend(DataWriter, int, byte[], int, int)

Encode a binary diff "append" operator to indicate that bytes should be appended from the delta stream to the new value.

Declaration
protected static DataWriter WriteAppend(DataWriter writer, int cbMax, byte[] ab, int of, int cb)
Parameters
Type Name Description
DataWriter writer

The existing DataWriter for the diff, or null

int cbMax

The expected resulting size of the write buffer.

byte[] ab

The byte array from which to get the bytes to append.

int of

The offset of the old buffer to append.

int cb

The length of the old buffer to append.

Returns
Type Description
DataWriter

A DataWriter, never null.

WriteExtract(DataWriter, int, int, int)

Encode a binary diff "extract" operator to indicate that bytes should be copied from the old value to the new value.

Declaration
protected static DataWriter WriteExtract(DataWriter writer, int cbMax, int of, int cb)
Parameters
Type Name Description
DataWriter writer

The existing DataWriter for the diff, or null

int cbMax

The expected resulting size of the write buffer.

int of

The offset of the old buffer to append.

int cb

The length of the old buffer to append.

Returns
Type Description
DataWriter

A DataWriter, never null.

Implements

IDeltaCompressor
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.