Skip to content

Commit

Permalink
Fix check
Browse files Browse the repository at this point in the history
  • Loading branch information
liurenjie1024 committed Dec 29, 2023
1 parent b1a1af9 commit 4556370
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 50 deletions.
10 changes: 10 additions & 0 deletions java/connector-node/risingwave-sink-iceberg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
<artifactId>iceberg-core</artifactId>
<version>${iceberg.version}</version>
</dependency>
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-api</artifactId>
<version>${iceberg.version}</version>
</dependency>
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-bundled-guava</artifactId>
<version>${iceberg.version}</version>
</dependency>
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-parquet</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@

package com.risingwave.connector.catalog;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.Preconditions;
import static com.google.common.base.Preconditions.checkArgument;

import java.util.HashMap;
import java.util.Objects;
import org.apache.iceberg.CatalogUtil;
import org.apache.iceberg.Table;
import org.apache.iceberg.catalog.Catalog;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.rest.CatalogHandlers;
import org.apache.iceberg.rest.requests.UpdateTableRequest;
import org.apache.iceberg.rest.responses.LoadTableResponse;

import java.util.HashMap;
import java.util.Objects;

/**
* This class provide jni interface to iceberg catalog.
*/
/** This class provide jni interface to iceberg catalog. */
public class JniCatalogWrapper {
private final Catalog catalog;

Expand Down Expand Up @@ -58,21 +54,24 @@ public String loadTable(String tableIdentifier) throws Exception {
* @throws Exception
*/
public String updateTable(String updateTableRequest) throws Exception {
UpdateTableRequest req = RESTObjectMapper.mapper().readValue(updateTableRequest, UpdateTableRequest.class);
UpdateTableRequest req =
RESTObjectMapper.mapper().readValue(updateTableRequest, UpdateTableRequest.class);
LoadTableResponse resp = CatalogHandlers.updateTable(catalog, req.identifier(), req);
return RESTObjectMapper.mapper().writer().writeValueAsString(resp);
}

/**
* Create JniCatalogWrapper instance.
*
* @param name Catalog name.
* @param name Catalog name.
* @param klassName Delegated catalog class name.
* @param props Catalog properties.
* @param props Catalog properties.
* @return JniCatalogWrapper instance.
*/
public static JniCatalogWrapper create(String name, String klassName, String[] props) {
Preconditions.checkArgument(props.length % 2 == 0, "props should be key-value pairs, but length is: " + props.length);
checkArgument(
props.length % 2 == 0,
"props should be key-value pairs, but length is: " + props.length);
try {
HashMap<String, String> config = new HashMap<>(props.length / 2);
for (int i = 0; i < props.length; i += 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,26 @@
import org.apache.iceberg.rest.RESTSerializers;

class RESTObjectMapper {
private static final JsonFactory FACTORY = new JsonFactory();
private static final ObjectMapper MAPPER = new ObjectMapper(FACTORY);
private static volatile boolean isInitialized = false;
private static final JsonFactory FACTORY = new JsonFactory();
private static final ObjectMapper MAPPER = new ObjectMapper(FACTORY);
private static volatile boolean isInitialized = false;

private RESTObjectMapper() {}
private RESTObjectMapper() {}

static ObjectMapper mapper() {
if (!isInitialized) {
synchronized (RESTObjectMapper.class) {
static ObjectMapper mapper() {
if (!isInitialized) {
MAPPER.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MAPPER.setPropertyNamingStrategy(new PropertyNamingStrategy.KebabCaseStrategy());
RESTSerializers.registerAll(MAPPER);
isInitialized = true;
synchronized (RESTObjectMapper.class) {
if (!isInitialized) {
MAPPER.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MAPPER.setPropertyNamingStrategy(
new PropertyNamingStrategy.KebabCaseStrategy());
RESTSerializers.registerAll(MAPPER);
isInitialized = true;
}
}
}
}
}

return MAPPER;
}
return MAPPER;
}
}
21 changes: 0 additions & 21 deletions java/tools/maven/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,6 @@ This file is based on the checkstyle file of Apache Beam.
<property name="message"
value="Use Guava Checks instead of Commons Validate. Please refer to the coding guidelines."/>
</module>
<!-- forbid the use of google.common.base.Preconditions -->
<module name="Regexp">
<property name="format" value="import com\.google\.common\.base\.Preconditions"/>
<property name="illegalPattern" value="true"/>
<property name="message"
value="Use Flink's Preconditions instead of Guava's Preconditions"/>
</module>
<!-- forbid the use of com.google.common.annotations.VisibleForTesting -->
<module name="Regexp">
<property name="format"
value="import com\.google\.common\.annotations\.VisibleForTesting"/>
<property name="illegalPattern" value="true"/>
<property name="message"
value="Use Flink's VisibleForTesting instead of Guava's VisibleForTesting"/>
</module>
<module name="Regexp">
<property name="format" value="import static com\.google\.common\.base\.Preconditions"/>
<property name="illegalPattern" value="true"/>
<property name="message"
value="Use Flink's Preconditions instead of Guava's Preconditions"/>
</module>
<!-- forbid the use of org.apache.commons.lang.SerializationUtils -->
<module name="Regexp">
<property name="format" value="org\.apache\.commons\.lang\.SerializationUtils"/>
Expand Down

0 comments on commit 4556370

Please sign in to comment.