You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2018/06/27 14:19:11 UTC
[1/2] kudu git commit: KUDU-2471: Fix ColumnSchema.equals NPE with
non-Decimal columns
Repository: kudu
Updated Branches:
refs/heads/master 4479c20bb -> e0a4c6cfa
KUDU-2471: Fix ColumnSchema.equals NPE with non-Decimal columns
Fixes a potential NPE on non-decimal columns and adds
tests to prevent the issue in the future.
Change-Id: Ica7afcbbbd9197e6ffd34761a5298f29e7306dd6
Reviewed-on: http://gerrit.cloudera.org:8080/10826
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <da...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/81828ba6
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/81828ba6
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/81828ba6
Branch: refs/heads/master
Commit: 81828ba64f6348da2a4aec3fab3e7833f7ad01f0
Parents: 4479c20
Author: Grant Henke <gr...@apache.org>
Authored: Tue Jun 26 15:00:39 2018 -0500
Committer: Grant Henke <gr...@apache.org>
Committed: Wed Jun 27 13:03:22 2018 +0000
----------------------------------------------------------------------
.../main/java/org/apache/kudu/ColumnSchema.java | 28 +++----------
.../java/org/apache/kudu/TestColumnSchema.java | 44 ++++++++++++++++++++
2 files changed, 50 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/81828ba6/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java b/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java
index 6bb8263..212ce78 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java
@@ -195,29 +195,13 @@ public class ColumnSchema {
@Override
public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
ColumnSchema that = (ColumnSchema) o;
-
- if (key != that.key) {
- return false;
- }
- if (!name.equals(that.name)) {
- return false;
- }
- if (!type.equals(that.type)) {
- return false;
- }
- if (!typeAttributes.equals(that.typeAttributes)) {
- return false;
- }
-
- return true;
+ return Objects.equals(name, that.name) &&
+ Objects.equals(type, that.type) &&
+ Objects.equals(key, that.key) &&
+ Objects.equals(typeAttributes, that.typeAttributes);
}
@Override
http://git-wip-us.apache.org/repos/asf/kudu/blob/81828ba6/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java b/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java
index d2d0710..51d5cb8 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java
@@ -21,6 +21,7 @@ import org.apache.kudu.util.DecimalUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
public class TestColumnSchema {
@@ -36,4 +37,47 @@ public class TestColumnSchema {
assertEquals("Column name: col2, type: int64", col2.toString());
assertEquals("Column name: col3, type: decimal(5, 2)", col3.toString());
}
+
+ @Test
+ public void testEquals() {
+ ColumnSchema stringCol1 = new ColumnSchemaBuilder("col1", Type.STRING)
+ .defaultValue("test")
+ .build();
+ // Same instance
+ assertEquals(stringCol1, stringCol1);
+
+ // Same value
+ ColumnSchema stringCol2 = new ColumnSchemaBuilder("col1", Type.STRING)
+ .defaultValue("test")
+ .build();
+ assertEquals(stringCol1, stringCol2);
+
+ // Different by key
+ ColumnSchema isKey = new ColumnSchemaBuilder("col1", Type.STRING)
+ .key(true)
+ .build();
+ assertNotEquals(stringCol1, isKey);
+
+ // Different by type
+ ColumnSchema isInt = new ColumnSchemaBuilder("col1", Type.INT32)
+ .build();
+ assertNotEquals(stringCol1, isInt);
+
+ // Same with type attributes
+ ColumnSchema decCol1 = new ColumnSchemaBuilder("col1", Type.DECIMAL)
+ .typeAttributes(DecimalUtil.typeAttributes(9, 2))
+ .build();
+ ColumnSchema decCol2 = new ColumnSchemaBuilder("col1", Type.DECIMAL)
+ .typeAttributes(DecimalUtil.typeAttributes(9, 2))
+ .build();
+ assertEquals(decCol1, decCol2);
+
+ // Different by type attributes
+ ColumnSchema decCol3 = new ColumnSchemaBuilder("col1", Type.DECIMAL)
+ .typeAttributes(DecimalUtil.typeAttributes(9, 0))
+ .build();
+ assertNotEquals(decCol1, decCol3);
+
+
+ }
}
[2/2] kudu git commit: [tests] Fix usage of deprecated time zones
Posted by gr...@apache.org.
[tests] Fix usage of deprecated time zones
Replaces some deprecated 3 letter time zones with thier
equivalents.
Change-Id: Ie5f87f337d04231eb4ed092adbd3963598bc86ad
Reviewed-on: http://gerrit.cloudera.org:8080/10828
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <da...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/e0a4c6cf
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/e0a4c6cf
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/e0a4c6cf
Branch: refs/heads/master
Commit: e0a4c6cfa122f6263c068d59ba8566c1a786967a
Parents: 81828ba
Author: Grant Henke <gr...@apache.org>
Authored: Tue Jun 26 15:13:59 2018 -0500
Committer: Grant Henke <gr...@apache.org>
Committed: Wed Jun 27 13:03:28 2018 +0000
----------------------------------------------------------------------
.../src/test/java/org/apache/kudu/util/TestTimestampUtil.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/e0a4c6cf/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java b/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java
index c06ae06..46d6e69 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java
@@ -49,7 +49,7 @@ public class TestTimestampUtil {
@Test
public void testNonZuluTimestampConversion() throws Exception {
SimpleDateFormat cst = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
- cst.setTimeZone(TimeZone.getTimeZone("CST"));
+ cst.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
String timeString = "2016-08-19T12:12:12.121";
Timestamp timestamp = new Timestamp(cst.parse(timeString).getTime());
@@ -63,7 +63,7 @@ public class TestTimestampUtil {
assertEquals(timeString, formattedCST);
SimpleDateFormat pst = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
- pst.setTimeZone(TimeZone.getTimeZone("PST"));
+ pst.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
String formattedPST = pst.format(fromMicros);
assertEquals("2016-08-19T10:12:12.121", formattedPST);