Skip to content

Commit

Permalink
[Improve][Connector-V2][Clickhouse] Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
TyrantLucifer committed Jan 10, 2023
1 parent f739bd9 commit ce2988b
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@

public class StringInjectFunction implements ClickhouseFieldInjectFunction {

private final ObjectMapper mapper = new ObjectMapper();
private static final ObjectMapper MAPPER = new ObjectMapper();
private String fieldType;

@Override
public void injectFields(PreparedStatement statement, int index, Object value) throws SQLException {
try {
if ("Point".equals(fieldType)) {
statement.setObject(index, mapper.readValue(replace(value.toString()), double[].class));
statement.setObject(index, MAPPER.readValue(replace(value.toString()), double[].class));
} else if ("Ring".equals(fieldType)) {
statement.setObject(index, mapper.readValue(replace(value.toString()), double[][].class));
statement.setObject(index, MAPPER.readValue(replace(value.toString()), double[][].class));
} else if ("Polygon".equals(fieldType)) {
statement.setObject(index, mapper.readValue(replace(value.toString()), double[][][].class));
statement.setObject(index, MAPPER.readValue(replace(value.toString()), double[][][].class));
} else if ("MultiPolygon".equals(fieldType)) {
statement.setObject(index, mapper.readValue(replace(value.toString()), double[][][][].class));
statement.setObject(index, MAPPER.readValue(replace(value.toString()), double[][][][].class));
} else {
statement.setString(index, value.toString());
}
Expand Down

0 comments on commit ce2988b

Please sign in to comment.