Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.io
Class BinaryDeltaCompressor

    java.lang.Object
      com.tangosol.io.BinaryDeltaCompressor

All Implemented Interfaces:
  DeltaCompressor

Direct Known Subclasses:
  PofDeltaCompressor

    public class BinaryDeltaCompressor

extends java.lang.Object
implements DeltaCompressor

A DeltaCompressor implementation that works with opaque (binary) values.

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

Author:
  cp 2009.01.06

Field Summary
`protected static Binary` | `DELTA_TRUNCATE` A delta value that indicates an empty new value.
`protected static byte` | `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.
`protected static 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.
`protected static 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.
`protected static int` | `MIN_BLOCK` Minimum length of an "extract" block to encode.
`protected static Binary` | `NO_BINARY` An empty Binary object.
`protected static byte` | `OP_APPEND` A binary delta operator that instructs the `applyDelta(com.tangosol.io.ReadBuffer, com.tangosol.io.ReadBuffer)` method to copy the following bytes from the delta value and append them to the new value.
`protected static byte` | `OP_EXTRACT` A binary delta operator that instructs the `applyDelta(com.tangosol.io.ReadBuffer, com.tangosol.io.ReadBuffer)` method to extract bytes from the old value and append them to the new value.
`protected static byte` | `OP_TERM` A binary delta operator that instructs the `applyDelta(com.tangosol.io.ReadBuffer, com.tangosol.io.ReadBuffer)` method that the delta has been fully applied.

Constructor Summary
`BinaryDeltaCompressor()` Default constructor.

Method Summary
`ReadBuffer` | `applyDelta(ReadBuffer bufOld, ReadBuffer bufDelta)` Apply a delta to an old value in order to create a new value.
`protected ReadBuffer` | `createDelta(ReadBuffer bufOld, ReadBuffer bufNew)` Actually create a delta in the binary delta format.
`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.

Field Detail

### FMT_EMPTY

    protected static final 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.

  See Also:
    Constant Field Values

### FMT_REPLACE

    protected static final 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.

  See Also:
    Constant Field Values

### FMT_BINDIFF

    protected static final byte 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.

  See Also:
    Constant Field Values

### OP_EXTRACT

    protected static final byte OP_EXTRACT

  A binary delta operator that instructs the `applyDelta(com.tangosol.io.ReadBuffer, com.tangosol.io.ReadBuffer)` 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.

  See Also:
    Constant Field Values

### OP_APPEND

    protected static final byte OP_APPEND

  A binary delta operator that instructs the `applyDelta(com.tangosol.io.ReadBuffer, com.tangosol.io.ReadBuffer)` 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.

  See Also:
    Constant Field Values

### OP_TERM

    protected static final byte OP_TERM

  A binary delta operator that instructs the `applyDelta(com.tangosol.io.ReadBuffer, com.tangosol.io.ReadBuffer)` method that the delta has been fully applied.

  See Also:
    Constant Field Values

### MIN_BLOCK

    protected static final int MIN_BLOCK

  Minimum length of an "extract" block to encode.

  See Also:
    Constant Field Values

### NO_BINARY

    protected static final Binary NO_BINARY

  An empty Binary object.

### DELTA_TRUNCATE

    protected static final Binary DELTA_TRUNCATE

  A delta value that indicates an empty new value.

Constructor Detail

### BinaryDeltaCompressor

    public BinaryDeltaCompressor()

  Default constructor.

Method Detail

### 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.

  Specified by:
    `extractDelta` in interface `DeltaCompressor`
  Parameters:
    `bufOld` - the old value
    `bufNew` - the new value
  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(com.tangosol.io.ReadBuffer, com.tangosol.io.ReadBuffer)` to apply to the old value
  Returns:
    the new value

### createDelta

    protected ReadBuffer createDelta(ReadBuffer bufOld,
                                     ReadBuffer bufNew)

  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.

  Parameters:
    `bufOld` - the old value
    `bufNew` - the new value
  Returns:
    a delta in the binary delta format

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.