kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [2/2] kudu git commit: java: fix incorrect hashmap usage in Statistics
Date Fri, 30 Jun 2017 21:37:53 GMT
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 <jdcryans@apache.org>
Tested-by: Todd Lipcon <todd@apache.org>
(cherry picked from commit 332ebcd063b55923806b1704113d0623f7aae745)
Reviewed-on: http://gerrit.cloudera.org:8080/7338


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

Branch: refs/heads/branch-1.4.x
Commit: d759f3ee93d1158ac17409a1abc565b3e0d9b3d3
Parents: 1a897cc
Author: Todd Lipcon <todd@apache.org>
Authored: Thu Jun 29 14:21:15 2017 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Fri Jun 30 19:44:08 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/d759f3ee/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/d759f3ee/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));
   }
 }


Mime
View raw message