use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class VisMetricsGatherer method startLocalityGroup.
@Override
public void startLocalityGroup(Text oneCF) {
String name = null;
ByteSequence cf = new ArrayByteSequence(oneCF.toString());
for (Entry<String, ArrayList<ByteSequence>> entry : localityGroupCF.entrySet()) {
if (entry.getValue().contains(cf)) {
if (entry.getKey() == null)
name = null;
else
name = entry.getKey().toString();
break;
}
}
localityGroups.add(name);
metric.put(name, AtomicLongMap.create(new HashMap<>()));
blocks.put(name, AtomicLongMap.create(new HashMap<>()));
numLG++;
numEntries.add((long) 0);
numBlocks.add(0);
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RFileMetricsTest method twoEntryNonDefaultLocGroup.
@Test
public void twoEntryNonDefaultLocGroup() throws IOException {
// test an rfile with two entries in a non-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", "cq1", "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(1, metrics.get("L1"));
assertEquals(1, metrics.get("L2"));
assertEquals(1, blocks.get("L1"));
assertEquals(1, blocks.get("L2"));
assertEquals(2, vmg.numEntries.get(vmg.localityGroups.indexOf("lg1")).longValue());
assertEquals(1, 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 twoNonDefaultLocGroups.
@Test
public void twoNonDefaultLocGroups() throws IOException {
// test an rfile with two entries in 2 non-default locality groups
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", "cq1", "L2", 55), RFileTest.newValue("foo"));
Set<ByteSequence> lg2 = new HashSet<>();
lg2.add(new ArrayByteSequence("cf2"));
trf.writer.startNewLocalityGroup("lg2", lg2);
trf.writer.append(RFileTest.newKey("r1", "cf2", "cq1", "L1", 55), RFileTest.newValue("foo"));
trf.writer.append(RFileTest.newKey("r1", "cf2", "cq1", "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(1, metrics.get("L1"));
assertEquals(1, metrics.get("L2"));
assertEquals(1, blocks.get("L1"));
assertEquals(1, blocks.get("L2"));
assertEquals(2, vmg.numEntries.get(vmg.localityGroups.indexOf("lg1")).longValue());
assertEquals(1, vmg.numBlocks.get(vmg.localityGroups.indexOf("lg1")).longValue());
metrics = vmg.metric.get("lg2");
blocks = vmg.blocks.get("lg2");
assertEquals(1, metrics.get("L1"));
assertEquals(1, metrics.get("L2"));
assertEquals(1, blocks.get("L1"));
assertEquals(1, blocks.get("L2"));
assertEquals(2, vmg.numEntries.get(vmg.localityGroups.indexOf("lg2")).longValue());
assertEquals(1, vmg.numBlocks.get(vmg.localityGroups.indexOf("lg2")).longValue());
trf.closeReader();
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RFileTest method t18Append.
private void t18Append(TestRFile trf, HashSet<ByteSequence> allCf, int i) throws IOException {
String cf = t18ncf(i);
trf.writer.append(newKey("r0000", cf, "cq1", "", 1), newValue("" + i));
allCf.add(new ArrayByteSequence(cf));
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RFileTest method testLocalityGroups.
@Test
public void testLocalityGroups() throws Exception {
SortedMap<Key, Value> testData1 = createTestData(0, 10, 0, 2, 10);
SortedMap<Key, Value> testData2 = createTestData(0, 10, 2, 1, 10);
SortedMap<Key, Value> defaultData = createTestData(0, 10, 3, 7, 10);
LocalFileSystem localFs = FileSystem.getLocal(new Configuration());
String testFile = createTmpTestFile();
RFileWriter writer = RFile.newWriter().to(testFile).withFileSystem(localFs).build();
writer.startNewLocalityGroup("z", colStr(0), colStr(1));
writer.append(testData1.entrySet());
writer.startNewLocalityGroup("h", colStr(2));
writer.append(testData2.entrySet());
writer.startDefaultLocalityGroup();
writer.append(defaultData.entrySet());
writer.close();
Scanner scanner = RFile.newScanner().from(testFile).withFileSystem(localFs).build();
scanner.fetchColumnFamily(new Text(colStr(0)));
scanner.fetchColumnFamily(new Text(colStr(1)));
Assert.assertEquals(testData1, toMap(scanner));
scanner.clearColumns();
scanner.fetchColumnFamily(new Text(colStr(2)));
Assert.assertEquals(testData2, toMap(scanner));
scanner.clearColumns();
for (int i = 3; i < 10; i++) {
scanner.fetchColumnFamily(new Text(colStr(i)));
}
Assert.assertEquals(defaultData, toMap(scanner));
scanner.clearColumns();
Assert.assertEquals(createTestData(10, 10, 10), toMap(scanner));
scanner.close();
Reader reader = getReader(localFs, testFile);
Map<String, ArrayList<ByteSequence>> lGroups = reader.getLocalityGroupCF();
Assert.assertTrue(lGroups.containsKey("z"));
Assert.assertTrue(lGroups.get("z").size() == 2);
Assert.assertTrue(lGroups.get("z").contains(new ArrayByteSequence(colStr(0))));
Assert.assertTrue(lGroups.get("z").contains(new ArrayByteSequence(colStr(1))));
Assert.assertTrue(lGroups.containsKey("h"));
Assert.assertEquals(Arrays.asList(new ArrayByteSequence(colStr(2))), lGroups.get("h"));
reader.close();
}
Aggregations