adoroszlai commented on code in PR #10053: URL: https://github.com/apache/ozone/pull/10053#discussion_r3038447991
########## hadoop-ozone/iceberg/src/main/java/org/apache/hadoop/ozone/iceberg/RewriteTablePathOzoneAction.java: ########## @@ -0,0 +1,213 @@ +/* + * 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://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 org.apache.hadoop.ozone.iceberg; + +import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import com.google.common.base.Preconditions; +import org.apache.iceberg.HasTableOperations; +import org.apache.iceberg.RewriteTablePathUtil; +import org.apache.iceberg.Table; +import org.apache.iceberg.TableMetadata; +import org.apache.iceberg.TableMetadata.MetadataLogEntry; +import org.apache.iceberg.actions.ImmutableRewriteTablePath; +import org.apache.iceberg.actions.RewriteTablePath; + +public class RewriteTablePathOzoneAction implements RewriteTablePath { + + private static final String RESULT_LOCATION = "file-list"; + + private String sourcePrefix; + private String targetPrefix; + private String startVersionName; + private String endVersionName; + private String stagingDir; + private int parallelism = Runtime.getRuntime().availableProcessors(); Review Comment: Please move initialization to `RewriteTablePathOzoneAction(Table)`, since it is unnecessary for the other constructor. ########## pom.xml: ########## @@ -93,6 +93,7 @@ <hk2.version>2.6.1</hk2.version> <httpclient.version>4.5.14</httpclient.version> <httpcore.version>4.4.16</httpcore.version> + <iceberg.version>1.10.0</iceberg.version> Review Comment: Please use the latest version to save an upgrade via dependabot: ```suggestion <iceberg.version>1.10.1</iceberg.version> ``` https://github.com/apache/iceberg/releases/tag/apache-iceberg-1.10.1 ########## hadoop-ozone/iceberg/pom.xml: ########## @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed 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://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. See accompanying LICENSE file. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.ozone</groupId> + <artifactId>ozone</artifactId> + <version>2.2.0-SNAPSHOT</version> + </parent> + <artifactId>ozone-iceberg</artifactId> + <version>2.2.0-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Apache Ozone Iceberg Integration</name> + <description>Apache Ozone Iceberg Integration</description> + + <properties> + <classpath.skip>false</classpath.skip> + <maven.compiler.release>11</maven.compiler.release> + </properties> + + <dependencies> + + <!-- Common utilities --> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <!-- Iceberg dependencies --> + <dependency> + <groupId>org.apache.iceberg</groupId> + <artifactId>iceberg-api</artifactId> + <version>${iceberg.version}</version> Review Comment: Please import `iceberg-bom` in root `pom.xml`, similar to: https://github.com/apache/ozone/blob/994a8abaafcb294748f594a30d4de75d95503b5c/pom.xml#L258-L264 then we can remove `<version>` here. ########## hadoop-ozone/iceberg/pom.xml: ########## @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed 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://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. See accompanying LICENSE file. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.ozone</groupId> + <artifactId>ozone</artifactId> + <version>2.2.0-SNAPSHOT</version> + </parent> + <artifactId>ozone-iceberg</artifactId> + <version>2.2.0-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Apache Ozone Iceberg Integration</name> + <description>Apache Ozone Iceberg Integration</description> + + <properties> + <classpath.skip>false</classpath.skip> + <maven.compiler.release>11</maven.compiler.release> + </properties> + + <dependencies> + + <!-- Common utilities --> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <!-- Iceberg dependencies --> + <dependency> + <groupId>org.apache.iceberg</groupId> + <artifactId>iceberg-api</artifactId> + <version>${iceberg.version}</version> + </dependency> + <dependency> + <groupId>org.apache.iceberg</groupId> + <artifactId>iceberg-core</artifactId> + <version>${iceberg.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <!-- Iceberg 1.10+ API is Java 11 bytecode, override parent Java 8 default. --> + <release>11</release> Review Comment: `maven.compiler.release` is also defined, do we need this? On the other hand, please disable annotation processing: ``` <proc>none</proc> ``` ########## hadoop-ozone/pom.xml: ########## @@ -106,6 +106,15 @@ </build> <profiles> + <profile> + <id>jdk11-with-iceberg</id> + <activation> + <jdk>[11,)</jdk> + </activation> + <modules> + <module>iceberg</module> + </modules> + </profile> <profile> <id>build-with-ozonefs</id> Review Comment: To include `ozone-iceberg` in the binary distribution, we need to add it as dependency in `ozone-dist`, similar to filesystem jars: https://github.com/apache/ozone/blob/994a8abaafcb294748f594a30d4de75d95503b5c/hadoop-ozone/dist/pom.xml#L258-L277 ########## hadoop-ozone/iceberg/pom.xml: ########## @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed 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://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. See accompanying LICENSE file. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.ozone</groupId> + <artifactId>ozone</artifactId> + <version>2.2.0-SNAPSHOT</version> + </parent> + <artifactId>ozone-iceberg</artifactId> + <version>2.2.0-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Apache Ozone Iceberg Integration</name> + <description>Apache Ozone Iceberg Integration</description> + + <properties> + <classpath.skip>false</classpath.skip> + <maven.compiler.release>11</maven.compiler.release> + </properties> + + <dependencies> + + <!-- Common utilities --> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> Review Comment: Let's not add `guava`, currently only used for `Preconditions`. ########## hadoop-ozone/iceberg/src/main/java/org/apache/hadoop/ozone/iceberg/RewriteTablePathOzoneAction.java: ########## @@ -0,0 +1,213 @@ +/* + * 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://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 org.apache.hadoop.ozone.iceberg; + +import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import com.google.common.base.Preconditions; +import org.apache.iceberg.HasTableOperations; +import org.apache.iceberg.RewriteTablePathUtil; +import org.apache.iceberg.Table; +import org.apache.iceberg.TableMetadata; +import org.apache.iceberg.TableMetadata.MetadataLogEntry; +import org.apache.iceberg.actions.ImmutableRewriteTablePath; +import org.apache.iceberg.actions.RewriteTablePath; + +public class RewriteTablePathOzoneAction implements RewriteTablePath { + + private static final String RESULT_LOCATION = "file-list"; + + private String sourcePrefix; + private String targetPrefix; + private String startVersionName; + private String endVersionName; + private String stagingDir; + private int parallelism = Runtime.getRuntime().availableProcessors(); + + private final Table table; + private ExecutorService executorService; + + public RewriteTablePathOzoneAction(Table table) { + this.table = table; + } + + public RewriteTablePathOzoneAction(Table table, int parallelism) { + this.table = table; + this.parallelism = parallelism; + } + + @Override + public RewriteTablePath rewriteLocationPrefix(String sPrefix, String tPrefix) { + Preconditions.checkArgument( + sPrefix != null && !sPrefix.isEmpty(), "Source prefix('%s') cannot be empty.", sPrefix); Review Comment: Please replace `Preconditions.checkArgument/checkNotNull` with - `Objects.requireNonNull` (see HDDS-14057) for null-check - simple internal helper method for `isEmpty()` check -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
