accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmil...@apache.org
Subject [accumulo] branch master updated: Remove extra loop in InMemoryMap (#843)
Date Wed, 19 Dec 2018 23:39:05 GMT
This is an automated email from the ASF dual-hosted git repository.

mmiller pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new c06636e  Remove extra loop in InMemoryMap (#843)
c06636e is described below

commit c06636e1d701947bc66d0ff6f3652e32ef5dddb6
Author: Mike Miller <mmiller@apache.org>
AuthorDate: Wed Dec 19 18:39:01 2018 -0500

    Remove extra loop in InMemoryMap (#843)
    
    * The number of total keys across mutations was counted twice so just
    pass the count down to the InMemoryMap
---
 .../main/java/org/apache/accumulo/tserver/InMemoryMap.java    |  6 +-----
 .../org/apache/accumulo/tserver/tablet/CommitSession.java     |  4 ++--
 .../main/java/org/apache/accumulo/tserver/tablet/Tablet.java  |  4 ++--
 .../java/org/apache/accumulo/tserver/tablet/TabletMemory.java |  4 ++--
 .../java/org/apache/accumulo/tserver/InMemoryMapTest.java     | 10 +++++-----
 .../src/main/java/org/apache/accumulo/test/InMemoryMapIT.java | 11 +++++++----
 6 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java
index e93e7f6..b9e2167 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java
@@ -528,11 +528,7 @@ public class InMemoryMap {
    * Applies changes to a row in the InMemoryMap
    *
    */
-  public void mutate(List<Mutation> mutations) {
-    int numKVs = 0;
-    for (Mutation mutation : mutations)
-      numKVs += mutation.size();
-
+  public void mutate(List<Mutation> mutations, int numKVs) {
     // Can not update mutationCount while writes that started before
     // are in progress, this would cause partial mutations to be seen.
     // Also, can not continue until mutation count is updated, because
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CommitSession.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CommitSession.java
index 885b349..247f0c8 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CommitSession.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CommitSession.java
@@ -111,7 +111,7 @@ public class CommitSession {
     return maxCommittedTime;
   }
 
-  public void mutate(List<Mutation> mutations) {
-    memTable.mutate(mutations);
+  public void mutate(List<Mutation> mutations, int count) {
+    memTable.mutate(mutations, count);
   }
 }
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index a769061..833a9d3 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -445,7 +445,7 @@ public class Tablet implements TabletCommitter {
                     maxTime.set(Math.max(maxTime.get(), columnUpdate.getTimestamp()));
                   }
                 }
-                getTabletMemory().mutate(commitSession, Collections.singletonList(m));
+                getTabletMemory().mutate(commitSession, Collections.singletonList(m), 1);
                 entriesUsedOnTablet.incrementAndGet();
               }
             });
@@ -1284,7 +1284,7 @@ public class Tablet implements TabletCommitter {
       totalBytes += mutation.numBytes();
     }
 
-    getTabletMemory().mutate(commitSession, mutations);
+    getTabletMemory().mutate(commitSession, mutations, totalCount);
 
     synchronized (this) {
       if (writesInProgress < 1) {
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/TabletMemory.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/TabletMemory.java
index 08695df..c812356 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/TabletMemory.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/TabletMemory.java
@@ -146,8 +146,8 @@ class TabletMemory implements Closeable {
     }
   }
 
-  public void mutate(CommitSession cm, List<Mutation> mutations) {
-    cm.mutate(mutations);
+  public void mutate(CommitSession cm, List<Mutation> mutations, int count) {
+    cm.mutate(mutations, count);
   }
 
   public void updateMemoryUsageStats() {
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java
b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java
index 44465a2..cee92ee 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java
@@ -127,7 +127,7 @@ public class InMemoryMapTest {
     String[] sa = column.split(":");
     m.putDelete(new Text(sa[0]), new Text(sa[1]), ts);
 
-    imm.mutate(Collections.singletonList(m));
+    imm.mutate(Collections.singletonList(m), 1);
   }
 
   public void mutate(InMemoryMap imm, String row, String column, long ts, String value) {
@@ -135,7 +135,7 @@ public class InMemoryMapTest {
     String[] sa = column.split(":");
     m.put(new Text(sa[0]), new Text(sa[1]), ts, new Value(value.getBytes()));
 
-    imm.mutate(Collections.singletonList(m));
+    imm.mutate(Collections.singletonList(m), 1);
   }
 
   static Key newKey(String row, String column, long ts) {
@@ -492,7 +492,7 @@ public class InMemoryMapTest {
     Mutation m = new Mutation(new Text("r1"));
     m.put(new Text("foo"), new Text("cq"), 3, new Value("v1".getBytes()));
     m.put(new Text("foo"), new Text("cq"), 3, new Value("v2".getBytes()));
-    imm.mutate(Collections.singletonList(m));
+    imm.mutate(Collections.singletonList(m), 2);
 
     MemoryIterator skvi1 = imm.skvIterator(null);
     skvi1.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
@@ -529,7 +529,7 @@ public class InMemoryMapTest {
                 Mutation m = new Mutation("row");
                 m.put("cf", "cq", new Value("v".getBytes()));
                 List<Mutation> mutations = Collections.singletonList(m);
-                imm.mutate(mutations);
+                imm.mutate(mutations, 1);
                 counts[threadId]++;
               }
             }
@@ -583,7 +583,7 @@ public class InMemoryMapTest {
     m5.put("cf3", "z", 6, "A");
     m5.put("cf4", "z", 6, "B");
 
-    imm.mutate(Arrays.asList(m1, m2, m3, m4, m5));
+    imm.mutate(Arrays.asList(m1, m2, m3, m4, m5), 10);
 
     MemoryIterator iter1 = imm.skvIterator(null);
 
diff --git a/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java b/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
index 9483966..801e60a 100644
--- a/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
@@ -266,10 +266,13 @@ public class InMemoryMapIT {
     assertEquals("Not a LocalityGroupMap with native", InMemoryMap.TYPE_LOCALITY_GROUP_MAP_NATIVE,
         localityGroupMapWithNative.getMapType());
 
-    defaultMap.mutate(mutations);
-    nativeMapWrapper.mutate(mutations);
-    localityGroupMap.mutate(mutations);
-    localityGroupMapWithNative.mutate(mutations);
+    int count = 0;
+    for (Mutation m : mutations)
+      count += m.size();
+    defaultMap.mutate(mutations, count);
+    nativeMapWrapper.mutate(mutations, count);
+    localityGroupMap.mutate(mutations, count);
+    localityGroupMapWithNative.mutate(mutations, count);
 
     // let's use the transitive property to assert all four are equivalent
     assertMutatesEquivalent(mutations, defaultMap, nativeMapWrapper);


Mime
View raw message