You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by yi...@apache.org on 2025/12/06 02:16:46 UTC
(hudi) branch master updated: refactor: introduce lombok dependency (#17500)
This is an automated email from the ASF dual-hosted git repository.
yihua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 99870dfa0d09 refactor: introduce lombok dependency (#17500)
99870dfa0d09 is described below
commit 99870dfa0d09ee6cb76311c572e2653eccfc6e80
Author: vinoth chandar <vi...@users.noreply.github.com>
AuthorDate: Fri Dec 5 18:16:39 2025 -0800
refactor: introduce lombok dependency (#17500)
---
hudi-common/pom.xml | 6 ++
.../hudi/common/model/HoodieIndexDefinition.java | 101 ++++-----------------
pom.xml | 9 ++
3 files changed, 35 insertions(+), 81 deletions(-)
diff --git a/hudi-common/pom.xml b/hudi-common/pom.xml
index 15897ac239f5..3a881ffd0c55 100644
--- a/hudi-common/pom.xml
+++ b/hudi-common/pom.xml
@@ -115,6 +115,12 @@
<artifactId>jol-core</artifactId>
</dependency>
+ <!-- Lombok -->
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+
<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
diff --git a/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieIndexDefinition.java b/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieIndexDefinition.java
index 948967b8b85e..112aa9b97545 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieIndexDefinition.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieIndexDefinition.java
@@ -23,16 +23,18 @@ import org.apache.hudi.common.util.ValidationUtils;
import org.apache.hudi.metadata.HoodieIndexVersion;
import org.apache.hudi.metadata.MetadataPartitionType;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
-import java.util.StringJoiner;
import static org.apache.hudi.common.util.StringUtils.EMPTY_STRING;
import static org.apache.hudi.common.util.StringUtils.nonEmpty;
@@ -49,6 +51,10 @@ import static org.apache.hudi.index.expression.HoodieExpressionIndex.TRIM_STRING
* Class representing the metadata for a functional or secondary index in Hudi.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
+@Getter
+@NoArgsConstructor
+@ToString
+@EqualsAndHashCode
public class HoodieIndexDefinition implements Serializable {
// Index name is composed of 2 parts - MDT partition path prefix + user-specified index name.
@@ -68,6 +74,8 @@ public class HoodieIndexDefinition implements Serializable {
* <p>The field should be ignored in Ser/De.
*/
@JsonIgnore
+ @ToString.Exclude
+ @EqualsAndHashCode.Exclude
private String sourceFieldsKey;
// Any other configuration or properties specific to the index
@@ -76,10 +84,6 @@ public class HoodieIndexDefinition implements Serializable {
// Version of the index
private HoodieIndexVersion version;
- // Required for jackson to properly deserialize from json.
- public HoodieIndexDefinition() {
- }
-
private HoodieIndexDefinition(
String indexName,
String indexType,
@@ -95,14 +99,6 @@ public class HoodieIndexDefinition implements Serializable {
this.version = version;
}
- public String getIndexFunction() {
- return indexFunction;
- }
-
- public List<String> getSourceFields() {
- return sourceFields;
- }
-
public String getSourceFieldsKey() {
if (this.sourceFieldsKey == null) {
this.sourceFieldsKey = String.join(".", this.sourceFields);
@@ -110,17 +106,6 @@ public class HoodieIndexDefinition implements Serializable {
return this.sourceFieldsKey;
}
- public Map<String, String> getIndexOptions() {
- return indexOptions;
- }
-
- /**
- * Return the version of this index definition
- */
- public HoodieIndexVersion getVersion() {
- return version;
- }
-
public String getExpressionIndexFormatOption(String defaultValue) {
return indexOptions.getOrDefault(FORMAT_OPTION, defaultValue);
}
@@ -157,14 +142,6 @@ public class HoodieIndexDefinition implements Serializable {
return indexOptions.get(TRIM_STRING_OPTION);
}
- public String getIndexName() {
- return indexName;
- }
-
- public String getIndexType() {
- return indexType;
- }
-
public static Builder newBuilder() {
return new Builder();
}
@@ -173,34 +150,31 @@ public class HoodieIndexDefinition implements Serializable {
* Create a new Builder pre-populated with values from this instance.
*/
public Builder toBuilder() {
- Builder builder = new Builder();
- builder.withIndexName(this.indexName)
+ return new Builder()
+ .withIndexName(this.indexName)
.withIndexType(this.indexType)
.withIndexFunction(this.indexFunction)
.withSourceFields(new ArrayList<>(this.sourceFields))
.withIndexOptions(new HashMap<>(this.indexOptions))
.withVersion(this.version);
- return builder;
}
+ /**
+ * Builder for {@link HoodieIndexDefinition}.
+ */
+ @NoArgsConstructor
public static class Builder {
private String indexName;
private String indexType;
private String indexFunction;
- private List<String> sourceFields;
- private Map<String, String> indexOptions;
+ private List<String> sourceFields = new ArrayList<>();
+ private Map<String, String> indexOptions = new HashMap<>();
private HoodieIndexVersion version;
- public Builder() {
- this.sourceFields = new ArrayList<>();
- this.indexOptions = new HashMap<>();
- this.version = null;
- }
-
public Builder withIndexName(String indexName) {
ValidationUtils.checkArgument(MetadataPartitionType.fromPartitionPath(indexName) != null,
- "Invalid index name");
+ "Invalid index name");
this.indexName = indexName;
return this;
}
@@ -226,7 +200,6 @@ public class HoodieIndexDefinition implements Serializable {
}
public Builder withVersion(HoodieIndexVersion version) {
- // Make sure the version enum matching the metadata partition is used.
this.version = version;
return this;
}
@@ -244,38 +217,4 @@ public class HoodieIndexDefinition implements Serializable {
);
}
}
-
- @Override
- public String toString() {
- return new StringJoiner(", ", HoodieIndexDefinition.class.getSimpleName() + "[", "]")
- .add("indexName='" + indexName + "'")
- .add("indexType='" + indexType + "'")
- .add("indexFunction='" + indexFunction + "'")
- .add("sourceFields=" + sourceFields)
- .add("indexOptions=" + indexOptions)
- .add("version=" + version)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof HoodieIndexDefinition)) {
- return false;
- }
- HoodieIndexDefinition that = (HoodieIndexDefinition) o;
- return Objects.equals(indexName, that.indexName)
- && Objects.equals(indexType, that.indexType)
- && Objects.equals(indexFunction, that.indexFunction)
- && Objects.equals(sourceFields, that.sourceFields)
- && Objects.equals(indexOptions, that.indexOptions)
- && Objects.equals(version, that.version);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(indexName, indexType, indexFunction, sourceFields, indexOptions, version);
- }
}
diff --git a/pom.xml b/pom.xml
index dc28d5660f03..74dbc0e55a29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -243,6 +243,7 @@
<copy.files>false</copy.files>
<copy.files.target.dir>${maven.multiModuleProjectDirectory}</copy.files.target.dir>
<jacoco.agent.dest.filename>jacoco.exec</jacoco.agent.dest.filename>
+ <lombok.version>1.18.36</lombok.version>
</properties>
<scm>
@@ -1824,6 +1825,14 @@
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
+
+ <!-- Lombok -->
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</dependencyManagement>
<repositories>