Class BaseRdbParser
- java.lang.Object
-
- com.moilioncircle.redis.replicator.rdb.BaseRdbParser
-
public class BaseRdbParser extends Object
- Since:
- 2.1.0
- Author:
- Leon Chen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseRdbParser.Lenstatic classBaseRdbParser.LenHelperstatic classBaseRdbParser.StringHelper
-
Field Summary
Fields Modifier and Type Field Description protected RedisInputStreamin
-
Constructor Summary
Constructors Constructor Description BaseRdbParser(RedisInputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteArrayrdbGenericLoadStringObject(int flags)1.|11xxxxxx|xxxxxxxx| remaining 6bit is 0, then an 8 bit integer followsdoublerdbLoadBinaryDoubleValue()floatrdbLoadBinaryFloatValue()doublerdbLoadDoubleValue()ByteArrayrdbLoadEncodedStringObject()ByteArrayrdbLoadIntegerObject(int enctype, int flags)BaseRdbParser.LenrdbLoadLen()read bytes 1 or 2 or 5ByteArrayrdbLoadLzfStringObject(int flags)|11xxxxxx| remaining 6bit is 3,then lzf compressed string followslongrdbLoadMillisecondTime()"expiry time in ms".ByteArrayrdbLoadPlainStringObject()intrdbLoadTime()"expiry time in seconds".
-
-
-
Field Detail
-
in
protected final RedisInputStream in
-
-
Constructor Detail
-
BaseRdbParser
public BaseRdbParser(RedisInputStream in)
-
-
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 51. |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,2flags- 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 followslzf 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 follows2.|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
-
rdbLoadDoubleValue
public double rdbLoadDoubleValue() throws IOException- Throws:
IOException
-
rdbLoadBinaryDoubleValue
public double rdbLoadBinaryDoubleValue() throws IOException- Throws:
IOException
-
rdbLoadBinaryFloatValue
public float rdbLoadBinaryFloatValue() throws IOException- Returns:
- single precision float
- Throws:
IOException- io exception- Since:
- 2.2.0
-
-