Search in sources :

Example 26 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class RFileMetricsTest method multiCFNonDefaultAndDefaultLocGroup.

@Test
public void multiCFNonDefaultAndDefaultLocGroup() throws IOException {
    // test an rfile with multiple column families in a non-default locality group and the default locality group
    trf.openWriter(false);
    Set<ByteSequence> lg1 = new HashSet<>();
    lg1.add(new ArrayByteSequence("cf1"));
    lg1.add(new ArrayByteSequence("cf3"));
    trf.writer.startNewLocalityGroup("lg1", lg1);
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq1", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq2", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf3", "cq1", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf3", "cq2", "L2", 55), RFileTest.newValue("foo"));
    trf.writer.startDefaultLocalityGroup();
    trf.writer.append(RFileTest.newKey("r1", "cf2", "cq1", "A", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf2", "cq1", "B", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf4", "cq1", "A", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf4", "cq1", "B", 55), RFileTest.newValue("foo"));
    trf.closeWriter();
    trf.openReader(false);
    VisMetricsGatherer vmg = trf.gatherMetrics();
    AtomicLongMap<String> metrics = vmg.metric.get("lg1");
    AtomicLongMap<String> blocks = vmg.blocks.get("lg1");
    assertEquals(3, metrics.get("L1"));
    assertEquals(1, metrics.get("L2"));
    assertEquals(1, blocks.get("L1"));
    assertEquals(1, blocks.get("L2"));
    assertEquals(4, vmg.numEntries.get(vmg.localityGroups.indexOf("lg1")).longValue());
    assertEquals(1, vmg.numBlocks.get(vmg.localityGroups.indexOf("lg1")).longValue());
    metrics = vmg.metric.get(null);
    blocks = vmg.blocks.get(null);
    assertEquals(2, metrics.get("A"));
    assertEquals(2, metrics.get("B"));
    assertEquals(1, blocks.get("A"));
    assertEquals(1, blocks.get("B"));
    assertEquals(4, vmg.numEntries.get(vmg.localityGroups.indexOf(null)).longValue());
    assertEquals(1, vmg.numBlocks.get(vmg.localityGroups.indexOf(null)).longValue());
    trf.closeReader();
}
Also used : ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class RFileMetricsTest method nonDefaultAndDefaultLocGroup.

@Test
public void nonDefaultAndDefaultLocGroup() throws IOException {
    // test an rfile with 3 entries in a non-default locality group and the default locality group
    trf.openWriter(false);
    Set<ByteSequence> lg1 = new HashSet<>();
    lg1.add(new ArrayByteSequence("cf1"));
    trf.writer.startNewLocalityGroup("lg1", lg1);
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq1", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq2", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq2", "L2", 55), RFileTest.newValue("foo"));
    trf.writer.startDefaultLocalityGroup();
    trf.writer.append(RFileTest.newKey("r1", "cf2", "cq1", "A", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf2", "cq1", "B", 55), RFileTest.newValue("foo"));
    trf.closeWriter();
    trf.openReader(false);
    VisMetricsGatherer vmg = trf.gatherMetrics();
    AtomicLongMap<String> metrics = vmg.metric.get("lg1");
    AtomicLongMap<String> blocks = vmg.blocks.get("lg1");
    assertEquals(2, metrics.get("L1"));
    assertEquals(1, metrics.get("L2"));
    assertEquals(1, blocks.get("L1"));
    assertEquals(1, blocks.get("L2"));
    assertEquals(3, vmg.numEntries.get(vmg.localityGroups.indexOf("lg1")).longValue());
    assertEquals(1, vmg.numBlocks.get(vmg.localityGroups.indexOf("lg1")).longValue());
    metrics = vmg.metric.get(null);
    blocks = vmg.blocks.get(null);
    assertEquals(1, metrics.get("A"));
    assertEquals(1, metrics.get("B"));
    assertEquals(1, blocks.get("A"));
    assertEquals(1, blocks.get("B"));
    assertEquals(2, vmg.numEntries.get(vmg.localityGroups.indexOf(null)).longValue());
    assertEquals(1, vmg.numBlocks.get(vmg.localityGroups.indexOf(null)).longValue());
    trf.closeReader();
}
Also used : ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 28 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class RFileMetricsTest method multiBlockMultiCFNonDefaultAndDefaultLocGroup.

@Test
public void multiBlockMultiCFNonDefaultAndDefaultLocGroup() throws IOException {
    // test an rfile with multiple column families and multiple blocks in a non-default locality group and the default locality group
    // Each entry is a block
    trf.openWriter(false, 10);
    Set<ByteSequence> lg1 = new HashSet<>();
    lg1.add(new ArrayByteSequence("cf1"));
    lg1.add(new ArrayByteSequence("cf3"));
    trf.writer.startNewLocalityGroup("lg1", lg1);
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq1", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq2", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf3", "cq1", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf3", "cq2", "L2", 55), RFileTest.newValue("foo"));
    trf.writer.startDefaultLocalityGroup();
    trf.writer.append(RFileTest.newKey("r1", "cf2", "cq1", "A", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf2", "cq1", "B", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf4", "cq1", "A", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf4", "cq1", "B", 55), RFileTest.newValue("foo"));
    trf.closeWriter();
    trf.openReader(false);
    VisMetricsGatherer vmg = trf.gatherMetrics();
    AtomicLongMap<String> metrics = vmg.metric.get("lg1");
    AtomicLongMap<String> blocks = vmg.blocks.get("lg1");
    assertEquals(3, metrics.get("L1"));
    assertEquals(1, metrics.get("L2"));
    assertEquals(3, blocks.get("L1"));
    assertEquals(1, blocks.get("L2"));
    assertEquals(4, vmg.numEntries.get(vmg.localityGroups.indexOf("lg1")).longValue());
    assertEquals(4, vmg.numBlocks.get(vmg.localityGroups.indexOf("lg1")).longValue());
    metrics = vmg.metric.get(null);
    blocks = vmg.blocks.get(null);
    assertEquals(2, metrics.get("A"));
    assertEquals(2, metrics.get("B"));
    assertEquals(2, blocks.get("A"));
    assertEquals(2, blocks.get("B"));
    assertEquals(4, vmg.numEntries.get(vmg.localityGroups.indexOf(null)).longValue());
    assertEquals(4, vmg.numBlocks.get(vmg.localityGroups.indexOf(null)).longValue());
    trf.closeReader();
}
Also used : ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 29 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class RFileMetricsTest method multiBlockNonDefaultLocGroup.

@Test
public void multiBlockNonDefaultLocGroup() throws IOException {
    // test an rfile with four blocks in a non-default locality group
    // Each entry is a block
    trf.openWriter(false, 20);
    Set<ByteSequence> lg1 = new HashSet<>();
    lg1.add(new ArrayByteSequence("cf1"));
    lg1.add(new ArrayByteSequence("cf3"));
    trf.writer.startNewLocalityGroup("lg1", lg1);
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq1", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf1", "cq2", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf3", "cq1", "L1", 55), RFileTest.newValue("foo"));
    trf.writer.append(RFileTest.newKey("r1", "cf3", "cq2", "L2", 55), RFileTest.newValue("foo"));
    trf.closeWriter();
    trf.openReader(false);
    VisMetricsGatherer vmg = trf.gatherMetrics();
    AtomicLongMap<String> metrics = vmg.metric.get("lg1");
    AtomicLongMap<String> blocks = vmg.blocks.get("lg1");
    assertEquals(3, metrics.get("L1"));
    assertEquals(1, metrics.get("L2"));
    assertEquals(3, blocks.get("L1"));
    assertEquals(1, blocks.get("L2"));
    assertEquals(4, vmg.numEntries.get(vmg.localityGroups.indexOf("lg1")).longValue());
    assertEquals(4, vmg.numBlocks.get(vmg.localityGroups.indexOf("lg1")).longValue());
    trf.closeReader();
}
Also used : ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 30 with ArrayByteSequence

use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.

the class RFileMetricsTest method testManyFamiliesInDefaultLocGroup.

@Test
public void testManyFamiliesInDefaultLocGroup() throws IOException {
    trf.openWriter(false, 1024);
    String fam1 = String.format("%06x", 9000);
    String fam2 = String.format("%06x", 9001);
    Set<ByteSequence> lg1 = new HashSet<>();
    lg1.add(new ArrayByteSequence(fam1));
    lg1.add(new ArrayByteSequence(fam2));
    trf.writer.startNewLocalityGroup("lg1", lg1);
    for (int row = 0; row < 1100; row++) {
        String rs = String.format("%06x", row);
        trf.writer.append(new Key(rs, fam1, "q4", "A", 42l), new Value("v".getBytes()));
        trf.writer.append(new Key(rs, fam2, "q4", "A|B", 42l), new Value("v".getBytes()));
    }
    trf.writer.startDefaultLocalityGroup();
    String[] vis = new String[] { "A", "A&B", "A|C", "B&C", "Boo" };
    int fam = 0;
    for (int row = 0; row < 1000; row++) {
        String rs = String.format("%06x", row);
        for (int v = 0; v < 5; v++) {
            String fs = String.format("%06x", fam++);
            trf.writer.append(new Key(rs, fs, "q4", vis[v], 42l), new Value("v".getBytes()));
        }
    }
    trf.closeWriter();
    trf.openReader(false);
    VisMetricsGatherer vmg = trf.gatherMetrics();
    Map<String, Long> expected = new HashMap<>();
    Map<String, Long> expectedBlocks = new HashMap<>();
    for (String v : vis) {
        expected.put(v, 1000l);
        expectedBlocks.put(v, 71l);
    }
    assertEquals(expected, vmg.metric.get(null).asMap());
    assertEquals(expectedBlocks, vmg.blocks.get(null).asMap());
    expected.clear();
    expectedBlocks.clear();
    expected.put("A", 1100l);
    expected.put("A|B", 1100l);
    expectedBlocks.put("A", 32l);
    expectedBlocks.put("A|B", 32l);
    assertEquals(expected, vmg.metric.get("lg1").asMap());
    assertEquals(expectedBlocks, vmg.blocks.get("lg1").asMap());
    assertEquals(2, vmg.metric.keySet().size());
    assertEquals(2, vmg.blocks.keySet().size());
}
Also used : HashMap(java.util.HashMap) Value(org.apache.accumulo.core.data.Value) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) Key(org.apache.accumulo.core.data.Key) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)39 ByteSequence (org.apache.accumulo.core.data.ByteSequence)26 HashSet (java.util.HashSet)20 Test (org.junit.Test)18 Key (org.apache.accumulo.core.data.Key)10 Value (org.apache.accumulo.core.data.Value)9 Range (org.apache.accumulo.core.data.Range)8 ArrayList (java.util.ArrayList)7 TreeMap (java.util.TreeMap)6 SortedMapIterator (org.apache.accumulo.core.iterators.SortedMapIterator)5 Text (org.apache.hadoop.io.Text)5 HashMap (java.util.HashMap)4 ColumnFamilySkippingIterator (org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator)3 IOException (java.io.IOException)2 Map (java.util.Map)2 Scanner (org.apache.accumulo.core.client.Scanner)2 Mutation (org.apache.accumulo.core.data.Mutation)2 PartialKey (org.apache.accumulo.core.data.PartialKey)2 IterInfo (org.apache.accumulo.core.data.thrift.IterInfo)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1