Class BinaryModelPackage


  • public class BinaryModelPackage
    extends Object
    The python package (sklearn4x) implements a class named BinaryBuffer that saves the python objects in a binary format. BinaryModelPackage is its counterpart to load these files (or stream) in other languages.
    • Method Detail

      • fromFile

        public static BinaryModelPackage fromFile​(String path)
        Creates a new BinaryModelPackage that reads from a given file.
        Parameters:
        path - Path to the file to be read.
        Returns:
        A BinaryModelPackage instance to read the package file.
      • fromStream

        public static BinaryModelPackage fromStream​(InputStream stream)
        Creates a new BinaryModelPackage that reads from a given stream. This method is useful to load the files from a custom-made package or an encrypted one.
        Parameters:
        stream - The input stream that should be loaded. It is recommended to use a buffered stream.
        Returns:
        A BinaryModelPackage instance to read the package stream.
      • readByte

        public byte readByte()
        Reads a byte from the stream.
        Returns:
        A byte value stored in the stream.
      • readShort

        public short readShort()
        Reads a 16-bits integer from the stream. The values are stored in little endian formats.
        Returns:
        A short value stored in the stream.
      • readInteger

        public int readInteger()
        Reads a 32-bits integer from the stream. The values are stored in little endian formats.
        Returns:
        An integer value stored in the stream.
      • readLongInteger

        public long readLongInteger()
        Reads a 64-bits integer from the stream. The values are stored in little endian formats.
        Returns:
        An integer value stored in the stream.
      • readFloat

        public float readFloat()
        Reads a 32-bits floating point value from the stream. The values are stored in IEE 754 and little endian formats.
        Returns:
        A float value stored in the stream.
      • readDouble

        public double readDouble()
        Reads a 64-bits floating point value from the stream. The values are stored in IEE 754 and little endian formats.
        Returns:
        A double value stored in the stream.
      • readString

        public String readString()
        Reads a string with UTF-8 encoding from stream.
        Returns:
        The string stored in the stream, or null if it has no value.
      • readNumpyArray

        public NumpyArray readNumpyArray()
        Read a multidimensional numpy array from the stream.
        Returns:
        The numpy array stored in the stream, or null if it has no value.
      • readList

        public List<Object> readList()
        Reads a list from the stream.
        Returns:
        The list stored in the stream, or null if it has no value.
      • readDictionary

        public Map<String,​Object> readDictionary()
        Reads a dictionary from the stream.
        Returns:
        The dictionary stored in the stream, or null if it has no value.
      • readStringArray

        public String[] readStringArray()
        Reads an array of string from the stream.
        Returns:
        The String[] stored in the stream, or null if it has no value.
      • canRead

        public boolean canRead()
        Checks if there is still available content in the input stream.
        Returns:
        A boolean indicating if the stream still has content or not.