Skip to content

Commit a184166

Browse files
committed
add freshMan readme dialog,datavane/tis#448
1 parent dad20fe commit a184166

4 files changed

Lines changed: 36 additions & 26 deletions

File tree

tis-incr/tis-flink-extends/src/main/java/com/qlangtech/plugins/incr/flink/cdc/FlinkCDCPipelineEventProcess.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public Object apply(Object o) {
6262
}
6363
}
6464

65+
66+
6567
public static class FlinkPipelineDecimalConvert extends BiFunction {
6668
// private final DataType type;
6769

tis-incr/tis-realtime-flink/src/main/java/com/qlangtech/tis/plugins/incr/flink/cdc/BasicFlinkDataMapper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ public FlinkCol varcharType(DataType type) {
316316
//, DataTypes.VARCHAR(type.columnSize)
317317
, new StringConvert()
318318
, FlinkCol.NoOp()
319-
, new FlinkCDCPipelineEventProcess(org.apache.flink.cdc.common.types.DataTypes.VARCHAR(type.getColumnSize()), new FlinkPipelineStringConvert())
319+
, new FlinkCDCPipelineEventProcess(
320+
org.apache.flink.cdc.common.types.DataTypes.VARCHAR(type.getColumnSize())
321+
, new FlinkPipelineStringConvert())
320322
, new RowFieldGetterFactory.StringGetter(meta.getName(), colIndex));
321323
}
322324

@@ -336,9 +338,6 @@ public static FlinkCol mapFlinkCol(IColMetaGetter meta, int colIndex) {
336338
}
337339

338340

339-
340-
341-
342341
protected abstract IMPLDATA createRowData(DTO dto);
343342

344343
static class ShortConvert extends BiFunction {
@@ -385,6 +384,9 @@ public Object apply(Object o) {
385384
if (o instanceof String) {
386385
return Integer.parseInt((String) o);
387386
}
387+
if (o instanceof Number) {
388+
return ((Number) o).intValue();
389+
}
388390
return o;
389391
}
390392
}

tis-incr/tis-realtime-flink/src/main/java/com/qlangtech/tis/plugins/incr/flink/cdc/FlinkCol2Index.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
package com.qlangtech.tis.plugins.incr.flink.cdc;
2020

2121
import com.alibaba.datax.common.element.ICol2Index;
22-
import org.apache.flink.calcite.shaded.com.google.common.collect.Maps;
22+
import com.qlangtech.plugins.incr.flink.cdc.FlinkCol;
23+
import org.apache.commons.collections.CollectionUtils;
24+
import org.apache.commons.lang3.tuple.Pair;
2325

2426
import java.io.Serializable;
25-
import java.util.Collections;
27+
import java.util.List;
2628
import java.util.Map;
2729
import java.util.Objects;
2830
import java.util.stream.Collectors;
@@ -34,8 +36,25 @@
3436
public class FlinkCol2Index implements ICol2Index, Serializable {
3537
final Map<String, ICol2Index.Col> col2IndexMapper;
3638

39+
public static FlinkCol2Index create(List<FlinkCol> cols) {
40+
if (CollectionUtils.isEmpty(cols)) {
41+
throw new IllegalArgumentException("param cols can not be empty");
42+
}
43+
Map<String, Pair<Integer, FlinkCol>> col2IdxBuilder = com.google.common.collect.Maps.newHashMap();
44+
int idx = 0;
45+
for (FlinkCol col : cols) {
46+
col2IdxBuilder.put(col.name, Pair.of(idx++, col));
47+
}
48+
49+
return new FlinkCol2Index(
50+
col2IdxBuilder.entrySet().stream().collect(
51+
Collectors.toUnmodifiableMap((entry) -> entry.getKey() //
52+
, (entry) -> new ICol2Index.Col(entry.getValue().getKey(), entry.getValue().getValue().colType))));
53+
}
54+
55+
3756
public FlinkCol2Index(Map<String, ICol2Index.Col> col2IndexMapper) {
38-
this.col2IndexMapper = Maps.newHashMap(Objects.requireNonNull(col2IndexMapper, "param col2IndexMapper can not be null"));
57+
this.col2IndexMapper = (Objects.requireNonNull(col2IndexMapper, "param col2IndexMapper can not be null"));
3958
}
4059

4160
@Override

tis-incr/tis-realtime-flink/src/main/java/com/qlangtech/tis/plugins/incr/flink/cdc/ReocrdTransformerMapper.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,15 @@
1818

1919
package com.qlangtech.tis.plugins.incr.flink.cdc;
2020

21-
import com.alibaba.datax.common.element.ICol2Index;
2221
import com.google.common.collect.Lists;
23-
import com.google.common.collect.Maps;
2422
import com.qlangtech.plugins.incr.flink.cdc.FlinkCol;
2523
import com.qlangtech.tis.plugin.datax.transformer.RecordTransformerRules;
2624
import com.qlangtech.tis.plugin.datax.transformer.UDFDefinition;
27-
import org.apache.commons.lang3.tuple.Pair;
2825
import org.apache.flink.api.common.functions.MapFunction;
2926

3027
import java.io.Serializable;
3128
import java.util.List;
32-
import java.util.Map;
3329
import java.util.Objects;
34-
import java.util.stream.Collectors;
3530

3631
/**
3732
* 执行TIS中定义的 transformer执行逻辑
@@ -45,21 +40,13 @@ public abstract class ReocrdTransformerMapper<Type> implements MapFunction<Type,
4540
private final FlinkCol2Index col2IdxMapper;
4641

4742
public ReocrdTransformerMapper(List<FlinkCol> cols, RecordTransformerRules transformerRules) {
48-
this.cols = Lists.newArrayList(Objects.requireNonNull(cols, "cols can not be null"));
49-
this.transformerUDF
50-
= Objects.requireNonNull(transformerRules, "param transformerRules can not be null")
51-
.rules.stream().map((t) -> t.getUdf()).collect(Collectors.toList());
52-
53-
Map<String, Pair<Integer, FlinkCol>> col2IdxBuilder = Maps.newHashMap();
54-
int idx = 0;
55-
for (FlinkCol col : cols) {
56-
col2IdxBuilder.put(col.name, Pair.of(idx++, col));
57-
}
43+
this(cols, transformerRules.getTransformerUDFs());
44+
}
5845

59-
this.col2IdxMapper = new FlinkCol2Index(
60-
col2IdxBuilder.entrySet().stream().collect(
61-
Collectors.toMap((entry) -> entry.getKey() //
62-
, (entry) -> new ICol2Index.Col(entry.getValue().getKey(), entry.getValue().getValue().colType))));
46+
public ReocrdTransformerMapper(List<FlinkCol> cols, List<UDFDefinition> transformerUDF) {
47+
this.cols = Lists.newArrayList(Objects.requireNonNull(cols, "cols can not be null"));
48+
this.transformerUDF = transformerUDF;
49+
this.col2IdxMapper = FlinkCol2Index.create(cols);
6350
}
6451

6552
@Override

0 commit comments

Comments
 (0)