TyrantLucifer commented on code in PR #3894: URL: https://github.com/apache/incubator-seatunnel/pull/3894#discussion_r1066758202
########## seatunnel-connectors-v2/connector-maxcompute/src/main/java/com/aliyun/odps/type/SimpleArrayTypeInfo.java: ########## @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.aliyun.odps.type; + +import com.aliyun.odps.OdpsType; + +public class SimpleArrayTypeInfo implements ArrayTypeInfo { + private final TypeInfo valueType; + + SimpleArrayTypeInfo(TypeInfo typeInfo) { + if (typeInfo == null) { + throw new IllegalArgumentException("Invalid element type."); Review Comment: throw new MaxcomputeConnectorException(CommonErrorCode.UNSUPPORTED_DATA_TYPE) ########## seatunnel-connectors-v2/connector-maxcompute/src/main/java/com/aliyun/odps/type/SimpleStructTypeInfo.java: ########## @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.aliyun.odps.type; + +import com.aliyun.odps.OdpsType; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class SimpleStructTypeInfo implements StructTypeInfo { + private final List<String> fieldNames; + private final List<TypeInfo> fieldTypeInfos; + + SimpleStructTypeInfo(List<String> names, List<TypeInfo> typeInfos) { + this.validateParameters(names, typeInfos); + this.fieldNames = this.toLowerCase(names); + this.fieldTypeInfos = new ArrayList(typeInfos); + } + + private List<String> toLowerCase(List<String> names) { + List<String> lowerNames = new ArrayList(names.size()); + Iterator var3 = names.iterator(); + + while (var3.hasNext()) { + String name = (String) var3.next(); + lowerNames.add(name.toLowerCase()); + } + + return lowerNames; + } + + private void validateParameters(List<String> names, List<TypeInfo> typeInfos) { + if (names != null && typeInfos != null && !names.isEmpty() && !typeInfos.isEmpty()) { + if (names.size() != typeInfos.size()) { + throw new IllegalArgumentException("The amount of field names must be equal to the amount of field types."); Review Comment: Same as above. ########## seatunnel-connectors-v2/connector-maxcompute/src/main/java/com/aliyun/odps/type/SimpleStructTypeInfo.java: ########## @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.aliyun.odps.type; + +import com.aliyun.odps.OdpsType; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class SimpleStructTypeInfo implements StructTypeInfo { + private final List<String> fieldNames; + private final List<TypeInfo> fieldTypeInfos; + + SimpleStructTypeInfo(List<String> names, List<TypeInfo> typeInfos) { + this.validateParameters(names, typeInfos); + this.fieldNames = this.toLowerCase(names); + this.fieldTypeInfos = new ArrayList(typeInfos); + } + + private List<String> toLowerCase(List<String> names) { + List<String> lowerNames = new ArrayList(names.size()); + Iterator var3 = names.iterator(); + + while (var3.hasNext()) { + String name = (String) var3.next(); + lowerNames.add(name.toLowerCase()); + } + + return lowerNames; + } + + private void validateParameters(List<String> names, List<TypeInfo> typeInfos) { + if (names != null && typeInfos != null && !names.isEmpty() && !typeInfos.isEmpty()) { + if (names.size() != typeInfos.size()) { + throw new IllegalArgumentException("The amount of field names must be equal to the amount of field types."); + } + } else { + throw new IllegalArgumentException("Invalid name or element type for struct."); Review Comment: Same as above. ########## seatunnel-connectors-v2/connector-maxcompute/src/main/java/com/aliyun/odps/type/SimpleMapTypeInfo.java: ########## @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.aliyun.odps.type; + +import com.aliyun.odps.OdpsType; + +public class SimpleMapTypeInfo implements MapTypeInfo { + private final TypeInfo keyType; + private final TypeInfo valueType; + + SimpleMapTypeInfo(TypeInfo keyType, TypeInfo valueType) { + if (keyType != null && valueType != null) { + this.keyType = keyType; + this.valueType = valueType; + } else { + throw new IllegalArgumentException("Invalid key or value type for map."); Review Comment: Same as above. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
