[
https://issues.apache.org/jira/browse/BEAM-5092?focusedWorklogId=131812&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-131812
]
ASF GitHub Bot logged work on BEAM-5092:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Aug/18 12:15
Start Date: 07/Aug/18 12:15
Worklog Time Spent: 10m
Work Description: reuvenlax closed pull request #6160: [BEAM-5092] Make
sure that SchemaCoder overrides consistentWithEquals.
URL: https://github.com/apache/beam/pull/6160
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoder.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoder.java
index 28fc0275c53..97252ce7889 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoder.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/RowCoder.java
@@ -104,6 +104,11 @@ public Schema getSchema() {
public void verifyDeterministic()
throws org.apache.beam.sdk.coders.Coder.NonDeterministicException {}
+ @Override
+ public boolean consistentWithEquals() {
+ return true;
+ }
+
/** Returns the coder used for a given primitive type. */
public static <T> Coder<T> coderForPrimitiveType(TypeName typeName) {
return (Coder<T>) CODER_MAP.get(typeName);
diff --git
a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaBeanSchema.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaBeanSchema.java
index 135294ee2a3..0ea71a4695f 100644
---
a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaBeanSchema.java
+++
b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaBeanSchema.java
@@ -30,7 +30,9 @@
*
* <p>This provider finds (recursively) all public getters and setters in a
Java object, and creates
* schemas and rows that bind to those fields. The field order in the schema
is not guaranteed to
- * match the method order in the class.
+ * match the method order in the class. The Java object is expected to have
implemented a correct
+ * .equals() method. TODO: Validate equals() method is provided, and if not
generate a "slow" equals
+ * method based on the schema.
*/
@Experimental(Kind.SCHEMAS)
public class JavaBeanSchema extends GetterBasedSchemaProvider {
diff --git
a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaFieldSchema.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaFieldSchema.java
index 5dbc979cb21..98bf86daecb 100644
---
a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaFieldSchema.java
+++
b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaFieldSchema.java
@@ -30,7 +30,9 @@
*
* <p>This provider finds all public fields (recursively) in a Java object,
and creates schemas and
* rows that bind to those fields. The field order in the schema is not
guaranteed to match the
- * field order in the class.
+ * field order in the class. The Java object is expected to have implemented a
correct .equals()
+ * method. TODO: Validate equals() method is provided, and if not generate a
"slow" equals method
+ * based on the schema.
*/
@Experimental(Kind.SCHEMAS)
public class JavaFieldSchema extends GetterBasedSchemaProvider {
diff --git
a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
index 05f381d067f..164b1869d73 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
@@ -175,7 +175,10 @@ public static Schema of(Field... fields) {
/** Returns true if two Schemas have the same fields in the same order. */
@Override
public boolean equals(Object o) {
- if (!(o instanceof Schema)) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
}
Schema other = (Schema) o;
diff --git
a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaCoder.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaCoder.java
index c5b29cfc31e..26b1fa4f8cc 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaCoder.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaCoder.java
@@ -93,4 +93,9 @@ public T decode(InputStream inStream) throws IOException {
public void verifyDeterministic() throws NonDeterministicException {
rowCoder.verifyDeterministic();
}
+
+ @Override
+ public boolean consistentWithEquals() {
+ return rowCoder.consistentWithEquals();
+ }
}
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java
index e94dc4b8bb4..171f665a9ac 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java
@@ -310,7 +310,10 @@ public Schema getSchema() {
@Override
public boolean equals(Object o) {
- if (!(o instanceof Row)) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
}
Row other = (Row) o;
diff --git
a/sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestJavaBeans.java
b/sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestJavaBeans.java
index febe67496d4..ca4e945a4cb 100644
---
a/sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestJavaBeans.java
+++
b/sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestJavaBeans.java
@@ -20,8 +20,10 @@
import java.math.BigDecimal;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import javax.annotation.Nullable;
import org.apache.beam.sdk.schemas.DefaultSchema;
import org.apache.beam.sdk.schemas.JavaBeanSchema;
@@ -56,6 +58,23 @@ public int getAnInt() {
public void setAnInt(int anInt) {
this.anInt = anInt;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NullableBean that = (NullableBean) o;
+ return anInt == that.anInt && Objects.equals(str, that.str);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(str, anInt);
+ }
}
/** A Bean containing nullable getter but a non-nullable setter. */
@@ -73,6 +92,23 @@ public String getStr() {
public void setStr(String str) {
this.str = str;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ MismatchingNullableBean that = (MismatchingNullableBean) o;
+ return Objects.equals(str, that.str);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(str);
+ }
}
/** A simple Bean containing basic types. * */
@@ -214,6 +250,48 @@ public StringBuilder getStringBuilder() {
public void setStringBuilder(StringBuilder stringBuilder) {
this.stringBuilder = stringBuilder;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ SimpleBean that = (SimpleBean) o;
+ return aByte == that.aByte
+ && aShort == that.aShort
+ && anInt == that.anInt
+ && aLong == that.aLong
+ && aBoolean == that.aBoolean
+ && Objects.equals(str, that.str)
+ && Objects.equals(dateTime, that.dateTime)
+ && Objects.equals(instant, that.instant)
+ && Arrays.equals(bytes, that.bytes)
+ && Objects.equals(byteBuffer, that.byteBuffer)
+ && Objects.equals(bigDecimal, that.bigDecimal)
+ && Objects.equals(stringBuilder, that.stringBuilder);
+ }
+
+ @Override
+ public int hashCode() {
+ int result =
+ Objects.hash(
+ str,
+ aByte,
+ aShort,
+ anInt,
+ aLong,
+ aBoolean,
+ dateTime,
+ instant,
+ byteBuffer,
+ bigDecimal,
+ stringBuilder);
+ result = 31 * result + Arrays.hashCode(bytes);
+ return result;
+ }
}
/** The schema for {@link SimpleBean}. * */
@@ -251,6 +329,23 @@ public SimpleBean getNested() {
public void setNested(SimpleBean nested) {
this.nested = nested;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedBean that = (NestedBean) o;
+ return Objects.equals(nested, that.nested);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nested);
+ }
}
/** The schema for {@link NestedBean}. * */
@@ -296,6 +391,28 @@ public void setIntegers(int[] integers) {
public void setLongs(Long[] longs) {
this.longs = longs;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ PrimitiveArrayBean that = (PrimitiveArrayBean) o;
+ return Objects.equals(strings, that.strings)
+ && Arrays.equals(integers, that.integers)
+ && Arrays.equals(longs, that.longs);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = Objects.hash(strings);
+ result = 31 * result + Arrays.hashCode(integers);
+ result = 31 * result + Arrays.hashCode(longs);
+ return result;
+ }
}
/** The schema for {@link PrimitiveArrayBean}. * */
@@ -324,6 +441,23 @@ public NestedArrayBean() {}
public void setBeans(SimpleBean[] beans) {
this.beans = beans;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedArrayBean that = (NestedArrayBean) o;
+ return Arrays.equals(beans, that.beans);
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(beans);
+ }
}
/** The schema for {@link NestedArrayBean}. * */
@@ -348,6 +482,23 @@ public NestedArraysBean() {}
public void setLists(List<List<String>> lists) {
this.lists = lists;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedArraysBean that = (NestedArraysBean) o;
+ return Objects.equals(lists, that.lists);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(lists);
+ }
}
/** The schema for {@link NestedArrayBean}. * */
@@ -372,6 +523,23 @@ public NestedCollectionBean() {}
public void setSimples(List<SimpleBean> simples) {
this.simples = simples;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedCollectionBean that = (NestedCollectionBean) o;
+ return Objects.equals(simples, that.simples);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(simples);
+ }
}
/** The schema for {@link NestedCollectionBean}. * */
@@ -396,6 +564,23 @@ public PrimitiveMapBean() {}
public void setMap(Map<String, Integer> map) {
this.map = map;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ PrimitiveMapBean that = (PrimitiveMapBean) o;
+ return Objects.equals(map, that.map);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(map);
+ }
}
/** The schema for {@link PrimitiveMapBean}. * */
@@ -420,6 +605,23 @@ public NestedMapBean() {}
public void setMap(Map<String, SimpleBean> map) {
this.map = map;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedMapBean that = (NestedMapBean) o;
+ return Objects.equals(map, that.map);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(map);
+ }
}
/** The schema for {@link NestedMapBean}. * */
@@ -487,6 +689,27 @@ public Boolean getaBoolean() {
public void setaBoolean(Boolean aBoolean) {
this.aBoolean = aBoolean;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ BeanWithBoxedFields that = (BeanWithBoxedFields) o;
+ return Objects.equals(aByte, that.aByte)
+ && Objects.equals(aShort, that.aShort)
+ && Objects.equals(anInt, that.anInt)
+ && Objects.equals(aLong, that.aLong)
+ && Objects.equals(aBoolean, that.aBoolean);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(aByte, aShort, anInt, aLong, aBoolean);
+ }
}
/** The schema for {@link BeanWithBoxedFields}. * */
@@ -527,6 +750,25 @@ public ByteBuffer getBytes2() {
public void setBytes2(ByteBuffer bytes2) {
this.bytes2 = bytes2;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ BeanWithByteArray that = (BeanWithByteArray) o;
+ return Arrays.equals(bytes1, that.bytes1) && Objects.equals(bytes2,
that.bytes2);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = Objects.hash(bytes2);
+ result = 31 * result + Arrays.hashCode(bytes1);
+ return result;
+ }
}
/** The schema for {@link BeanWithByteArray}. * */
diff --git
a/sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestPOJOs.java
b/sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestPOJOs.java
index 9d03f3fe613..6c705d005c7 100644
---
a/sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestPOJOs.java
+++
b/sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestPOJOs.java
@@ -20,8 +20,10 @@
import java.math.BigDecimal;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import javax.annotation.Nullable;
import org.apache.beam.sdk.schemas.DefaultSchema;
import org.apache.beam.sdk.schemas.JavaFieldSchema;
@@ -44,6 +46,23 @@ public POJOWithNullables(@Nullable String str, int anInt) {
}
public POJOWithNullables() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ POJOWithNullables that = (POJOWithNullables) o;
+ return anInt == that.anInt && Objects.equals(str, that.str);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(str, anInt);
+ }
}
/** The schema for {@link POJOWithNullables}. * */
@@ -60,6 +79,23 @@ public POJOWithNestedNullable(@Nullable POJOWithNullables
nested) {
}
public POJOWithNestedNullable() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ POJOWithNestedNullable that = (POJOWithNestedNullable) o;
+ return Objects.equals(nested, that.nested);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nested);
+ }
}
/** The schema for {@link POJOWithNestedNullable}. * */
@@ -110,6 +146,48 @@ public SimplePOJO(
this.bigDecimal = bigDecimal;
this.stringBuilder = stringBuilder;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ SimplePOJO that = (SimplePOJO) o;
+ return aByte == that.aByte
+ && aShort == that.aShort
+ && anInt == that.anInt
+ && aLong == that.aLong
+ && aBoolean == that.aBoolean
+ && Objects.equals(str, that.str)
+ && Objects.equals(dateTime, that.dateTime)
+ && Objects.equals(instant, that.instant)
+ && Arrays.equals(bytes, that.bytes)
+ && Objects.equals(byteBuffer, that.byteBuffer)
+ && Objects.equals(bigDecimal, that.bigDecimal)
+ && Objects.equals(stringBuilder, that.stringBuilder);
+ }
+
+ @Override
+ public int hashCode() {
+ int result =
+ Objects.hash(
+ str,
+ aByte,
+ aShort,
+ anInt,
+ aLong,
+ aBoolean,
+ dateTime,
+ instant,
+ byteBuffer,
+ bigDecimal,
+ stringBuilder);
+ result = 31 * result + Arrays.hashCode(bytes);
+ return result;
+ }
}
/** The schema for {@link SimplePOJO}. * */
@@ -139,6 +217,23 @@ public NestedPOJO(SimplePOJO nested) {
}
public NestedPOJO() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedPOJO that = (NestedPOJO) o;
+ return Objects.equals(nested, that.nested);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nested);
+ }
}
/** The schema for {@link NestedPOJO}. * */
@@ -160,6 +255,28 @@ public PrimitiveArrayPOJO(List<String> strings, int[]
integers, Long[] longs) {
this.integers = integers;
this.longs = longs;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ PrimitiveArrayPOJO that = (PrimitiveArrayPOJO) o;
+ return Objects.equals(strings, that.strings)
+ && Arrays.equals(integers, that.integers)
+ && Arrays.equals(longs, that.longs);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = Objects.hash(strings);
+ result = 31 * result + Arrays.hashCode(integers);
+ result = 31 * result + Arrays.hashCode(longs);
+ return result;
+ }
}
/** The schema for {@link PrimitiveArrayPOJO}. * */
@@ -180,6 +297,23 @@ public NestedArrayPOJO(SimplePOJO... pojos) {
}
public NestedArrayPOJO() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedArrayPOJO that = (NestedArrayPOJO) o;
+ return Arrays.equals(pojos, that.pojos);
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(pojos);
+ }
}
/** The schema for {@link NestedArrayPOJO}. * */
@@ -196,6 +330,23 @@ public NestedArraysPOJO(List<List<String>> lists) {
}
public NestedArraysPOJO() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedArraysPOJO that = (NestedArraysPOJO) o;
+ return Objects.equals(lists, that.lists);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(lists);
+ }
}
/** The schema for {@link NestedArraysPOJO}. * */
@@ -212,6 +363,24 @@ public NestedCollectionPOJO(List<SimplePOJO> simples) {
}
public NestedCollectionPOJO() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedCollectionPOJO that = (NestedCollectionPOJO) o;
+ return Objects.equals(simples, that.simples);
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(simples);
+ }
}
/** The schema for {@link NestedCollectionPOJO}. * */
@@ -228,6 +397,24 @@ public PrimitiveMapPOJO(Map<String, Integer> map) {
}
public PrimitiveMapPOJO() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ PrimitiveMapPOJO that = (PrimitiveMapPOJO) o;
+ return Objects.equals(map, that.map);
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(map);
+ }
}
/** The schema for {@link PrimitiveMapPOJO}. * */
@@ -244,6 +431,23 @@ public NestedMapPOJO(Map<String, SimplePOJO> map) {
}
public NestedMapPOJO() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NestedMapPOJO that = (NestedMapPOJO) o;
+ return Objects.equals(map, that.map);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(map);
+ }
}
/** The schema for {@link NestedMapPOJO}. * */
@@ -271,6 +475,27 @@ public POJOWithBoxedFields(
}
public POJOWithBoxedFields() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ POJOWithBoxedFields that = (POJOWithBoxedFields) o;
+ return Objects.equals(aByte, that.aByte)
+ && Objects.equals(aShort, that.aShort)
+ && Objects.equals(anInt, that.anInt)
+ && Objects.equals(aLong, that.aLong)
+ && Objects.equals(aBoolean, that.aBoolean);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(aByte, aShort, anInt, aLong, aBoolean);
+ }
}
/** The schema for {@link POJOWithBoxedFields}. * */
@@ -295,6 +520,25 @@ public POJOWithByteArray(byte[] bytes1, ByteBuffer bytes2)
{
}
public POJOWithByteArray() {}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ POJOWithByteArray that = (POJOWithByteArray) o;
+ return Arrays.equals(bytes1, that.bytes1) && Objects.equals(bytes2,
that.bytes2);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = Objects.hash(bytes2);
+ result = 31 * result + Arrays.hashCode(bytes1);
+ return result;
+ }
}
/** The schema for {@link POJOWithByteArray}. * */
diff --git
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/example/model/Customer.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/example/model/Customer.java
index 1b617404b60..b471dc83a26 100644
---
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/example/model/Customer.java
+++
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/example/model/Customer.java
@@ -18,6 +18,7 @@
package org.apache.beam.sdk.extensions.sql.example.model;
import java.io.Serializable;
+import java.util.Objects;
import org.apache.beam.sdk.schemas.DefaultSchema;
import org.apache.beam.sdk.schemas.JavaBeanSchema;
@@ -59,4 +60,23 @@ public void setId(int id) {
public void setCountryOfResidence(String countryOfResidence) {
this.countryOfResidence = countryOfResidence;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ Customer customer = (Customer) o;
+ return id == customer.id
+ && Objects.equals(name, customer.name)
+ && Objects.equals(countryOfResidence, customer.countryOfResidence);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, id, countryOfResidence);
+ }
}
diff --git
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/example/model/Order.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/example/model/Order.java
index 81402ebedee..656473284b0 100644
---
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/example/model/Order.java
+++
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/example/model/Order.java
@@ -18,6 +18,7 @@
package org.apache.beam.sdk.extensions.sql.example.model;
import java.io.Serializable;
+import java.util.Objects;
import org.apache.beam.sdk.schemas.DefaultSchema;
import org.apache.beam.sdk.schemas.JavaBeanSchema;
@@ -49,4 +50,21 @@ public void setId(int id) {
public void setCustomerId(int customerId) {
this.customerId = customerId;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ Order order = (Order) o;
+ return id == order.id && customerId == order.customerId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, customerId);
+ }
}
diff --git
a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/InferredJavaBeanSqlTest.java
b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/InferredJavaBeanSqlTest.java
index da93d93712a..829469ae78a 100644
---
a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/InferredJavaBeanSqlTest.java
+++
b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/InferredJavaBeanSqlTest.java
@@ -20,6 +20,7 @@
import static org.apache.beam.sdk.extensions.sql.TestUtils.tuple;
import java.io.Serializable;
+import java.util.Objects;
import org.apache.beam.sdk.schemas.DefaultSchema;
import org.apache.beam.sdk.schemas.JavaBeanSchema;
import org.apache.beam.sdk.schemas.Schema;
@@ -65,6 +66,23 @@ public void setAgeYears(Integer ageYears) {
public void setName(String name) {
this.name = name;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ PersonBean that = (PersonBean) o;
+ return Objects.equals(ageYears, that.ageYears) && Objects.equals(name,
that.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ageYears, name);
+ }
}
/** Order JavaBean. */
@@ -95,6 +113,25 @@ public void setAmount(Integer amount) {
public void setBuyerName(String buyerName) {
this.buyerName = buyerName;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ OrderBean orderBean = (OrderBean) o;
+ return Objects.equals(amount, orderBean.amount)
+ && Objects.equals(buyerName, orderBean.buyerName);
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(amount, buyerName);
+ }
}
@Test
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 131812)
Time Spent: 50m (was: 40m)
> Nexmark 10x performance regression
> ----------------------------------
>
> Key: BEAM-5092
> URL: https://issues.apache.org/jira/browse/BEAM-5092
> Project: Beam
> Issue Type: New Feature
> Components: sdk-java-core
> Reporter: Andrew Pilloud
> Assignee: Reuven Lax
> Priority: Critical
> Time Spent: 50m
> Remaining Estimate: 0h
>
> There looks to be a 10x performance hit on the DirectRunner and Flink nexmark
> jobs. It first showed up in this build:
> [https://builds.apache.org/view/A-D/view/Beam/job/beam_PostCommit_Java_Nexmark_Direct/151/changes]
> [https://apache-beam-testing.appspot.com/explore?dashboard=5084698770407424]
> [https://apache-beam-testing.appspot.com/explore?dashboard=5699257587728384]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)