Class BaseRdbParser


  • public class BaseRdbParser
    extends Object
    Since:
    2.1.0
    Author:
    Leon Chen
    • Method Detail

      • rdbLoadTime

        public int rdbLoadTime()
                        throws IOException
        "expiry time in seconds". After that, expiry time is read as a 4 byte unsigned int

        Returns:
        seconds
        Throws:
        IOException - when read timeout
      • rdbLoadMillisecondTime

        public long rdbLoadMillisecondTime()
                                    throws IOException
        "expiry time in ms". After that, expiry time is read as a 8 byte unsigned long

        Returns:
        millisecond
        Throws:
        IOException - when read timeout
      • rdbLoadLen

        public BaseRdbParser.Len rdbLoadLen()
                                     throws IOException
        read bytes 1 or 2 or 5

        1. |00xxxxxx| remaining 6 bits represent the length

        2. |01xxxxxx|xxxxxxxx| the combined 14 bits represent the length

        3. |10xxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx| the remaining 6 bits are discarded.Additional 4 bytes represent the length(big endian in version6)

        4. |11xxxxxx| the remaining 6 bits are read.and then the next object is encoded in a special format.so we set encoded = true

        Returns:
        tuple(len, encoded)
        Throws:
        IOException - when read timeout
        See Also:
        rdbLoadIntegerObject(int, int), rdbLoadLzfStringObject(int)
      • rdbLoadIntegerObject

        public ByteArray rdbLoadIntegerObject​(int enctype,
                                              int flags)
                                       throws IOException
        Parameters:
        enctype - 0,1,2
        flags - RDB_LOAD_ENC: encoded string.RDB_LOAD_PLAIN | RDB_LOAD_NONE:raw bytes
        Returns:
        ByteArray rdb byte array object
        Throws:
        IOException - when read timeout
      • rdbLoadLzfStringObject

        public ByteArray rdbLoadLzfStringObject​(int flags)
                                         throws IOException
        |11xxxxxx| remaining 6bit is 3,then lzf compressed string follows

        lzf format

        |lzf flag|clen:1 or 2 or 5 bytes|len:1 or 2 or 5 bytes | lzf compressed bytes |

        |11xxxxxx|xxxxxxxx|....|xxxxxxxx|xxxxxxxx|....|xxxxxxxx|xxxxxxxx|xxxxxxxx|............xxxxxxxx|

        Parameters:
        flags - RDB_LOAD_ENC: encoded string.RDB_LOAD_PLAIN | RDB_LOAD_NONE:raw bytes
        Returns:
        ByteArray rdb byte array object
        Throws:
        IOException - when read timeout
        See Also:
        rdbLoadLen()
      • rdbGenericLoadStringObject

        public ByteArray rdbGenericLoadStringObject​(int flags)
                                             throws IOException
        1.|11xxxxxx|xxxxxxxx| remaining 6bit is 0, then an 8 bit integer follows

        2.|11xxxxxx|xxxxxxxx|xxxxxxxx| remaining 6bit is 1, then an 16 bit integer follows

        3.|11xxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx| remaining 6bit is 2, then an 32 bit integer follows

        4.|11xxxxxx| remaining 6bit is 3,then lzf compressed string follows

        Parameters:
        flags - RDB_LOAD_ENC: encoded string.RDB_LOAD_PLAIN | RDB_LOAD_NONE:raw bytes
        Returns:
        ByteArray rdb byte array object
        Throws:
        IOException - when read timeout
        See Also:
        rdbLoadIntegerObject(int, int), rdbLoadLzfStringObject(int)
      • rdbLoadPlainStringObject

        public ByteArray rdbLoadPlainStringObject()
                                           throws IOException
        Returns:
        ByteArray rdb object with byte[]
        Throws:
        IOException - when read timeout
      • rdbLoadEncodedStringObject

        public ByteArray rdbLoadEncodedStringObject()
                                             throws IOException
        Returns:
        ByteArray rdb object with byte[]
        Throws:
        IOException - when read timeout
      • rdbLoadBinaryFloatValue

        public float rdbLoadBinaryFloatValue()
                                      throws IOException
        Returns:
        single precision float
        Throws:
        IOException - io exception
        Since:
        2.2.0