Class SerializationUtil

java.lang.Object
com._1c.g5.v8.bm.common.serialization.SerializationUtil

public final class SerializationUtil extends Object
Serialization utilities.
  • Method Details

    • packInt

      public static void packInt(int value, DataOutput out) throws IOException
      Packs the specified int value and writes it to the provided output.

      The more leading zeroes in the two's complement binary representation the value has the less bytes its packed representation requires. Thus this method may be inefficient if there are lots of positive numbers greater than or equal to 228 or lots of any negative numbers whose packed representation requires 5 bytes. In this case use DataOutput.writeInt(int) method.

      In case there are lots of both positive and negative numbers with low absolute values consider applying ZigZag encoding before packing.

      This method has been borrowed from MapDB but originally comes from Kryo Framework, author Nathan Sweet. It was modified to fit MapDB needs.

      Parameters:
      value - The value to pack and write.
      out - The output to write the packed value to.
      Throws:
      IOException - in case an I/O error occurs.
    • unpackInt

      public static int unpackInt(DataInput in) throws IOException
      Reads and unpacks an int value.

      This method has been borrowed from MapDB but originally comes from Kryo Framework, author Nathan Sweet. It was modified to fit MapDB needs.

      Parameters:
      in - The input to read the packed value from.
      Returns:
      the read and unpacked value.
      Throws:
      IOException - in case an I/O error occurs.
    • packLong

      public static void packLong(long value, DataOutput out) throws IOException
      Packs the specified long value and writes it to the provided output.

      The more leading zeroes in the two's complement binary representation the value has the less bytes its packed representation requires. Thus this method may be inefficient if there are lots of positive numbers greater than or equal to 256 whose packed representation requires at least 9 bytes or lots of any negative numbers whose packed representation requires 10 bytes. In this case use DataOutput.writeLong(long) method.

      In case there are lots of both positive and negative numbers with low absolute values consider applying ZigZag encoding before packing.

      This method has been borrowed from MapDB but originally comes from Kryo Framework, author Nathan Sweet. It was modified to fit MapDB needs.

      Parameters:
      value - The value to pack and write.
      out - The output to write the packed value to.
      Throws:
      IOException - in case an I/O error occurs.
    • unpackLong

      public static long unpackLong(DataInput in) throws IOException
      Reads and unpacks an long value.

      This method has been borrowed from MapDB but originally comes from Kryo Framework, author Nathan Sweet. It was modified to fit MapDB needs.

      Parameters:
      in - The input to read the packed value from.
      Returns:
      the read and unpacked value.
      Throws:
      IOException - in case an I/O error occurs.