Search in sources :

Example 1 with EntryLengthSummarizer

use of org.apache.accumulo.core.client.summary.summarizers.EntryLengthSummarizer 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);
}
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 2 with EntryLengthSummarizer

use of org.apache.accumulo.core.client.summary.summarizers.EntryLengthSummarizer 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);
}
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 3 with EntryLengthSummarizer

use of org.apache.accumulo.core.client.summary.summarizers.EntryLengthSummarizer 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);
}
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) Combiner(org.apache.accumulo.core.client.summary.Summarizer.Combiner) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 4 with EntryLengthSummarizer

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

the class EntryLengthSummarizersTest method testAll.

/* Miscellaneous Test */
@Test
public void testAll() {
    SummarizerConfiguration sc = SummarizerConfiguration.builder(EntryLengthSummarizer.class).build();
    EntryLengthSummarizer entrySum = new EntryLengthSummarizer();
    Key k1 = new Key("maximumnoqualifier", "f1", "q", "vis1");
    Key k2 = new Key("minKey", "fam2", "q2", "visibility2");
    Key k3 = new Key("row3", "f3", "qualifier3", "v3");
    Key k4 = new Key("r4", "family4", "qual4", "vis4");
    Key k5 = new Key("fifthrow", "thirdfamily", "q5", "v5");
    Key k6 = new Key("r6", "sixthfamily", "qual6", "visibi6");
    Collector collector = entrySum.collector(sc);
    collector.accept(k1, new Value("v1"));
    collector.accept(k2, new Value("value2"));
    collector.accept(k3, new Value("val3"));
    collector.accept(k4, new Value("fourthvalue"));
    collector.accept(k5, new Value(""));
    collector.accept(k6, new Value("value6"));
    HashMap<String, Long> stats = new HashMap<>();
    collector.summarize(stats::put);
    HashMap<String, Long> expected = new HashMap<>();
    expected.put("key.min", 18L);
    expected.put("key.max", 25L);
    expected.put("key.sum", 132L);
    // Log2 Histogram
    expected.put("key.logHist.4", 2L);
    expected.put("key.logHist.5", 4L);
    expected.put("row.min", 2L);
    expected.put("row.max", 18L);
    expected.put("row.sum", 40L);
    // Log2 Histogram
    expected.put("row.logHist.1", 2L);
    expected.put("row.logHist.2", 1L);
    expected.put("row.logHist.3", 2L);
    expected.put("row.logHist.4", 1L);
    expected.put("family.min", 2L);
    expected.put("family.max", 11L);
    expected.put("family.sum", 37L);
    // Log2 Histogram
    expected.put("family.logHist.1", 2L);
    expected.put("family.logHist.2", 1L);
    expected.put("family.logHist.3", 3L);
    expected.put("qualifier.min", 1L);
    expected.put("qualifier.max", 10L);
    expected.put("qualifier.sum", 25L);
    // Log2 Histogram
    expected.put("qualifier.logHist.0", 1L);
    expected.put("qualifier.logHist.1", 2L);
    expected.put("qualifier.logHist.2", 2L);
    expected.put("qualifier.logHist.3", 1L);
    expected.put("visibility.min", 2L);
    expected.put("visibility.max", 11L);
    expected.put("visibility.sum", 30L);
    // Log2 Histogram
    expected.put("visibility.logHist.1", 2L);
    expected.put("visibility.logHist.2", 2L);
    expected.put("visibility.logHist.3", 2L);
    expected.put("value.min", 0L);
    expected.put("value.max", 11L);
    expected.put("value.sum", 29L);
    // Log2 Histogram
    expected.put("value.logHist.0", 1L);
    expected.put("value.logHist.1", 1L);
    expected.put("value.logHist.2", 1L);
    expected.put("value.logHist.3", 3L);
    expected.put("total", 6L);
    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 5 with EntryLengthSummarizer

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

Aggregations

HashMap (java.util.HashMap)16 Collector (org.apache.accumulo.core.client.summary.Summarizer.Collector)16 SummarizerConfiguration (org.apache.accumulo.core.client.summary.SummarizerConfiguration)16 EntryLengthSummarizer (org.apache.accumulo.core.client.summary.summarizers.EntryLengthSummarizer)16 Test (org.junit.Test)16 Key (org.apache.accumulo.core.data.Key)15 Value (org.apache.accumulo.core.data.Value)15 Combiner (org.apache.accumulo.core.client.summary.Summarizer.Combiner)3