kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From granthe...@apache.org
Subject kudu git commit: KUDU-2416: Fix PartialRow.setMin and add a unit test
Date Wed, 25 Apr 2018 21:20:27 GMT
Repository: kudu
Updated Branches:
  refs/heads/branch-1.6.x a3aa10978 -> 807648e34


KUDU-2416: Fix PartialRow.setMin and add a unit test

* Fixes INTEGER.MIN_VALUE being used for LONG colums
  that could lead to incorrect partition prunning.
* Adds a unit test for all types.

Change-Id: I510743385cc567a8443efc8b0c9f5b641cf04c31
Reviewed-on: http://gerrit.cloudera.org:8080/10189
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <danburkert@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/807648e3
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/807648e3
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/807648e3

Branch: refs/heads/branch-1.6.x
Commit: 807648e34c6b83a29ab7ea0fbc9b6420bda8186d
Parents: a3aa109
Author: Grant Henke <granthenke@apache.org>
Authored: Tue Apr 24 21:56:43 2018 -0500
Committer: Grant Henke <granthenke@apache.org>
Committed: Wed Apr 25 20:09:28 2018 +0000

----------------------------------------------------------------------
 .../java/org/apache/kudu/client/PartialRow.java  |  2 +-
 .../org/apache/kudu/client/TestPartialRow.java   | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/807648e3/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java b/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
index 4b1f965..91e5471 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
@@ -1032,7 +1032,7 @@ public class PartialRow {
         break;
       case INT64:
       case UNIXTIME_MICROS:
-        addLong(index, Integer.MIN_VALUE);
+        addLong(index, Long.MIN_VALUE);
         break;
       case FLOAT:
         addFloat(index, -Float.MAX_VALUE);

http://git-wip-us.apache.org/repos/asf/kudu/blob/807648e3/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java
index b4dd756..ac57e42 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java
@@ -230,6 +230,25 @@ public class TestPartialRow {
                  row.toString());
   }
 
+  @Test
+  public void testSetMin() {
+    PartialRow partialRow = getPartialRowWithAllTypes();
+    for (int i = 0; i < partialRow.getSchema().getColumnCount(); i++) {
+      partialRow.setMin(i);
+    }
+    assertEquals(false, partialRow.getBoolean("bool"));
+    assertEquals(Byte.MIN_VALUE, partialRow.getByte("int8"));
+    assertEquals(Short.MIN_VALUE, partialRow.getShort("int16"));
+    assertEquals(Integer.MIN_VALUE, partialRow.getInt("int32"));
+    assertEquals(Long.MIN_VALUE, partialRow.getLong("int64"));
+    assertEquals(Long.MIN_VALUE, partialRow.getLong("timestamp"));
+    assertEquals(-Float.MAX_VALUE, partialRow.getFloat("float"), 0.0f);
+    assertEquals(-Double.MAX_VALUE, partialRow.getDouble("double"), 0.0);
+    assertEquals("", partialRow.getString("string"));
+    assertArrayEquals(new byte[0], partialRow.getBinaryCopy("binary-array"));
+    assertArrayEquals(new byte[0], partialRow.getBinaryCopy("binary-bytebuffer"));
+  }
+
   private PartialRow getPartialRowWithAllTypes() {
     Schema schema = BaseKuduTest.getSchemaWithAllTypes();
     // Ensure we aren't missing any types


Mime
View raw message