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: Fixes #849 Test Value in CountingSummarizer Converter (#893)
Date Tue, 15 Jan 2019 17:29:44 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 1687f33  Fixes #849 Test Value in CountingSummarizer Converter (#893)
1687f33 is described below

commit 1687f33eadc737efe3359cc93934a20aedc92b2a
Author: Jeffrey Zeiberg <jzeiberg@gmail.com>
AuthorDate: Tue Jan 15 12:29:38 2019 -0500

    Fixes #849 Test Value in CountingSummarizer Converter (#893)
---
 .../client/summary/CountingSummarizerTest.java     | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/core/src/test/java/org/apache/accumulo/core/client/summary/CountingSummarizerTest.java
b/core/src/test/java/org/apache/accumulo/core/client/summary/CountingSummarizerTest.java
index e8e14b8..a15fb23 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/summary/CountingSummarizerTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/summary/CountingSummarizerTest.java
@@ -51,6 +51,15 @@ public class CountingSummarizerTest {
     }
   }
 
+  public static class ValueSummarizer extends CountingSummarizer<String> {
+    @Override
+    protected Converter<String> converter() {
+      return (k, v, c) -> {
+        c.accept("vp:" + v.toString().subSequence(0, 2));
+      };
+    }
+  }
+
   @Test
   public void testMultipleEmit() {
     SummarizerConfiguration sc = SummarizerConfiguration.builder(MultiSummarizer.class).build();
@@ -255,4 +264,39 @@ public class CountingSummarizerTest {
     expected.put("f2", 1L);
     assertEquals(expected, csum.getCounters());
   }
+
+  @Test
+  public void testConvertValue() {
+
+    SummarizerConfiguration sc = SummarizerConfiguration.builder(ValueSummarizer.class).build();
+    ValueSummarizer countSum = new ValueSummarizer();
+
+    Summarizer.Collector collector = countSum.collector(sc);
+
+    HashMap<String,Long> expected = new HashMap<>();
+
+    for (String row : new String[] {"ask", "asleep", "some", "soul"}) {
+      for (String fam : new String[] {"hop", "hope", "nope", "noop"}) {
+        for (String qual : new String[] {"mad", "lad", "lab", "map"})
+          for (Value value : new Value[] {new Value("ask"), new Value("asleep"), new Value("some"),
+              new Value("soul")}) {
+            collector.accept(new Key(row, fam, qual), value);
+            expected.merge("vp:" + value.toString().substring(0, 2), 1L, Long::sum);
+
+          }
+      }
+    }
+
+    HashMap<String,Long> stats = new HashMap<>();
+    collector.summarize(stats::put);
+
+    CounterSummary csum = new CounterSummary(stats);
+    assertEquals(expected, csum.getCounters());
+    assertEquals(256, csum.getSeen());
+    assertEquals(256, csum.getEmitted());
+    assertEquals(0, csum.getIgnored());
+    assertEquals(0, csum.getDeletesIgnored());
+
+  }
+
 }


Mime
View raw message