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 2019/02/11 18:42:42 UTC

[kudu] branch branch-1.9.x updated (cb5c6cd -> 3aae1ba)

This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a change to branch branch-1.9.x
in repository https://gitbox.apache.org/repos/asf/kudu.git.


    from cb5c6cd  [rebalancer] location-aware rebalancer (part 10/n)
     new b872c34  KUDU-2411: Mark the KuduTestHarness as public
     new a16d2e5  [client] Mark GetUnscaledDecimal as const
     new 3aae1ba  [client] Improve message when setting a decimal on a non-decimal column

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/kudu/test/KuduTestHarness.java  |  4 ++--
 .../java/org/apache/kudu/test/TempDirUtils.java     |  4 ++++
 .../kudu/test/cluster/KuduBinaryJarExtractor.java   |  4 ++++
 src/kudu/client/scan_batch.cc                       |  2 +-
 src/kudu/common/partial_row-test.cc                 |  6 ++++++
 src/kudu/common/partial_row.cc                      | 21 ++++++++++++++-------
 src/kudu/common/partial_row.h                       |  4 ++--
 7 files changed, 33 insertions(+), 12 deletions(-)


[kudu] 01/03: KUDU-2411: Mark the KuduTestHarness as public

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch branch-1.9.x
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit b872c340dfe1d975e4fe078a80d9036d4fc59edf
Author: Grant Henke <gr...@apache.org>
AuthorDate: Fri Feb 8 08:15:02 2019 -0600

    KUDU-2411: Mark the KuduTestHarness as public
    
    This patch marks the KuduTestHarness as public and
    evolving so that users external to Kudu can use the
    rule for integration testing.
    
    Additionally some unmarked classes were marked private
    and unstable.
    
    Change-Id: I739d5fb4a602817924187ce24d64b2561594ab37
    Reviewed-on: http://gerrit.cloudera.org:8080/12408
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
    Tested-by: Grant Henke <gr...@apache.org>
---
 .../src/main/java/org/apache/kudu/test/KuduTestHarness.java           | 4 ++--
 .../src/main/java/org/apache/kudu/test/TempDirUtils.java              | 4 ++++
 .../java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java     | 4 ++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/java/kudu-test-utils/src/main/java/org/apache/kudu/test/KuduTestHarness.java b/java/kudu-test-utils/src/main/java/org/apache/kudu/test/KuduTestHarness.java
index d4e008a..10a1271 100644
--- a/java/kudu-test-utils/src/main/java/org/apache/kudu/test/KuduTestHarness.java
+++ b/java/kudu-test-utils/src/main/java/org/apache/kudu/test/KuduTestHarness.java
@@ -63,8 +63,8 @@ import static org.junit.Assert.fail;
  * }
  * </pre>
  */
-@InterfaceAudience.Private
-@InterfaceStability.Unstable
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
 public class KuduTestHarness extends ExternalResource {
 
   private static final Logger LOG = LoggerFactory.getLogger(KuduTestHarness.class);
diff --git a/java/kudu-test-utils/src/main/java/org/apache/kudu/test/TempDirUtils.java b/java/kudu-test-utils/src/main/java/org/apache/kudu/test/TempDirUtils.java
index 01d435b..8fa65a2 100644
--- a/java/kudu-test-utils/src/main/java/org/apache/kudu/test/TempDirUtils.java
+++ b/java/kudu-test-utils/src/main/java/org/apache/kudu/test/TempDirUtils.java
@@ -18,6 +18,8 @@
 package org.apache.kudu.test;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.yetus.audience.InterfaceStability;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -30,6 +32,8 @@ import java.nio.file.Paths;
 /**
  * Utilities for retrieving and creating temp directories.
  */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
 public class TempDirUtils {
 
   /**
diff --git a/java/kudu-test-utils/src/main/java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java b/java/kudu-test-utils/src/main/java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java
index 2ddb215..69aec0e 100644
--- a/java/kudu-test-utils/src/main/java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java
+++ b/java/kudu-test-utils/src/main/java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java
@@ -19,6 +19,8 @@ package org.apache.kudu.test.cluster;
 
 import com.google.common.base.Preconditions;
 import com.google.gradle.osdetector.OsDetector;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.yetus.audience.InterfaceStability;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,6 +48,8 @@ import java.util.Set;
 /**
  * Class to find and extract Kudu binary jars from the classpath
  */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
 public class KuduBinaryJarExtractor {
 
   private static final Logger LOG = LoggerFactory.getLogger(KuduBinaryJarExtractor.class);


[kudu] 03/03: [client] Improve message when setting a decimal on a non-decimal column

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch branch-1.9.x
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 3aae1ba565741ccf2aac6930984639c0062eead0
Author: Grant Henke <gr...@apache.org>
AuthorDate: Mon Feb 11 10:54:41 2019 -0600

    [client] Improve message when setting a decimal on a non-decimal column
    
    This patch improves the error messaging when
    setting a decimal on a non-decimal column.
    
    Changes the order of validation operations to first
    check the column type is valid before checking
    the value is in range.
    
    Change-Id: I331028c3ce88e54eef0a091c0cc98b39293fb3c1
    Reviewed-on: http://gerrit.cloudera.org:8080/12435
    Tested-by: Kudu Jenkins
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
 src/kudu/client/scan_batch.cc       |  2 +-
 src/kudu/common/partial_row-test.cc |  6 ++++++
 src/kudu/common/partial_row.cc      | 17 ++++++++++++-----
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/kudu/client/scan_batch.cc b/src/kudu/client/scan_batch.cc
index ac63c1f..d79397f 100644
--- a/src/kudu/client/scan_batch.cc
+++ b/src/kudu/client/scan_batch.cc
@@ -341,7 +341,7 @@ Status KuduScanBatch::RowPtr::GetUnscaledDecimal(int col_idx, int128_t* val) con
       return Status::OK();
     default:
       return Status::InvalidArgument(
-          Substitute("invalid type $0 provided for column '$1' (expected DECIMAL)",
+          Substitute("invalid type $0 provided for column '$1' (expected decimal)",
                      col.type_info()->name(), col.name()));
   }
 }
diff --git a/src/kudu/common/partial_row-test.cc b/src/kudu/common/partial_row-test.cc
index fc4671c..5421f1d 100644
--- a/src/kudu/common/partial_row-test.cc
+++ b/src/kudu/common/partial_row-test.cc
@@ -232,6 +232,12 @@ TEST_F(PartialRowTest, UnitTest) {
   EXPECT_EQ("Invalid argument: value -10000.00 out of range for decimal column 'decimal_val'",
             s.ToString());
 
+  // Set a decimal value on a non decimal column.
+  s = row.SetUnscaledDecimal("string_val", 123456);
+  EXPECT_EQ("Invalid argument: invalid type string provided for column "
+            "'string_val' (expected decimal)",
+            s.ToString());
+
   // Even though the storage is actually the same at the moment, we shouldn't be
   // able to set string columns with SetBinary and vice versa.
   EXPECT_FALSE(row.SetBinaryCopy("string_val", "oops").ok());
diff --git a/src/kudu/common/partial_row.cc b/src/kudu/common/partial_row.cc
index a40b98e..cb422f5 100644
--- a/src/kudu/common/partial_row.cc
+++ b/src/kudu/common/partial_row.cc
@@ -301,10 +301,8 @@ Status KuduPartialRow::SetFloat(int col_idx, float val) {
 Status KuduPartialRow::SetDouble(int col_idx, double val) {
   return Set<TypeTraits<DOUBLE> >(col_idx, val);
 }
-Status KuduPartialRow::SetUnscaledDecimal(int col_idx, int128_t val) {
-  const ColumnSchema& col = schema_->column(col_idx);
-  const DataType col_type = col.type_info()->type();
 
+Status CheckDecimalValueInRange(ColumnSchema col, int128_t val) {
   int128_t max_val = MaxUnscaledDecimal(col.type_attributes().precision);
   int128_t min_val = -max_val;
   if (val < min_val || val > max_val) {
@@ -312,16 +310,25 @@ Status KuduPartialRow::SetUnscaledDecimal(int col_idx, int128_t val) {
         Substitute("value $0 out of range for decimal column '$1'",
                    DecimalToString(val, col.type_attributes().scale), col.name()));
   }
+  return Status::OK();
+}
+
+Status KuduPartialRow::SetUnscaledDecimal(int col_idx, int128_t val) {
+  const ColumnSchema& col = schema_->column(col_idx);
+  const DataType col_type = col.type_info()->type();
   switch (col_type) {
     case DECIMAL32:
+      RETURN_NOT_OK(CheckDecimalValueInRange(col, val))
       return Set<TypeTraits<DECIMAL32> >(col_idx, static_cast<int32_t>(val));
     case DECIMAL64:
+      RETURN_NOT_OK(CheckDecimalValueInRange(col, val))
       return Set<TypeTraits<DECIMAL64> >(col_idx, static_cast<int64_t>(val));
     case DECIMAL128:
+      RETURN_NOT_OK(CheckDecimalValueInRange(col, val))
       return Set<TypeTraits<DECIMAL128> >(col_idx, static_cast<int128_t>(val));
     default:
       return Status::InvalidArgument(
-          Substitute("invalid type $0 provided for column '$1' (expected DECIMAL)",
+          Substitute("invalid type $0 provided for column '$1' (expected decimal)",
                      col.type_info()->name(), col.name()));
   }
 }
@@ -700,7 +707,7 @@ Status KuduPartialRow::GetUnscaledDecimal(int col_idx, int128_t *val) const {
       return Status::OK();
     default:
       return Status::InvalidArgument(
-          Substitute("invalid type $0 provided for column '$1' (expected DECIMAL)",
+          Substitute("invalid type $0 provided for column '$1' (expected decimal)",
                      col.type_info()->name(), col.name()));
   }
 }


[kudu] 02/03: [client] Mark GetUnscaledDecimal as const

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch branch-1.9.x
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit a16d2e5e05114d046dae6b7bdbe30a975bbc5272
Author: Grant Henke <gr...@apache.org>
AuthorDate: Mon Feb 11 10:15:53 2019 -0600

    [client] Mark GetUnscaledDecimal as const
    
    The KuduPartialRow::GetUnscaledDecimal functions
    are missing the const keyword.
    
    Change-Id: I91d1d21a76179ff511eb5723958dcfb3d5eae0a2
    Reviewed-on: http://gerrit.cloudera.org:8080/12434
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
    Tested-by: Kudu Jenkins
---
 src/kudu/common/partial_row.cc | 4 ++--
 src/kudu/common/partial_row.h  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/kudu/common/partial_row.cc b/src/kudu/common/partial_row.cc
index b20ce33..a40b98e 100644
--- a/src/kudu/common/partial_row.cc
+++ b/src/kudu/common/partial_row.cc
@@ -643,7 +643,7 @@ Status KuduPartialRow::GetFloat(const Slice& col_name, float* val) const {
 Status KuduPartialRow::GetDouble(const Slice& col_name, double* val) const {
   return Get<TypeTraits<DOUBLE> >(col_name, val);
 }
-Status KuduPartialRow::GetUnscaledDecimal(const Slice &col_name, int128_t *val) {
+Status KuduPartialRow::GetUnscaledDecimal(const Slice &col_name, int128_t *val) const {
   int col_idx;
   RETURN_NOT_OK(FindColumn(*schema_, col_name, &col_idx));
   return GetUnscaledDecimal(col_idx, val);
@@ -679,7 +679,7 @@ Status KuduPartialRow::GetFloat(int col_idx, float* val) const {
 Status KuduPartialRow::GetDouble(int col_idx, double* val) const {
   return Get<TypeTraits<DOUBLE> >(col_idx, val);
 }
-Status KuduPartialRow::GetUnscaledDecimal(int col_idx, int128_t *val) {
+Status KuduPartialRow::GetUnscaledDecimal(int col_idx, int128_t *val) const {
   const ColumnSchema& col = schema_->column(col_idx);
   const DataType col_type = col.type_info()->type();
   switch (col_type) {
diff --git a/src/kudu/common/partial_row.h b/src/kudu/common/partial_row.h
index 36e0c78..3dca69d 100644
--- a/src/kudu/common/partial_row.h
+++ b/src/kudu/common/partial_row.h
@@ -361,7 +361,7 @@ class KUDU_EXPORT KuduPartialRow {
   Status GetFloat(const Slice& col_name, float* val) const WARN_UNUSED_RESULT;
   Status GetDouble(const Slice& col_name, double* val) const WARN_UNUSED_RESULT;
 #if KUDU_INT128_SUPPORTED
-  Status GetUnscaledDecimal(const Slice& col_name, int128_t* val) WARN_UNUSED_RESULT;
+  Status GetUnscaledDecimal(const Slice& col_name, int128_t* val) const WARN_UNUSED_RESULT;
 #endif
   ///@}
 
@@ -394,7 +394,7 @@ class KUDU_EXPORT KuduPartialRow {
   Status GetFloat(int col_idx, float* val) const WARN_UNUSED_RESULT;
   Status GetDouble(int col_idx, double* val) const WARN_UNUSED_RESULT;
 #if KUDU_INT128_SUPPORTED
-  Status GetUnscaledDecimal(int col_idx, int128_t* val) WARN_UNUSED_RESULT;
+  Status GetUnscaledDecimal(int col_idx, int128_t* val) const WARN_UNUSED_RESULT;
 #endif
   ///@}