Search in sources :

Example 6 with Collector

use of org.apache.accumulo.core.client.summary.Summarizer.Collector in project accumulo by apache.

the class EntryLengthSummarizersTest method testBasicRow.

@Test
public void testBasicRow() {
    SummarizerConfiguration sc = SummarizerConfiguration.builder(EntryLengthSummarizer.class).build();
    EntryLengthSummarizer entrySum = new EntryLengthSummarizer();
    Key k1 = new Key("r1");
    Key k2 = new Key("r2");
    Key k3 = new Key("r3");
    Collector collector = entrySum.collector(sc);
    collector.accept(k1, new Value(""));
    collector.accept(k2, new Value(""));
    collector.accept(k3, new Value(""));
    HashMap<String, Long> stats = new HashMap<>();
    collector.summarize(stats::put);
    HashMap<String, Long> expected = new HashMap<>();
    expected.put("key.min", 2L);
    expected.put("key.max", 2L);
    expected.put("key.sum", 6L);
    // Log2 Histogram
    expected.put("key.logHist.1", 3L);
    expected.put("row.min", 2L);
    expected.put("row.max", 2L);
    expected.put("row.sum", 6L);
    // Log2 Histogram
    expected.put("row.logHist.1", 3L);
    expected.put("family.min", 0L);
    expected.put("family.max", 0L);
    expected.put("family.sum", 0L);
    // Log2 Histogram
    expected.put("family.logHist.0", 3L);
    expected.put("qualifier.min", 0L);
    expected.put("qualifier.max", 0L);
    expected.put("qualifier.sum", 0L);
    // Log2 Histogram
    expected.put("qualifier.logHist.0", 3L);
    expected.put("visibility.min", 0L);
    expected.put("visibility.max", 0L);
    expected.put("visibility.sum", 0L);
    // Log2 Histogram
    expected.put("visibility.logHist.0", 3L);
    expected.put("value.min", 0L);
    expected.put("value.max", 0L);
    expected.put("value.sum", 0L);
    // Log2 Histogram
    expected.put("value.logHist.0", 3L);
    expected.put("total", 3L);
    Assert.assertEquals(expected, stats);
}
Also used : HashMap(java.util.HashMap) EntryLengthSummarizer(org.apache.accumulo.core.client.summary.summarizers.EntryLengthSummarizer) Collector(org.apache.accumulo.core.client.summary.Summarizer.Collector) Value(org.apache.accumulo.core.data.Value) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 7 with Collector

use of org.apache.accumulo.core.client.summary.Summarizer.Collector in project accumulo by apache.

the class EntryLengthSummarizersTest method testComplexValue.

@Test
public void testComplexValue() {
    SummarizerConfiguration sc = SummarizerConfiguration.builder(EntryLengthSummarizer.class).build();
    EntryLengthSummarizer entrySum = new EntryLengthSummarizer();
    Key k1 = new Key("r1", "family1", "columnQualifier1", "v1");
    Key k2 = new Key("row2", "columnFamily2", "q2", "visibility2");
    Key k3 = new Key("columnRow3", "f3", "qualifier3", "columnVisibility3");
    Collector collector = entrySum.collector(sc);
    collector.accept(k1, new Value("v1"));
    collector.accept(k2, new Value("value2"));
    collector.accept(k3, new Value("keyValue3"));
    HashMap<String, Long> stats = new HashMap<>();
    collector.summarize(stats::put);
    HashMap<String, Long> expected = new HashMap<>();
    expected.put("key.min", 27L);
    expected.put("key.max", 39L);
    expected.put("key.sum", 96L);
    // Log2 Histogram
    expected.put("key.logHist.5", 3L);
    expected.put("row.min", 2L);
    expected.put("row.max", 10L);
    expected.put("row.sum", 16L);
    // Log2 Histogram
    expected.put("row.logHist.1", 1L);
    expected.put("row.logHist.2", 1L);
    expected.put("row.logHist.3", 1L);
    expected.put("family.min", 2L);
    expected.put("family.max", 13L);
    expected.put("family.sum", 22L);
    // Log2 Histogram
    expected.put("family.logHist.1", 1L);
    expected.put("family.logHist.3", 1L);
    expected.put("family.logHist.4", 1L);
    expected.put("qualifier.min", 2L);
    expected.put("qualifier.max", 16L);
    expected.put("qualifier.sum", 28L);
    // Log2 Histogram
    expected.put("qualifier.logHist.1", 1L);
    expected.put("qualifier.logHist.3", 1L);
    expected.put("qualifier.logHist.4", 1L);
    expected.put("visibility.min", 2L);
    expected.put("visibility.max", 17L);
    expected.put("visibility.sum", 30L);
    // Log2 Histogram
    expected.put("visibility.logHist.1", 1L);
    expected.put("visibility.logHist.3", 1L);
    expected.put("visibility.logHist.4", 1L);
    expected.put("value.min", 2L);
    expected.put("value.max", 9L);
    expected.put("value.sum", 17L);
    // Log2 Histogram
    expected.put("value.logHist.1", 1L);
    expected.put("value.logHist.3", 2L);
    expected.put("total", 3L);
    Assert.assertEquals(expected, stats);
}
Also used : HashMap(java.util.HashMap) EntryLengthSummarizer(org.apache.accumulo.core.client.summary.summarizers.EntryLengthSummarizer) Collector(org.apache.accumulo.core.client.summary.Summarizer.Collector) Value(org.apache.accumulo.core.data.Value) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 8 with Collector

use of org.apache.accumulo.core.client.summary.Summarizer.Collector in project accumulo by apache.

the class CountingSummarizerTest method testMultipleEmit.

@Test
public void testMultipleEmit() {
    SummarizerConfiguration sc = SummarizerConfiguration.builder(MultiSummarizer.class).build();
    MultiSummarizer countSum = new MultiSummarizer();
    Summarizer.Collector collector = countSum.collector(sc);
    Value val = new Value("abc");
    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" }) {
                collector.accept(new Key(row, fam, qual), val);
                expected.merge("rp:" + row.substring(0, 2), 1l, Long::sum);
                expected.merge("fp:" + fam.substring(0, 2), 1l, Long::sum);
                expected.merge("qp:" + qual.substring(0, 2), 1l, Long::sum);
            }
        }
    }
    HashMap<String, Long> stats = new HashMap<>();
    collector.summarize((k, v) -> stats.put(k, v));
    CounterSummary csum = new CounterSummary(stats);
    Assert.assertEquals(expected, csum.getCounters());
    Assert.assertEquals(64, csum.getSeen());
    Assert.assertEquals(3 * 64, csum.getEmitted());
    Assert.assertEquals(0, csum.getIgnored());
    Assert.assertEquals(0, csum.getDeletesIgnored());
}
Also used : Collector(org.apache.accumulo.core.client.summary.Summarizer.Collector) HashMap(java.util.HashMap) CounterSummary(org.apache.accumulo.core.client.summary.CounterSummary) Value(org.apache.accumulo.core.data.Value) VisibilitySummarizer(org.apache.accumulo.core.client.summary.summarizers.VisibilitySummarizer) CountingSummarizer(org.apache.accumulo.core.client.summary.CountingSummarizer) Summarizer(org.apache.accumulo.core.client.summary.Summarizer) FamilySummarizer(org.apache.accumulo.core.client.summary.summarizers.FamilySummarizer) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 9 with Collector

use of org.apache.accumulo.core.client.summary.Summarizer.Collector in project accumulo by apache.

the class CountingSummarizerTest method testCountDeletes.

@Test
public void testCountDeletes() {
    SummarizerConfiguration sc = SummarizerConfiguration.builder(FamilySummarizer.class).addOptions(INGNORE_DELETES_OPT, "false").build();
    FamilySummarizer countSum = new FamilySummarizer();
    Key k1 = new Key("r1", "f1");
    Key k2 = new Key("r1", "f1");
    k2.setDeleted(true);
    Key k3 = new Key("r1", "f2");
    Collector collector = countSum.collector(sc);
    collector.accept(k1, new Value(""));
    collector.accept(k2, new Value(""));
    collector.accept(k3, new Value(""));
    String p = COUNTER_STAT_PREFIX;
    HashMap<String, Long> expected = new HashMap<>();
    expected.put(p + "f1", 2l);
    expected.put(p + "f2", 1l);
    expected.put(TOO_LONG_STAT, 0l);
    expected.put(TOO_MANY_STAT, 0l);
    expected.put(SEEN_STAT, 3l);
    expected.put(EMITTED_STAT, 3l);
    expected.put(DELETES_IGNORED_STAT, 0l);
    HashMap<String, Long> stats = new HashMap<>();
    collector.summarize(stats::put);
    Assert.assertEquals(expected, stats);
    CounterSummary csum = new CounterSummary(stats);
    Assert.assertEquals(0, csum.getIgnored());
    Assert.assertEquals(0, csum.getTooMany());
    Assert.assertEquals(0, csum.getTooLong());
    Assert.assertEquals(3, csum.getSeen());
    Assert.assertEquals(3, csum.getEmitted());
    Assert.assertEquals(0, csum.getDeletesIgnored());
    expected.clear();
    expected.put("f1", 2l);
    expected.put("f2", 1l);
    Assert.assertEquals(expected, csum.getCounters());
}
Also used : HashMap(java.util.HashMap) CounterSummary(org.apache.accumulo.core.client.summary.CounterSummary) Collector(org.apache.accumulo.core.client.summary.Summarizer.Collector) Value(org.apache.accumulo.core.data.Value) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration) FamilySummarizer(org.apache.accumulo.core.client.summary.summarizers.FamilySummarizer) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 10 with Collector

use of org.apache.accumulo.core.client.summary.Summarizer.Collector in project accumulo by apache.

the class EntryLengthSummarizersTest method testEmpty.

/* COLLECTOR TEST */
/* Basic Test: Each test adds to the next, all are simple lengths. */
@Test
public void testEmpty() {
    SummarizerConfiguration sc = SummarizerConfiguration.builder(EntryLengthSummarizer.class).build();
    EntryLengthSummarizer entrySum = new EntryLengthSummarizer();
    Collector collector = entrySum.collector(sc);
    HashMap<String, Long> stats = new HashMap<>();
    collector.summarize(stats::put);
    HashMap<String, Long> expected = new HashMap<>();
    expected.put("key.min", 0L);
    expected.put("key.max", 0L);
    expected.put("key.sum", 0L);
    expected.put("row.min", 0L);
    expected.put("row.max", 0L);
    expected.put("row.sum", 0L);
    expected.put("family.min", 0L);
    expected.put("family.max", 0L);
    expected.put("family.sum", 0L);
    expected.put("qualifier.min", 0L);
    expected.put("qualifier.max", 0L);
    expected.put("qualifier.sum", 0L);
    expected.put("visibility.min", 0L);
    expected.put("visibility.max", 0L);
    expected.put("visibility.sum", 0L);
    expected.put("value.min", 0L);
    expected.put("value.max", 0L);
    expected.put("value.sum", 0L);
    expected.put("total", 0L);
    Assert.assertEquals(expected, stats);
}
Also used : HashMap(java.util.HashMap) EntryLengthSummarizer(org.apache.accumulo.core.client.summary.summarizers.EntryLengthSummarizer) Collector(org.apache.accumulo.core.client.summary.Summarizer.Collector) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)19 Collector (org.apache.accumulo.core.client.summary.Summarizer.Collector)19 SummarizerConfiguration (org.apache.accumulo.core.client.summary.SummarizerConfiguration)19 Test (org.junit.Test)19 Key (org.apache.accumulo.core.data.Key)18 Value (org.apache.accumulo.core.data.Value)18 EntryLengthSummarizer (org.apache.accumulo.core.client.summary.summarizers.EntryLengthSummarizer)16 CounterSummary (org.apache.accumulo.core.client.summary.CounterSummary)3 Combiner (org.apache.accumulo.core.client.summary.Summarizer.Combiner)3 FamilySummarizer (org.apache.accumulo.core.client.summary.summarizers.FamilySummarizer)3 CountingSummarizer (org.apache.accumulo.core.client.summary.CountingSummarizer)2 Summarizer (org.apache.accumulo.core.client.summary.Summarizer)2 VisibilitySummarizer (org.apache.accumulo.core.client.summary.summarizers.VisibilitySummarizer)2