Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
bjyflihongyu committed Oct 21, 2022
1 parent 46bdf4a commit 130e0f4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import java.io.Serializable;
import java.util.List;
import java.util.Set;

@Data
public class TDengineSourceConfig implements Serializable {
Expand All @@ -54,20 +53,6 @@ public class TDengineSourceConfig implements Serializable {
private List<String> fields;
private List<String> tags;

public static class ConfigNames {
public static String URL = "url";
public static String USERNAME = "username";
public static String PASSWORD = "password";
public static String DATABASE = "database";
public static String STABLE = "stable";
public static String LOWER_BOUND = "lower_bound";
public static String UPPER_BOUND = "upper_bound";
public static String PARTITIONS_NUM = "partitions_num";
public static String FIELDS = "fields";
public static String TAGS = "tags";
}


public static TDengineSourceConfig buildSourceConfig(Config pluginConfig) {
TDengineSourceConfig tdengineSourceConfig = new TDengineSourceConfig();
tdengineSourceConfig.setUrl(pluginConfig.hasPath(URL) ? pluginConfig.getString(URL) : null);
Expand All @@ -82,4 +67,18 @@ public static TDengineSourceConfig buildSourceConfig(Config pluginConfig) {
tdengineSourceConfig.setTags(pluginConfig.hasPath(TAGS) ? Lists.newArrayList(pluginConfig.getObject(TAGS).keySet().toArray(new String[0])) : null);
return tdengineSourceConfig;
}

public static class ConfigNames {

public static String URL = "url";
public static String USERNAME = "username";
public static String PASSWORD = "password";
public static String DATABASE = "database";
public static String STABLE = "stable";
public static String LOWER_BOUND = "lower_bound";
public static String UPPER_BOUND = "upper_bound";
public static String PARTITIONS_NUM = "partitions_num";
public static String FIELDS = "fields";
public static String TAGS = "tags";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@

public class TDengineSinkWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {

private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
private final SeaTunnelRowType seaTunnelRowType;
private final Connection conn;
private final TDengineSourceConfig config;
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
private int tagsNum;

@SneakyThrows
Expand All @@ -68,7 +68,7 @@ public TDengineSinkWriter(Config pluginConfig, SeaTunnelRowType seaTunnelRowType
@SuppressWarnings("checkstyle:RegexpSingleline")
public void write(SeaTunnelRow element) {
final ArrayList<Object> tags = Lists.newArrayList();
for (int i = element.getArity()-tagsNum; i< element.getArity(); i++){
for (int i = element.getArity() - tagsNum; i < element.getArity(); i++) {
tags.add(element.getField(i));
}
final String tagValues = StringUtils.join(convertDataType(tags.toArray()), ",");
Expand All @@ -92,7 +92,7 @@ public void write(SeaTunnelRow element) {

@Override
public void close() throws IOException {
if (Objects.nonNull(conn)){
if (Objects.nonNull(conn)) {
try {
conn.close();
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ public void close() throws IOException {
}
}


@Override
public void handleSplitRequest(int subtaskId) {
//nothing to do
Expand Down

0 comments on commit 130e0f4

Please sign in to comment.