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();
}
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();
}
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();
}
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();
}
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());
}
Aggregations