Search in sources :

Example 1 with FamilySummarizer

use of org.apache.accumulo.core.client.summary.summarizers.FamilySummarizer in project accumulo by apache.

the class CountingSummarizerTest method testSummarizing.

@Test
public void testSummarizing() {
    SummarizerConfiguration sc = SummarizerConfiguration.builder(FamilySummarizer.class).addOptions(MAX_COUNTERS_OPT, "5", MAX_COUNTER_LEN_OPT, "10").build();
    FamilySummarizer countSum = new FamilySummarizer();
    Value val = new Value("abc");
    Summarizer.Collector collector = countSum.collector(sc);
    for (String fam : Arrays.asList("f1", "f1", "f1", "f2", "f1", "f70000000000000000000", "f70000000000000000001", "f2", "f3", "f4", "f5", "f6", "f7", "f3", "f7")) {
        collector.accept(new Key("r", fam), val);
    }
    Key dk = new Key("r", "f2");
    dk.setDeleted(true);
    collector.accept(dk, new Value(""));
    HashMap<String, Long> stats = new HashMap<>();
    collector.summarize((k, v) -> stats.put(k, v));
    String p = COUNTER_STAT_PREFIX;
    HashMap<String, Long> expected = new HashMap<>();
    expected.put(p + "f1", 4l);
    expected.put(p + "f2", 2l);
    expected.put(p + "f3", 2l);
    expected.put(p + "f4", 1l);
    expected.put(p + "f5", 1l);
    expected.put(TOO_LONG_STAT, 2l);
    expected.put(TOO_MANY_STAT, 3l);
    expected.put(SEEN_STAT, 16l);
    expected.put(EMITTED_STAT, 15l);
    expected.put(DELETES_IGNORED_STAT, 1l);
    Assert.assertEquals(expected, stats);
    CounterSummary csum = new CounterSummary(stats);
    Assert.assertEquals(5, csum.getIgnored());
    Assert.assertEquals(3, csum.getTooMany());
    Assert.assertEquals(2, csum.getTooLong());
    Assert.assertEquals(16, csum.getSeen());
    Assert.assertEquals(15, csum.getEmitted());
    Assert.assertEquals(1, csum.getDeletesIgnored());
    expected.clear();
    expected.put("f1", 4l);
    expected.put("f2", 2l);
    expected.put("f3", 2l);
    expected.put("f4", 1l);
    expected.put("f5", 1l);
    Assert.assertEquals(expected, csum.getCounters());
}
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) FamilySummarizer(org.apache.accumulo.core.client.summary.summarizers.FamilySummarizer) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 2 with FamilySummarizer

use of org.apache.accumulo.core.client.summary.summarizers.FamilySummarizer 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)

Aggregations

HashMap (java.util.HashMap)2 CounterSummary (org.apache.accumulo.core.client.summary.CounterSummary)2 Collector (org.apache.accumulo.core.client.summary.Summarizer.Collector)2 SummarizerConfiguration (org.apache.accumulo.core.client.summary.SummarizerConfiguration)2 FamilySummarizer (org.apache.accumulo.core.client.summary.summarizers.FamilySummarizer)2 Key (org.apache.accumulo.core.data.Key)2 Value (org.apache.accumulo.core.data.Value)2 Test (org.junit.Test)2 CountingSummarizer (org.apache.accumulo.core.client.summary.CountingSummarizer)1 Summarizer (org.apache.accumulo.core.client.summary.Summarizer)1 VisibilitySummarizer (org.apache.accumulo.core.client.summary.summarizers.VisibilitySummarizer)1