-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a455925
commit 234be8c
Showing
26 changed files
with
484 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
*/ | ||
package com.qlangtech.tis.realtime.transfer; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
|
||
/** | ||
* @author 百岁([email protected]) | ||
* @date 2020/04/13 | ||
|
@@ -57,4 +59,14 @@ public static StringBuffer addUnderline(String value) { | |
} | ||
return parsedName; | ||
} | ||
|
||
public static String getJavaName(String collection) { | ||
// Matcher matcher = PATTERN_COLLECTION_NAME.matcher(collection); | ||
// if (!matcher.matches()) { | ||
// throw new IllegalStateException("collection:" + collection + " is not match the Pattern:" + PATTERN_COLLECTION_NAME); | ||
// } | ||
// return matcher.replaceFirst("S4$2"); | ||
// return StringUtils.capitalize(collection); | ||
return StringUtils.capitalize(removeUnderline(collection).toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,29 @@ | |
*/ | ||
package com.qlangtech.tis.sql.parser.tuple.creator; | ||
|
||
import com.qlangtech.tis.realtime.transfer.UnderlineUtils; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author 百岁([email protected]) | ||
* @date 2021-04-06 09:49 | ||
*/ | ||
public interface IStreamIncrGenerateStrategy { | ||
|
||
String TEMPLATE_FLINK_TABLE_HANDLE_SCALA = "flink_table_handle_scala.vm"; | ||
|
||
default boolean isExcludeFacadeDAOSupport() { | ||
return true; | ||
} | ||
|
||
default String getFlinkStreamGenerateTemplateFileName() { | ||
return "flink_source_handle_scala.vm"; | ||
} | ||
|
||
boolean isExcludeFacadeDAOSupport(); | ||
default IStreamTemplateData decorateMergeData(IStreamTemplateData mergeData) { | ||
return mergeData; | ||
} | ||
|
||
// Map<IEntityNameGetter, List<IValChain>> getTabTriggerLinker(); | ||
// | ||
|
@@ -38,4 +53,46 @@ public interface IStreamIncrGenerateStrategy { | |
// IERRules getERRule(); | ||
|
||
|
||
/** | ||
* | ||
**/ | ||
interface IStreamTemplateData { | ||
|
||
/** | ||
* TIS App 应用名称 | ||
* | ||
* @return | ||
*/ | ||
public String getCollection(); | ||
|
||
public default String getJavaName() { | ||
return UnderlineUtils.getJavaName(this.getCollection()); | ||
} | ||
|
||
|
||
public List<EntityName> getDumpTables(); | ||
} | ||
|
||
public static abstract class AdapterStreamTemplateData implements IStreamTemplateData { | ||
private final IStreamTemplateData data; | ||
|
||
public AdapterStreamTemplateData(IStreamTemplateData data) { | ||
this.data = data; | ||
} | ||
|
||
@Override | ||
public String getCollection() { | ||
return data.getCollection(); | ||
} | ||
|
||
@Override | ||
public String getJavaName() { | ||
return data.getJavaName(); | ||
} | ||
|
||
@Override | ||
public List<EntityName> getDumpTables() { | ||
return data.getDumpTables(); | ||
} | ||
} | ||
} |
150 changes: 150 additions & 0 deletions
150
tis-builder-api/src/main/java/com/qlangtech/tis/sql/parser/visitor/BlockScriptBuffer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/** | ||
* 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.sql.parser.visitor; | ||
|
||
import com.qlangtech.tis.sql.parser.tuple.creator.EntityName; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* @author: 百岁([email protected]) | ||
* @create: 2022-02-19 22:43 | ||
**/ | ||
public class BlockScriptBuffer implements IBlockToString { | ||
private static final Pattern PATTERN_LAST_RETURN = Pattern.compile("\n\\s*$"); | ||
private final List<Object> format = new ArrayList<>(); | ||
private int indent; | ||
private boolean lastReturnChar = false; | ||
|
||
private void addIndent() { | ||
this.indent += 4; | ||
} | ||
|
||
private void decreaseIndent() { | ||
this.indent -= 4; | ||
} | ||
|
||
public BlockScriptBuffer methodBody(Object method, IFuncFormatCall call) { | ||
return methodBody(true, method, call); | ||
} | ||
|
||
|
||
public BlockScriptBuffer methodBody(boolean returnLine, Object method, IFuncFormatCall call) { | ||
return blockBody(returnLine, new String[]{"{", "}"}, method, call); | ||
} | ||
|
||
public BlockScriptBuffer block(Object method, IFuncFormatCall call) { | ||
return block(false, method, call); | ||
} | ||
|
||
public BlockScriptBuffer block(boolean returnLine, Object method, IFuncFormatCall call) { | ||
return blockBody(returnLine, new String[]{"(", ")"}, method, call); | ||
} | ||
|
||
public void buildRowMapTraverseLiteria(EntityName entity, IFuncFormatCall call) { | ||
this.methodBody("for ( ( r:" + EntityName.ROW_MAP_CLASS_NAME + ") <- " + entity.entities() + ".asScala)", call); | ||
} | ||
|
||
private BlockScriptBuffer blockBody(boolean returnLine, String[] brackets, Object method, IFuncFormatCall call) { | ||
if (returnLine) { | ||
this.returnLine(); | ||
this.appendIndent(); | ||
} | ||
this.append(method).append(brackets[0]).returnLine(); | ||
this.addIndent(); | ||
try { | ||
call.execute(this); | ||
this.returnLine(); | ||
} finally { | ||
this.decreaseIndent(); | ||
} | ||
this.appendIndent().append(brackets[1]); | ||
if (returnLine) { | ||
// this.returnLine(); | ||
this.returnLine(); | ||
} | ||
return this; | ||
} | ||
|
||
public BlockScriptBuffer append(Object val) { | ||
if (val instanceof String) { | ||
Matcher matcher = PATTERN_LAST_RETURN.matcher((String) val); | ||
this.lastReturnChar = matcher.find(); | ||
} else { | ||
this.lastReturnChar = false; | ||
} | ||
format.add(val); | ||
return this; | ||
} | ||
|
||
public BlockScriptBuffer appendLine(Object val) { | ||
return startLine(val).appendIndent(); | ||
} | ||
|
||
public BlockScriptBuffer startLine(Object val) { | ||
if (!lastReturnChar) { | ||
this.returnLine(); | ||
} | ||
appendIndent(); | ||
return this.append(val); | ||
} | ||
|
||
private BlockScriptBuffer appendIndent() { | ||
if (indent > 0) { | ||
for (int i = 0; i < indent; i++) { | ||
format.add(" "); | ||
} | ||
} | ||
return this; | ||
} | ||
|
||
public BlockScriptBuffer append(long val) { | ||
// appendIndent(); | ||
format.add(val); | ||
return this; | ||
} | ||
|
||
public BlockScriptBuffer returnLine() { | ||
this.append("\n"); | ||
return this; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuffer buffer = getContent(); | ||
return buffer.toString(); | ||
} | ||
|
||
public StringBuffer getContent() { | ||
StringBuffer buffer = new StringBuffer(); | ||
for (Object o : format) { | ||
buffer.append(o); | ||
} | ||
return buffer; | ||
} | ||
|
||
public interface IFuncFormatCall { | ||
|
||
public void execute(BlockScriptBuffer f); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
tis-builder-api/src/main/java/com/qlangtech/tis/sql/parser/visitor/IBlockToString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
package com.qlangtech.tis.sql.parser.visitor; | ||
|
||
/** | ||
* @author: 百岁([email protected]) | ||
* @create: 2022-02-19 23:27 | ||
**/ | ||
public interface IBlockToString { | ||
|
||
public String toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
package com.qlangtech.tis.datax; | ||
|
||
import com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta; | ||
import com.qlangtech.tis.sql.parser.tuple.creator.IStreamIncrGenerateStrategy; | ||
|
||
import java.util.List; | ||
|
||
|
@@ -28,7 +29,8 @@ | |
* @author: 百岁([email protected]) | ||
* @create: 2022-02-19 13:02 | ||
**/ | ||
public interface IStreamTableCreator { | ||
public interface IStreamTableCreator extends IStreamIncrGenerateStrategy { | ||
|
||
/** | ||
* 比表写入相关的元数据信息 | ||
* | ||
|
@@ -45,11 +47,11 @@ interface IStreamTableMeta { | |
*/ | ||
List<HdfsColMeta> getColsMeta(); | ||
|
||
/** | ||
* 创建Flink SQL 的DDL | ||
* | ||
* @return | ||
*/ | ||
StringBuffer createFlinkTableDDL(); | ||
// /** | ||
// * 创建Flink SQL 的DDL | ||
// * | ||
// * @return | ||
// */ | ||
// StringBuffer createFlinkTableDDL(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.