use of org.apache.accumulo.core.client.summary.SummarizerConfiguration 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());
}
use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class CountingSummarizerTest method testMerge.
@Test
public void testMerge() {
SummarizerConfiguration sc = SummarizerConfiguration.builder(VisibilitySummarizer.class).addOption(MAX_COUNTERS_OPT, "5").build();
VisibilitySummarizer countSum = new VisibilitySummarizer();
String p = COUNTER_STAT_PREFIX;
HashMap<String, Long> sm1 = new HashMap<>();
sm1.put(p + "f001", 9l);
sm1.put(p + "f002", 4l);
sm1.put(p + "f003", 2l);
sm1.put(p + "f004", 1l);
sm1.put(p + "f005", 19l);
sm1.put(EMITTED_STAT, 15l);
sm1.put(SEEN_STAT, 5l);
sm1.put(DELETES_IGNORED_STAT, 1l);
HashMap<String, Long> sm2 = new HashMap<>();
sm2.put(p + "f001", 1l);
sm2.put(p + "f002", 2l);
sm2.put(p + "f00a", 7l);
sm2.put(p + "f00b", 1l);
sm2.put(p + "f00c", 17l);
sm2.put(EMITTED_STAT, 18l);
sm2.put(SEEN_STAT, 6l);
sm2.put(DELETES_IGNORED_STAT, 2l);
countSum.combiner(sc).merge(sm1, sm2);
HashMap<String, Long> expected = new HashMap<>();
expected.put(p + "f001", 10l);
expected.put(p + "f002", 6l);
expected.put(p + "f005", 19l);
expected.put(p + "f00a", 7l);
expected.put(p + "f00c", 17l);
expected.put(TOO_LONG_STAT, 0l);
expected.put(TOO_MANY_STAT, 4l);
expected.put(EMITTED_STAT, 18l + 15l);
expected.put(SEEN_STAT, 6l + 5l);
expected.put(DELETES_IGNORED_STAT, 3l);
Assert.assertEquals(expected, sm1);
sm2.clear();
sm2.put(p + "f001", 19l);
sm2.put(p + "f002", 2l);
sm2.put(p + "f003", 3l);
sm2.put(p + "f00b", 13l);
sm2.put(p + "f00c", 2l);
sm2.put(TOO_LONG_STAT, 1l);
sm2.put(TOO_MANY_STAT, 3l);
sm2.put(EMITTED_STAT, 21l);
sm2.put(SEEN_STAT, 7l);
sm2.put(DELETES_IGNORED_STAT, 5l);
countSum.combiner(sc).merge(sm1, sm2);
expected.clear();
expected.put(p + "f001", 29l);
expected.put(p + "f002", 8l);
expected.put(p + "f005", 19l);
expected.put(p + "f00b", 13l);
expected.put(p + "f00c", 19l);
expected.put(TOO_LONG_STAT, 1l);
expected.put(TOO_MANY_STAT, 17l);
expected.put(EMITTED_STAT, 21l + 18 + 15);
expected.put(SEEN_STAT, 7l + 6 + 5);
expected.put(DELETES_IGNORED_STAT, 8l);
}
use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class EntryLengthSummarizersTest method testComplexVisibility.
@Test
public void testComplexVisibility() {
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(""));
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", 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", 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);
}
use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class EntryLengthSummarizersTest method testBasicFamily.
@Test
public void testBasicFamily() {
SummarizerConfiguration sc = SummarizerConfiguration.builder(EntryLengthSummarizer.class).build();
EntryLengthSummarizer entrySum = new EntryLengthSummarizer();
Key k1 = new Key("r1", "f1");
Key k2 = new Key("r2", "f2");
Key k3 = new Key("r3", "f3");
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", 4L);
expected.put("key.max", 4L);
expected.put("key.sum", 12L);
// Log2 Histogram
expected.put("key.logHist.2", 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", 2L);
expected.put("family.max", 2L);
expected.put("family.sum", 6L);
// Log2 Histogram
expected.put("family.logHist.1", 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);
}
use of org.apache.accumulo.core.client.summary.SummarizerConfiguration in project accumulo by apache.
the class EntryLengthSummarizersTest method testCombine2.
@Test
public void testCombine2() {
SummarizerConfiguration sc = SummarizerConfiguration.builder(EntryLengthSummarizer.class).build();
EntryLengthSummarizer entrySum = new EntryLengthSummarizer();
Collector collector1 = entrySum.collector(sc);
collector1.accept(new Key("12345678901234567890", "f12345", "q123456"), new Value("value1234567890"));
HashMap<String, Long> stats1 = new HashMap<>();
collector1.summarize(stats1::put);
Collector collector2 = entrySum.collector(sc);
collector2.accept(new Key("5432", "f11", "q12"), new Value("2"));
collector2.accept(new Key("12", "f11", "q1234"), new Value("12"));
collector2.accept(new Key("12", "f11", "q11234567"), new Value("4444"));
HashMap<String, Long> stats2 = new HashMap<>();
collector2.summarize(stats2::put);
Combiner combiner = entrySum.combiner(sc);
combiner.merge(stats1, stats2);
HashMap<String, Long> expected = new HashMap<>();
expected.put("key.min", 10L);
expected.put("key.max", 33L);
expected.put("key.sum", 67L);
// Log2 Histogram for Key
expected.put("key.logHist.3", 2L);
expected.put("key.logHist.4", 1L);
expected.put("key.logHist.5", 1L);
expected.put("row.min", 2L);
expected.put("row.max", 20L);
expected.put("row.sum", 28L);
// Log2 Histogram for Row
expected.put("row.logHist.1", 2L);
expected.put("row.logHist.2", 1L);
expected.put("row.logHist.4", 1L);
expected.put("family.min", 3L);
expected.put("family.max", 6L);
expected.put("family.sum", 15L);
// Log2 Histogram for Family
expected.put("family.logHist.2", 3L);
expected.put("family.logHist.3", 1L);
expected.put("qualifier.min", 3L);
expected.put("qualifier.max", 9L);
expected.put("qualifier.sum", 24L);
// Log2 Histogram for Qualifier
expected.put("qualifier.logHist.2", 2L);
expected.put("qualifier.logHist.3", 2L);
expected.put("visibility.min", 0L);
expected.put("visibility.max", 0L);
expected.put("visibility.sum", 0L);
// Log2 Histogram for Visibility
expected.put("visibility.logHist.0", 4L);
expected.put("value.min", 1L);
expected.put("value.max", 15L);
expected.put("value.sum", 22L);
// Log2 Histogram for Value
expected.put("value.logHist.0", 1L);
expected.put("value.logHist.1", 1L);
expected.put("value.logHist.2", 1L);
expected.put("value.logHist.4", 1L);
expected.put("total", 4L);
Assert.assertEquals(expected, stats1);
}
Aggregations