Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hotfix-#1029][redis] Fix Redis Lookup Connector. #1030

Merged
merged 1 commit into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private String[] getValues(ColumnRowData row) {
}
}

return values.toArray(new String[values.size()]);
return values.toArray(new String[0]);
}

private String concatValues(ColumnRowData row) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ private GenericRowData getGenericRowData(Map<String, String> input) throws Excep
typeIndexList.stream()
.filter(x -> x.first.equals(key))
.collect(Collectors.toList());
Triplet<String, Integer, LogicalType> typeTriplet = collect.get(0);
genericRowData.setField(
typeTriplet.second,
toInternalConverters.get(typeTriplet.second).deserialize(input.get(key)));
if (!collect.isEmpty()) {
Triplet<String, Integer, LogicalType> typeTriplet = collect.get(0);
genericRowData.setField(
typeTriplet.second,
toInternalConverters.get(typeTriplet.second).deserialize(input.get(key)));
}
}

return genericRowData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,23 @@
public enum RedisDataMode {

/** reader mode */
H_GET("hget"),

/** write mode */
SET("set"),
L_PUSH("lpush"),
R_PUSH("rpush"),
S_ADD("sadd"),
Z_ADD("zadd"),
H_SET("hset");
H_SET("hset"),
;

public String mode;
public final String mode;

RedisDataMode(String mode) {
this.mode = mode;
}

public String getMode() {
return mode;
}

public static RedisDataMode getDataMode(String mode) {
for (RedisDataMode redisDataMode : RedisDataMode.values()) {
if (redisDataMode.getMode().equals(mode)) {
Expand All @@ -54,4 +52,8 @@ public static RedisDataMode getDataMode(String mode) {

throw new RuntimeException("Unsupported redis data mode:" + mode);
}

public String getMode() {
return mode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum RedisDataType {

HASH("hash");

public String type;
public final String type;

RedisDataType(String type) {
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class RedisAllTableFunction extends AbstractAllTableFunction {

private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(RedisAllTableFunction.class);
private final RedisConf redisConf;
private transient RedisSyncClient redisSyncClient;
private RedisConf redisConf;

public RedisAllTableFunction(
RedisConf redisConf,
Expand All @@ -68,13 +68,12 @@ public RedisAllTableFunction(

@Override
public void eval(Object... keys) {
StringBuilder keyPattern = new StringBuilder(redisConf.getTableName());
keyPattern
.append("_")
.append(Arrays.stream(keys).map(String::valueOf).collect(Collectors.joining("_")));
String keyPattern =
redisConf.getTableName()
+ "_"
+ Arrays.stream(keys).map(String::valueOf).collect(Collectors.joining("_"));
List<Map<String, Object>> cacheList =
((Map<String, List<Map<String, Object>>>) cacheRef.get())
.get(keyPattern.toString());
((Map<String, List<Map<String, Object>>>) cacheRef.get()).get(keyPattern);

// 有数据才往下发,(左/内)连接flink会做相应的处理
if (!CollectionUtils.isEmpty(cacheList)) {
Expand Down