You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by jd...@apache.org on 2017/07/06 19:57:52 UTC

kudu git commit: java: fix incorrect hashmap usage in Statistics

Repository: kudu
Updated Branches:
  refs/heads/branch-1.2.x 36eff644b -> 3043dc5a4


java: fix incorrect hashmap usage in Statistics

65cb2edf5661599f689e28f4eec161fe062f7cb5 changed the hash map in the
Statistics class to use Strings instead of Slices as keys, but didn't
properly update all of the call sites.

Change-Id: I715e96a02ec83199b7e0678281c0857bf9258cf4
Reviewed-on: http://gerrit.cloudera.org:8080/7335
Reviewed-by: Jean-Daniel Cryans <jd...@apache.org>
Tested-by: Todd Lipcon <to...@apache.org>
(cherry picked from commit 332ebcd063b55923806b1704113d0623f7aae745)
Reviewed-on: http://gerrit.cloudera.org:8080/7340
Tested-by: Kudu Jenkins


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

Branch: refs/heads/branch-1.2.x
Commit: 3043dc5a499af545d1fc04c464ccf34142a810df
Parents: 36eff64
Author: Todd Lipcon <to...@apache.org>
Authored: Thu Jun 29 14:21:15 2017 -0700
Committer: Jean-Daniel Cryans <jd...@apache.org>
Committed: Thu Jul 6 19:57:25 2017 +0000

----------------------------------------------------------------------
 .../main/java/org/apache/kudu/client/Statistics.java   | 10 ++--------
 .../java/org/apache/kudu/client/TestStatistics.java    | 13 +++++++++++--
 2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/3043dc5a/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java
index 5f595c8..1c672c6 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Statistics.java
@@ -17,7 +17,6 @@
 
 package org.apache.kudu.client;
 
-import java.nio.charset.Charset;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLongArray;
@@ -26,9 +25,6 @@ import com.google.common.collect.Sets;
 
 import org.apache.kudu.annotations.InterfaceAudience;
 import org.apache.kudu.annotations.InterfaceStability;
-import org.apache.kudu.util.Slice;
-import org.apache.kudu.util.Slices;
-
 
 /**
  * A Statistics belongs to a specific AsyncKuduClient. It stores client-level
@@ -101,8 +97,7 @@ public class Statistics {
    * @return the value of the statistic
    */
   public long getTabletStatistic(String tabletId, Statistic statistic) {
-    Slice tabletIdAsSlice = Slices.copiedBuffer(tabletId, Charset.defaultCharset());
-    TabletStatistics tabletStatistics = stsMap.get(tabletIdAsSlice);
+    TabletStatistics tabletStatistics = stsMap.get(tabletId);
     if (tabletStatistics == null) {
       return 0;
     } else {
@@ -173,8 +168,7 @@ public class Statistics {
    * @return table name
    */
   public String getTableName(String tabletId) {
-    Slice tabletIdAsSlice = Slices.copiedBuffer(tabletId, Charset.defaultCharset());
-    TabletStatistics tabletStatistics = stsMap.get(tabletIdAsSlice);
+    TabletStatistics tabletStatistics = stsMap.get(tabletId);
     if (tabletStatistics == null) {
       return null;
     } else {

http://git-wip-us.apache.org/repos/asf/kudu/blob/3043dc5a/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java
index fadbfde..7afb524 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java
@@ -23,6 +23,9 @@ import org.junit.Test;
 
 import org.apache.kudu.client.Statistics.Statistic;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public class TestStatistics extends BaseKuduTest {
 
   private static final String TABLE_NAME = TestStatistics.class.getName() + "-"
@@ -69,7 +72,13 @@ public class TestStatistics extends BaseKuduTest {
     assertEquals(rowCount, statistics.getClientStatistic(Statistic.OPS_ERRORS));
     assertEquals(byteSize * 2, statistics.getClientStatistic(Statistic.BYTES_WRITTEN));
 
-    assertEquals(1, statistics.getTableSet().size());
-    assertEquals(1, statistics.getTabletSet().size());
+    List<String> tableNames = new ArrayList<>(statistics.getTableSet());
+    assertEquals(1, tableNames.size());
+    assertEquals(TABLE_NAME, tableNames.get(0));
+    assertEquals(rowCount, statistics.getTableStatistic(TABLE_NAME, Statistic.WRITE_OPS));
+
+    List<String> tabletIds = new ArrayList<>(statistics.getTabletSet());
+    assertEquals(1, tabletIds.size());
+    assertEquals(rowCount, statistics.getTabletStatistic(tabletIds.get(0), Statistic.WRITE_OPS));
   }
 }