Redis

Summary

Redis Load Node supports writing data to redis.

Data Type

See detail: Redis Data Type

Plain

c1c2c3c4c5c6c7
rowKey

Redis strings commands are used for managing string values in Redis

The first element is Redis row key,must be string type, and the remaining fields(c2~c6) will be serialized into one value and put into Redis.

Hash

  • A Redis hash is a data type that represents a mapping between a string field and a string value. There are two members in hash DataType:

  • Redis Hash

  • Redis Hash value

Set

Redis SET are simply lists of strings, sorted by insertion order. You can add elements in Redis SET in the head or the tail of the list.

BitMap

BitMaps are not an actual data type, but a set of bit-oriented operations defined on the String type.Since strings are binary safe blobs and their maximum length is 512 MB, they are suitable to set up to 2^32 different bits.

SchemaMappingMode

Dynamic

The DYNAMIC mode witch mapping a java.util.Map to RedisDataType. There are two members in DYNAMIC mode:

  • Redis key
  • java.util.Map object, witch will be iterated, the entry key is redis key, and the entry value is redis value.

Static Prefix Match

The are at least two fields, the first member is redis key, and each field from the second field represents a redis value.

  1. key, field, value1, value2, value3, [value]...

Static KV Pair

There are two fields, the first field is key, and the other fields are pairs of field and value.

  1. key, field1, value1,field2,value2,field3,value3,[field,value]...

SQL Demo

Plain

Plain only support STATIC_PREFIX_MATCH schema mapping mode

  1. CREATE TABLE sink (
  2. key STRING,
  3. aaa STRING,
  4. bbb DOUBLE,
  5. ccc BIGINT,
  6. PRIMARY KEY (`key`) NOT ENFORCED
  7. ) WITH (
  8. 'connector' = 'redis-inlong',
  9. 'sink.batch-size' = '1',
  10. 'format' = 'csv',
  11. 'data-type' = 'PLAIN',
  12. 'redis-mode' = 'standalone',
  13. 'host' = 'localhost',
  14. 'port' = '56615',
  15. 'maxIdle' = '8',
  16. 'minIdle' = '1',
  17. 'maxTotal' = '2',
  18. 'timeout' = '2000'
  19. );

Hash with Prefix Match

c1c2c3c4c5c6c7
rowKeyfield: String

The first element is Redis row key, must be string type. The second element is Redis field name in Hash DataType. The remaining fields(c2~c7) will be serialized into one value and put into redis

  1. CREATE TABLE sink (
  2. key STRING,
  3. field_name STRING,
  4. value_1 DOUBLE,
  5. value_2 BIGINT,
  6. PRIMARY KEY (`key`) NOT ENFORCED
  7. ) WITH (
  8. 'connector' = 'redis-inlong',
  9. 'sink.batch-size' = '1',
  10. 'format' = 'csv',
  11. 'data-type' = 'HASH',
  12. 'redis-mode' = 'standalone',
  13. 'host' = 'localhost',
  14. 'port' = '56869',
  15. 'maxIdle' = '8',
  16. 'minIdle' = '1',
  17. 'maxTotal' = '2',
  18. 'timeout' = '2000'
  19. );

Hash with Static KV Pair

c1c2c3c4c5c6c7
rowKeyfield1: Stringvalue 1:Stringfield 2: Stringvalue 2:Stringfield 3: Stringvalue 3:String

The first element is Redis row key, must be string type. The odd elements(c2 / c4 / c6) are Redis field names in Hash DataType, must be String type. The even elements(c3 / c5 / c7) are Redis field values in Hash DataType, must be String type.

  1. CREATE TABLE sink (
  2. key STRING,
  3. field1 STRING,
  4. value1 STRING,
  5. field2 STRING,
  6. value2 STRING,
  7. PRIMARY KEY (`key`) NOT ENFORCED
  8. ) WITH (
  9. 'connector' = 'redis-inlong',
  10. 'sink.batch-size' = '1',
  11. 'format' = 'csv',
  12. 'data-type' = 'HASH',
  13. 'schema-mapping-mode' = 'STATIC_KV_PAIR',
  14. 'redis-mode' = 'standalone',
  15. 'host' = 'localhost',
  16. 'port' = '6379',
  17. 'maxIdle' = '8',
  18. 'minIdle' = '1',
  19. 'maxTotal' = '2',
  20. 'timeout' = '2000'
  21. );

Hash with dynamic

c1c2
rowKeyfieldValueMap

The first element is Redis row key, must be string type. The second element is must be Map<String,String> type: key is fieldName, value is fieldValue.

  1. CREATE TABLE sink (
  2. key STRING,
  3. fieldValueMap MAP<STRING,STRING>,
  4. PRIMARY KEY (`key`) NOT ENFORCED
  5. ) WITH (
  6. 'connector' = 'redis-inlong',
  7. 'sink.batch-size' = '1',
  8. 'format' = 'csv',
  9. 'data-type' = 'HASH',
  10. 'schema-mapping-mode' = 'DYNAMIC',
  11. 'redis-mode' = 'standalone',
  12. 'host' = 'localhost',
  13. 'port' = '6379',
  14. 'maxIdle' = '8',
  15. 'minIdle' = '1',
  16. 'maxTotal' = '2',
  17. 'timeout' = '2000'
  18. )"

BitMap with static KV pair

c1c2c3c4c5c6c7
rowKeyfield1: Longvalue 1:Booleanfield 2: Longvalue 2:Booleanfield 3: Longvalue 3:Boolean

The first element is Redis row key, must be string type. The odd elements(c2 /c4 /c6 ) are Redis offsets in Bitmap DataType, must be Long type. The even elements(c3 / c5 / c7) are Redis values in Bitmap DataType, must be Boolean type.

  1. CREATE TABLE sink (
  2. key STRING,
  3. offset_1 BIGINT,
  4. value_1 BOOLEAN,
  5. offset_2 BIGINT,
  6. value_2 BOOLEAN,
  7. PRIMARY KEY (`key`) NOT ENFORCED
  8. ) WITH (
  9. 'connector' = 'redis-inlong',
  10. 'sink.batch-size' = '1',
  11. 'format' = 'csv',
  12. 'data-type' = 'BITMAP',
  13. 'schema-mapping-mode' = 'STATIC_KV_PAIR',
  14. 'redis-mode' = 'standalone',
  15. 'host' = 'localhost',
  16. 'port' = '6379',
  17. 'maxIdle' = '8',
  18. 'minIdle' = '1',
  19. 'maxTotal' = '2',
  20. 'timeout' = '2000'
  21. )