From 0dfa6648613a660961b06ffd4aed9b026c141a11 Mon Sep 17 00:00:00 2001 From: Oleg Danilov Date: Mon, 14 Aug 2017 13:19:55 +0300 Subject: [PATCH] HIVE-17311: Fixed numeric overflow, added test --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java | 6 +++--- common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 056f2d78346..580e725df92 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -1690,7 +1690,7 @@ private static void populateLlapDaemonVarsSet(Set llapDaemonVarsSetLocal "Whether column accesses are tracked in the QueryPlan.\n" + "This is useful to identify how tables are accessed and to determine if there are wasted columns that can be trimmed."), HIVE_STATS_NDV_ALGO("hive.stats.ndv.algo", "hll", new PatternSet("hll", "fm"), - "hll and fm stand for HyperLogLog and FM-sketch, respectively for computing ndv."), + "hll and fm stand for HyperLogLog and FM-sketch, respectively for computing ndv."), HIVE_STATS_FETCH_BITVECTOR("hive.stats.fetch.bitvector", false, "Whether we fetch bitvector when we compute ndv. Users can turn it off if they want to use old schema"), // standard error allowed for ndv estimates for FM-sketch. A lower value indicates higher accuracy and a @@ -3913,9 +3913,9 @@ public static long multiplierFor(String unit) { } else if (unit.equals("gb")) { return 1024*1024*1024; } else if (unit.equals("tb")) { - return 1024*1024*1024*1024; + return 1024L*1024*1024*1024; } else if (unit.equals("pb")) { - return 1024*1024*1024*1024*1024; + return 1024L*1024*1024*1024*1024; } throw new IllegalArgumentException("Invalid size unit " + unit); } diff --git a/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java b/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java index fa51ef64291..c914d2332dc 100644 --- a/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java +++ b/common/src/test/org/apache/hadoop/hive/conf/TestHiveConf.java @@ -117,6 +117,17 @@ public void testUnitFor() throws Exception { } @Test + public void testToSizeBytes() throws Exception { + Assert.assertEquals(1L, HiveConf.toSizeBytes("1b")); + Assert.assertEquals(1L, HiveConf.toSizeBytes("1bytes")); + Assert.assertEquals(1024L, HiveConf.toSizeBytes("1kb")); + Assert.assertEquals(1048576L, HiveConf.toSizeBytes("1mb")); + Assert.assertEquals(1073741824L, HiveConf.toSizeBytes("1gb")); + Assert.assertEquals(1099511627776L, HiveConf.toSizeBytes("1tb")); + Assert.assertEquals(1125899906842624L, HiveConf.toSizeBytes("1pb")); + } + + @Test public void testHiddenConfig() throws Exception { HiveConf conf = new HiveConf(); // check password configs are hidden