use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class MergeInfoTest method testNeedsToBeChopped_NotDelete.
@Test
public void testNeedsToBeChopped_NotDelete() {
expect(keyExtent.tableId()).andReturn(TableId.of("table1"));
KeyExtent keyExtent2 = createMock(KeyExtent.class);
expect(keyExtent2.tableId()).andReturn(TableId.of("table1"));
replay(keyExtent2);
expect(keyExtent.overlaps(keyExtent2)).andReturn(true);
replay(keyExtent);
mi = new MergeInfo(keyExtent, MergeInfo.Operation.MERGE);
assertTrue(mi.needsToBeChopped(keyExtent2));
}
use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class MergeInfoTest method testNeedsToBeChopped_DifferentTables.
@Test
public void testNeedsToBeChopped_DifferentTables() {
expect(keyExtent.tableId()).andReturn(TableId.of("table1"));
replay(keyExtent);
KeyExtent keyExtent2 = createMock(KeyExtent.class);
expect(keyExtent2.tableId()).andReturn(TableId.of("table2"));
replay(keyExtent2);
mi = new MergeInfo(keyExtent, MergeInfo.Operation.MERGE);
assertFalse(mi.needsToBeChopped(keyExtent2));
}
use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class MergeInfoTest method testOverlaps_NeedsChopping.
@Test
public void testOverlaps_NeedsChopping() {
KeyExtent keyExtent2 = createMock(KeyExtent.class);
expect(keyExtent.overlaps(keyExtent2)).andReturn(false);
expect(keyExtent.tableId()).andReturn(TableId.of("table1"));
expect(keyExtent.endRow()).andReturn(new Text("prev"));
replay(keyExtent);
expect(keyExtent2.tableId()).andReturn(TableId.of("table1"));
expect(keyExtent2.prevEndRow()).andReturn(new Text("prev"));
expectLastCall().anyTimes();
replay(keyExtent2);
mi = new MergeInfo(keyExtent, MergeInfo.Operation.DELETE);
assertTrue(mi.overlaps(keyExtent2));
}
use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class BulkImporterTest method testFindOverlappingTablets.
@Test
public void testFindOverlappingTablets() throws Exception {
MockTabletLocator locator = new MockTabletLocator();
FileSystem fs = FileSystem.getLocal(new Configuration());
ServerContext context = MockServerContext.get();
EasyMock.replay(context);
String file = "target/testFile.rf";
fs.delete(new Path(file), true);
FileSKVWriter writer = FileOperations.getInstance().newWriterBuilder().forFile(file, fs, fs.getConf(), CryptoServiceFactory.newDefaultInstance()).withTableConfiguration(context.getConfiguration()).build();
writer.startDefaultLocalityGroup();
Value empty = new Value();
writer.append(new Key("a", "cf", "cq"), empty);
writer.append(new Key("a", "cf", "cq1"), empty);
writer.append(new Key("a", "cf", "cq2"), empty);
writer.append(new Key("a", "cf", "cq3"), empty);
writer.append(new Key("a", "cf", "cq4"), empty);
writer.append(new Key("a", "cf", "cq5"), empty);
writer.append(new Key("d", "cf", "cq"), empty);
writer.append(new Key("d", "cf", "cq1"), empty);
writer.append(new Key("d", "cf", "cq2"), empty);
writer.append(new Key("d", "cf", "cq3"), empty);
writer.append(new Key("d", "cf", "cq4"), empty);
writer.append(new Key("d", "cf", "cq5"), empty);
writer.append(new Key("dd", "cf", "cq1"), empty);
writer.append(new Key("ichabod", "cf", "cq"), empty);
writer.append(new Key("icky", "cf", "cq1"), empty);
writer.append(new Key("iffy", "cf", "cq2"), empty);
writer.append(new Key("internal", "cf", "cq3"), empty);
writer.append(new Key("is", "cf", "cq4"), empty);
writer.append(new Key("iterator", "cf", "cq5"), empty);
writer.append(new Key("xyzzy", "cf", "cq"), empty);
writer.close();
try (var vm = VolumeManagerImpl.getLocalForTesting("file:///")) {
List<TabletLocation> overlaps = BulkImporter.findOverlappingTablets(context, vm, locator, new Path(file));
assertEquals(5, overlaps.size());
Collections.sort(overlaps);
assertEquals(new KeyExtent(tableId, new Text("a"), null), overlaps.get(0).tablet_extent);
assertEquals(new KeyExtent(tableId, new Text("d"), new Text("cm")), overlaps.get(1).tablet_extent);
assertEquals(new KeyExtent(tableId, new Text("dm"), new Text("d")), overlaps.get(2).tablet_extent);
assertEquals(new KeyExtent(tableId, new Text("j"), new Text("i")), overlaps.get(3).tablet_extent);
assertEquals(new KeyExtent(tableId, null, new Text("l")), overlaps.get(4).tablet_extent);
List<TabletLocation> overlaps2 = BulkImporter.findOverlappingTablets(context, vm, locator, new Path(file), new KeyExtent(tableId, new Text("h"), new Text("b")));
assertEquals(3, overlaps2.size());
assertEquals(new KeyExtent(tableId, new Text("d"), new Text("cm")), overlaps2.get(0).tablet_extent);
assertEquals(new KeyExtent(tableId, new Text("dm"), new Text("d")), overlaps2.get(1).tablet_extent);
assertEquals(new KeyExtent(tableId, new Text("j"), new Text("i")), overlaps2.get(2).tablet_extent);
assertEquals(locator.invalidated, 1);
}
}
use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class BulkImporterTest method testSequentialTablets.
@Test
public void testSequentialTablets() {
// ACCUMULO-3967 make sure that the startRow we compute in BulkImporter is actually giving
// a correct startRow so that findOverlappingTablets works as intended.
// 1;2;1
KeyExtent extent = new KeyExtent(TableId.of("1"), new Text("2"), new Text("1"));
assertEquals(new Text("1\0"), BulkImporter.getStartRowForExtent(extent));
// 1;2<
extent = new KeyExtent(TableId.of("1"), new Text("2"), null);
assertNull(BulkImporter.getStartRowForExtent(extent));
// 1<<
extent = new KeyExtent(TableId.of("1"), null, null);
assertNull(BulkImporter.getStartRowForExtent(extent));
// 1;8;7777777
extent = new KeyExtent(TableId.of("1"), new Text("8"), new Text("7777777"));
assertEquals(new Text("7777777\0"), BulkImporter.getStartRowForExtent(extent));
}
Aggregations