4343
4444/**
4545 * source data parse to json format
46- *
46+ * <p>
4747 * Date: 2019/12/12
4848 * Company: www.dtstack.com
4949 *
@@ -58,9 +58,12 @@ public class DtNestRowDeserializationSchema extends AbstractDeserializationSchem
5858
5959 private final String [] fieldNames ;
6060 private final TypeInformation <?>[] fieldTypes ;
61- private List <TableInfo .FieldExtraInfo > fieldExtraInfos ;
61+ private List <AbstractTableInfo .FieldExtraInfo > fieldExtraInfos ;
62+ private String charsetName ;
6263
63- public DtNestRowDeserializationSchema (TypeInformation <Row > typeInfo , Map <String , String > rowAndFieldMapping , List <TableInfo .FieldExtraInfo > fieldExtraInfos ) {
64+ public DtNestRowDeserializationSchema (TypeInformation <Row > typeInfo , Map <String , String > rowAndFieldMapping ,
65+ List <AbstractTableInfo .FieldExtraInfo > fieldExtraInfos ,
66+ String charsetName ) {
6467 this .fieldNames = ((RowTypeInfo ) typeInfo ).getFieldNames ();
6568 this .fieldTypes = ((RowTypeInfo ) typeInfo ).getFieldTypes ();
6669 this .rowAndFieldMapping = rowAndFieldMapping ;
@@ -99,7 +102,7 @@ public Row deserialize(byte[] message) throws IOException {
99102 }
100103 }
101104
102- private void parseTree (JsonNode jsonNode , String prefix ){
105+ private void parseTree (JsonNode jsonNode , String prefix ) {
103106 if (jsonNode .isArray ()) {
104107 ArrayNode array = (ArrayNode ) jsonNode ;
105108 for (int i = 0 ; i < array .size (); i ++) {
@@ -118,15 +121,15 @@ private void parseTree(JsonNode jsonNode, String prefix){
118121 return ;
119122 }
120123 Iterator <String > iterator = jsonNode .fieldNames ();
121- while (iterator .hasNext ()){
124+ while (iterator .hasNext ()) {
122125 String next = iterator .next ();
123126 JsonNode child = jsonNode .get (next );
124127 String nodeKey = getNodeKey (prefix , next );
125128
126129 nodeAndJsonNodeMapping .put (nodeKey , child );
127- if (child .isArray ()){
130+ if (child .isArray ()) {
128131 parseTree (child , nodeKey );
129- }else {
132+ } else {
130133 parseTree (child , nodeKey );
131134 }
132135 }
@@ -137,8 +140,8 @@ private JsonNode getIgnoreCase(String key) {
137140 return nodeAndJsonNodeMapping .get (nodeMappingKey );
138141 }
139142
140- private String getNodeKey (String prefix , String nodeName ){
141- if (Strings .isNullOrEmpty (prefix )){
143+ private String getNodeKey (String prefix , String nodeName ) {
144+ if (Strings .isNullOrEmpty (prefix )) {
142145 return nodeName ;
143146 }
144147 return prefix + "." + nodeName ;
@@ -162,15 +165,15 @@ private Object convert(JsonNode node, TypeInformation<?> info) {
162165 } else {
163166 return node .asText ();
164167 }
165- } else if (info .getTypeClass ().equals (Types .SQL_DATE .getTypeClass ())) {
168+ } else if (info .getTypeClass ().equals (Types .SQL_DATE .getTypeClass ())) {
166169 return Date .valueOf (node .asText ());
167170 } else if (info .getTypeClass ().equals (Types .SQL_TIME .getTypeClass ())) {
168171 // local zone
169172 return Time .valueOf (node .asText ());
170173 } else if (info .getTypeClass ().equals (Types .SQL_TIMESTAMP .getTypeClass ())) {
171174 // local zone
172175 return Timestamp .valueOf (node .asText ());
173- } else {
176+ } else {
174177 // for types that were specified without JSON schema
175178 // e.g. POJOs
176179 try {
0 commit comments