Skip to content

Commit

Permalink
add transformer for TIS adapter in reltine flink module
Browse files Browse the repository at this point in the history
  • Loading branch information
baisui1981 committed Jun 19, 2024
1 parent 3d8fbe2 commit 18f6142
Show file tree
Hide file tree
Showing 65 changed files with 1,318 additions and 789 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* 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
* <p>
* http:https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.alibaba.datax.common.element;

import java.util.Map;

/**
*
* @author: 百岁([email protected]
* @create: 2024-06-18 17:40
**/
public interface ColumnAwareRecord<ColValType> {

/**
* 设置列名称到列所在index的位置
*
* @param mapper
*/
public void setCol2Index(Map<String, Integer> mapper);

/**
* @param field 字段名称
* @param colVal
*/
public void setColumn(String field, final ColValType colVal);


public void setString(String field, final String val);

/**
* @param field 字段名称
* @return
*/
public ColValType getColumn(String field);

public String getString(String field);
}
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
/**
* 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:https://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.
* 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
* <p>
* http:https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.alibaba.datax.common.element;

import com.alibaba.datax.common.element.Column;
import java.util.Map;

/**
* Created by jingxing on 14-8-24.
*/

public interface Record {
public interface Record extends ColumnAwareRecord<Column> {


public void addColumn(Column column);

public void setColumn(int i, final Column column);

public void addColumn(Column column);

public void setColumn(int i, final Column column);
public Column getColumn(int i);

public Column getColumn(int i);
@Override
default String getString(String field) {
Column colVal = getColumn(field);
return colVal != null ? colVal.asString() : null;
}

public String toString();
public String toString();

public int getColumnNumber();
public int getColumnNumber();

public int getByteSize();
public int getByteSize();

public int getMemorySize();
public int getMemorySize();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import com.qlangtech.tis.datax.IDataXNameAware;
import com.qlangtech.tis.datax.IDataXTaskRelevant;

import java.util.Optional;

/**
* @author: 百岁([email protected]
* @create: 2023-02-23 10:06
**/
public interface IJobContainerContext extends IDataXTaskRelevant, IDataXNameAware {

<T extends ITransformerBuildInfo> Optional<T> getTransformerBuildCfg();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,15 @@
* limitations under the License.
*/

package com.qlangtech.tis.plugin.datax.transformer.jdbcprop;
package com.alibaba.datax.core.job;

import com.qlangtech.tis.plugin.ds.TypeBase;
import java.util.List;

/**
*
* @author: 百岁([email protected]
* @create: 2024-06-10 10:14
* @create: 2024-06-15 12:34
**/
public class VirtualColType extends TypeBase {

private String name;

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

public void setName(String name) {
this.name = name;
}
public interface ITransformerBuildInfo {
List<String> relevantOutterColKeys();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.alibaba.datax.core.util.container;

/**
* @author: 百岁([email protected]
* @create: 2024-06-15 08:22
**/
public interface TransformerConstant {
String JOB_TRANSFORMER = "transformer";
String JOB_TRANSFORMER_NAME = "name";
String JOB_TRANSFORMER_RELEVANT_KEYS = "cols";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,30 @@
* limitations under the License.
*/

import org.apache.commons.lang3.StringUtils;

/**
* @author: 百岁([email protected]
* @create: 2023-02-23 10:35
**/
public interface IDataXNameAware {
/**
* 是否在索引
*
* @return
*/
default boolean isCollectionAware() {
return StringUtils.isNotEmpty(getCollectionName());
}

String getCollectionName();

/**
* 取得DataX名称
*
* @return
*/
public String getTISDataXName();
public default String getTISDataXName() {
return this.getCollectionName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
*/
package com.qlangtech.tis.test;

import org.junit.Before;

/**
* @author 百岁([email protected]
* @date 2021-03-04 12:41
*/
public interface TISEasyMock {

@Before

default void clearMocks() {
EasyMockUtil.clearMocks();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* 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:https://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.
* 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
* <p>
* http:https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.qlangtech.tis.realtime.transfer;

Expand Down Expand Up @@ -48,13 +48,28 @@ public static StringBuffer removeUnderline(String value) {
}

public static StringBuffer addUnderline(String value) {
//return UnderlineUtils.addUnderline(value);
StringBuffer parsedName = new StringBuffer();
char[] nameAry = value.toCharArray();
boolean firstAppend = true;
boolean previousUnderline = false;
for (int i = 0; i < nameAry.length; i++) {
if (Character.isUpperCase(nameAry[i])) {
parsedName.append('_').append(Character.toLowerCase(nameAry[i]));
if (firstAppend) {
parsedName.append(Character.toLowerCase(nameAry[i]));
firstAppend = false;
} else {
if (!previousUnderline) {
parsedName.append('_');
}
parsedName.append(Character.toLowerCase(nameAry[i]));
previousUnderline = true;
}
} else {
parsedName.append(nameAry[i]);
firstAppend = false;
previousUnderline = false;
// .append(Character.toLowerCase());
}
}
return parsedName;
Expand Down
2 changes: 2 additions & 0 deletions tis-builder-api/src/test/java/com/qlangtech/tis/TestAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.qlangtech.tis.fs.TestIPath;
import com.qlangtech.tis.manage.common.TestConfig;
import com.qlangtech.tis.realtime.transfer.TestUnderlineUtils;
import com.qlangtech.tis.utils.TestTisMetaProps;
import com.qlangtech.tis.utils.TestUtils;
import junit.framework.Test;
Expand All @@ -41,6 +42,7 @@ public static Test suite() {
suite.addTestSuite(TestUtils.class);
suite.addTestSuite(TestTisMetaProps.class);
suite.addTestSuite(TestIPath.class);
suite.addTestSuite(TestUnderlineUtils.class);

return suite;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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
* <p>
* http:https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.qlangtech.tis.realtime.transfer;

import junit.framework.TestCase;
import org.junit.Assert;

/**
* @author: 百岁([email protected]
* @create: 2024-06-18 10:18
**/
public class TestUnderlineUtils extends TestCase {

public void testAddUnderline() {
StringBuffer copyValUDF = UnderlineUtils.addUnderline("CopyValUDF");
Assert.assertEquals("copy_val_udf", copyValUDF.toString());
}
}

0 comments on commit 18f6142

Please sign in to comment.