Skip to content

Commit

Permalink
intend to remove BasicTISSinkFactory.DTOSinkFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
baisui1981 committed Sep 5, 2022
1 parent bb79c34 commit fe30cb3
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.alibaba.datax.common.util.Configuration;
import com.qlangtech.tis.plugin.ds.DataType;
import com.qlangtech.tis.plugin.ds.IColMetaGetter;

import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -12,7 +13,7 @@
* @author: 百岁([email protected]
* @create: 2022-02-18 15:47
**/
public class HdfsColMeta implements Serializable {
public class HdfsColMeta implements Serializable, IColMetaGetter {

public static final String KEY_COLUMN = "column";
public static final String KEY_NAME = "name";
Expand Down Expand Up @@ -50,6 +51,16 @@ public HdfsColMeta(String colName, Boolean nullable, Boolean pk, DataType dataTy
this.pk = pk;
}

@Override
public boolean isPk() {
return this.pk;
}

@Override
public DataType getType() {
return this.type;
}

public String getName() {
return this.colName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.qlangtech.tis.plugin.ds;

import java.io.Serializable;

/**
* @author: 百岁([email protected]
* @create: 2022-08-25 17:45
**/
public class ColMeta implements IColMetaGetter, Serializable {
public final String name;
public final DataType type;
public final boolean pk;

public ColMeta(String name, DataType type, boolean pk) {
this.name = name;
this.type = type;
this.pk = pk;
}

@Override
public boolean isPk() {
return this.pk;
}

@Override
public String getName() {
return name;
}

@Override
public DataType getType() {
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class DataType implements Serializable {

public final int type;
public final int columnSize;
private final String typeName;
public final String typeName;
// decimal 的小数位长度
private Integer decimalDigits;

Expand All @@ -46,8 +46,9 @@ public DataType(int type) {
}

/**
* @param type java.sql.Types
* @param type
* @param columnSize
* @see java.sql.Types
*/
public DataType(int type, String typeName, int columnSize) {
this.type = type;
Expand All @@ -71,7 +72,9 @@ public DataXReaderColType getCollapse() {
return DataXReaderColType.Long;
case Types.FLOAT:
case Types.DOUBLE:
case Types.REAL:
case Types.DECIMAL:
case Types.NUMERIC:
return DataXReaderColType.Double;
case Types.DATE:
case Types.TIME:
Expand All @@ -93,11 +96,7 @@ public DataXReaderColType getCollapse() {
public <T> T accept(TypeVisitor<T> visitor) {
switch (this.type) {
case Types.INTEGER: {
if (this.isUnsigned()) {
return visitor.bigInt(this);
} else {
return visitor.intType(this);
}
return visitor.intType(this);
}
case Types.TINYINT:
return visitor.tinyIntType(this);
Expand All @@ -106,10 +105,12 @@ public <T> T accept(TypeVisitor<T> visitor) {
case Types.BIGINT:
return visitor.bigInt(this);
case Types.FLOAT:
case Types.REAL:
return visitor.floatType(this);
case Types.DOUBLE:
return visitor.doubleType(this);
case Types.DECIMAL:
case Types.NUMERIC:
return visitor.decimalType(this);
case Types.DATE:
return visitor.dateType(this);
Expand All @@ -118,6 +119,7 @@ public <T> T accept(TypeVisitor<T> visitor) {
case Types.TIMESTAMP:
return visitor.timestampType(this);
case Types.BIT:
return visitor.boolType(this);
case Types.BOOLEAN:
return visitor.bitType(this);
case Types.BLOB:
Expand Down Expand Up @@ -244,6 +246,7 @@ public static DataType ds(String ser) {
public String toString() {
return "{" +
"type=" + type +
",typeName=" + this.typeName +
", columnSize=" + columnSize +
", decimalDigits=" + decimalDigits +
'}';
Expand Down Expand Up @@ -287,5 +290,9 @@ default T tinyIntType(DataType dataType) {
default T smallIntType(DataType dataType) {
return intType(dataType);
}

default T boolType(DataType dataType) {
return bitType(dataType);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.qlangtech.tis.plugin.ds;

import java.io.Serializable;

/**
* @author: 百岁([email protected]
* @create: 2022-08-25 21:05
**/
public interface IColMetaGetter {

public static IColMetaGetter create(String name, DataType type) {
return create(name, type, false);
}

public static IColMetaGetter create(String name, DataType type, boolean pk) {
return new ColMeta(name, type, pk);
}

public String getName();

public DataType getType();

public boolean isPk();


}

0 comments on commit fe30cb3

Please sign in to comment.