Search in sources :

Example 66 with KeyExtent

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));
}
Also used : KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Test(org.junit.Test)

Example 67 with KeyExtent

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));
}
Also used : KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Test(org.junit.Test)

Example 68 with KeyExtent

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));
}
Also used : Text(org.apache.hadoop.io.Text) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Test(org.junit.Test)

Example 69 with KeyExtent

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);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) FileSKVWriter(org.apache.accumulo.core.file.FileSKVWriter) Text(org.apache.hadoop.io.Text) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) MockServerContext(org.apache.accumulo.server.MockServerContext) ServerContext(org.apache.accumulo.server.ServerContext) TabletLocation(org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocation) FileSystem(org.apache.hadoop.fs.FileSystem) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 70 with KeyExtent

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));
}
Also used : Text(org.apache.hadoop.io.Text) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Test(org.junit.Test)

Aggregations

KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)239 Text (org.apache.hadoop.io.Text)98 ArrayList (java.util.ArrayList)72 HashMap (java.util.HashMap)60 Value (org.apache.accumulo.core.data.Value)57 Key (org.apache.accumulo.core.data.Key)56 TableId (org.apache.accumulo.core.data.TableId)53 Test (org.junit.Test)52 Mutation (org.apache.accumulo.core.data.Mutation)47 IOException (java.io.IOException)40 List (java.util.List)40 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)39 HashSet (java.util.HashSet)38 TreeMap (java.util.TreeMap)38 Range (org.apache.accumulo.core.data.Range)38 Map (java.util.Map)33 Scanner (org.apache.accumulo.core.client.Scanner)31 Entry (java.util.Map.Entry)30 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)30 Test (org.junit.jupiter.api.Test)30