Class PackedIntegerBinding

All Implemented Interfaces:
EntryBinding<Integer>

public class PackedIntegerBinding extends TupleBinding<Integer>
A concrete TupleBinding for an unsorted Integer primitive wrapper or an unsorted int primitive, that stores the value in the smallest number of bytes possible.

There are two ways to use this class:

  1. When using the com.sleepycat.db package directly, the static methods in this class can be used to convert between primitive values and DatabaseEntry objects.
  2. When using the com.sleepycat.collections package, an instance of this class can be used with any stored collection.
See Also:
  • Constructor Details

    • PackedIntegerBinding

      public PackedIntegerBinding()
  • Method Details

    • entryToObject

      public Integer entryToObject(TupleInput input)
      Description copied from class: TupleBinding
      Constructs a key or data object from a TupleInput entry.
      Specified by:
      entryToObject in class TupleBinding<Integer>
      Parameters:
      input - is the tuple key or data entry.
      Returns:
      the key or data object constructed from the entry.
    • objectToEntry

      public void objectToEntry(Integer object, TupleOutput output)
      Description copied from class: TupleBinding
      Converts a key or data object to a tuple entry.
      Specified by:
      objectToEntry in class TupleBinding<Integer>
      Parameters:
      object - is the key or data object.
      output - is the tuple entry to which the key or data should be written.
    • getTupleOutput

      protected TupleOutput getTupleOutput(Integer object)
      Description copied from class: TupleBase
      Returns an empty TupleOutput instance that will be used by the tuple binding or key creator.

      The default implementation of this method creates a new TupleOutput with an initial buffer size that can be changed using the TupleBase.setTupleBufferSize(int) method.

      This method may be overridden to return a TupleOutput instance. For example, an instance per thread could be created and returned by this method. If a TupleOutput instance is reused, be sure to call its FastOutputStream.reset() method before each use.

      Overrides:
      getTupleOutput in class TupleBase<Integer>
      Parameters:
      object - is the object to be written to the tuple output, and may be used by subclasses to determine the size of the output buffer.
      Returns:
      an empty TupleOutput instance.
      See Also:
    • entryToInt

      public static int entryToInt(DatabaseEntry entry)
      Converts an entry buffer into a simple int value.
      Parameters:
      entry - is the source entry buffer.
      Returns:
      the resulting value.
    • intToEntry

      public static void intToEntry(int val, DatabaseEntry entry)
      Converts a simple int value into an entry buffer, using PackedInteger format.
      Parameters:
      val - is the source value.
      entry - is the destination entry buffer.