Search in sources :

Example 36 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class MergeInfo method readFields.

@Override
public void readFields(DataInput in) throws IOException {
    extent = new KeyExtent();
    extent.readFields(in);
    state = MergeState.values()[in.readInt()];
    operation = Operation.values()[in.readInt()];
}
Also used : KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent)

Example 37 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class TwoTierCompactionStrategyTest method testDefaultCompaction.

@Test
public void testDefaultCompaction() throws IOException {
    ttcs.init(opts);
    conf = DefaultConfiguration.getInstance();
    KeyExtent ke = new KeyExtent(Table.ID.of("0"), null, null);
    mcr = new MajorCompactionRequest(ke, MajorCompactionReason.NORMAL, conf);
    Map<FileRef, DataFileValue> fileMap = createFileMap("f1", "10M", "f2", "10M", "f3", "10M", "f4", "10M", "f5", "100M", "f6", "100M", "f7", "100M", "f8", "100M");
    mcr.setFiles(fileMap);
    Assert.assertTrue(ttcs.shouldCompact(mcr));
    Assert.assertEquals(8, mcr.getFiles().size());
    List<FileRef> filesToCompact = ttcs.getCompactionPlan(mcr).inputFiles;
    Assert.assertEquals(fileMap.keySet(), new HashSet<>(filesToCompact));
    Assert.assertEquals(8, filesToCompact.size());
    Assert.assertEquals(null, ttcs.getCompactionPlan(mcr).writeParameters.getCompressType());
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) FileRef(org.apache.accumulo.server.fs.FileRef) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Test(org.junit.Test)

Example 38 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class TabletLocatorImplTest method createMetaCacheKE.

static TreeMap<KeyExtent, TabletLocation> createMetaCacheKE(Object... data) {
    TreeMap<KeyExtent, TabletLocation> mcke = new TreeMap<>();
    for (int i = 0; i < data.length; i += 2) {
        KeyExtent ke = (KeyExtent) data[i];
        String loc = (String) data[i + 1];
        mcke.put(ke, new TabletLocation(ke, loc, "1"));
    }
    return mcke;
}
Also used : TabletLocation(org.apache.accumulo.core.client.impl.TabletLocator.TabletLocation) TreeMap(java.util.TreeMap) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent)

Example 39 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class TabletLocatorImplTest method testBinSplit.

@Test
public void testBinSplit() throws Exception {
    for (int i = 0; i < 3; i++) {
        // when i == 0 only test binning mutations
        // when i == 1 only test binning ranges
        // when i == 2 test both
        KeyExtent ke1 = nke("foo", null, null);
        TServers tservers = new TServers();
        TabletLocatorImpl metaCache = createLocators(tservers, "tserver1", "tserver2", "foo", ke1, "l1");
        List<Mutation> ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("m", "cf1:cq1=v3", "cf1:cq2=v4"), nm("z", "cf1:cq1=v5"));
        Map<String, Map<KeyExtent, List<String>>> emb = cemb(nol("a", "l1", ke1), nol("m", "l1", ke1), nol("z", "l1", ke1));
        if (i == 0 || i == 2)
            runTest(metaCache, ml, emb);
        List<Range> ranges = nrl(new Range(new Text("a")), new Range(new Text("m")), new Range(new Text("z")));
        Map<String, Map<KeyExtent, List<Range>>> expected1 = createExpectedBinnings("l1", nol(nke("foo", null, null), ranges));
        if (i == 1 || i == 2)
            runTest(new Text("foo"), ranges, metaCache, expected1);
        KeyExtent ke11 = nke("foo", "n", null);
        KeyExtent ke12 = nke("foo", null, "n");
        setLocation(tservers, "tserver2", MTE, ke12, "l2");
        metaCache.invalidateCache(ke1);
        emb = cemb(nol("z", "l2", ke12));
        if (i == 0 || i == 2)
            runTest(metaCache, ml, emb, "a", "m");
        Map<String, Map<KeyExtent, List<Range>>> expected2 = createExpectedBinnings("l2", nol(nke("foo", null, "n"), nrl(new Range(new Text("z")))));
        if (i == 1 || i == 2)
            runTest(new Text("foo"), ranges, metaCache, expected2, nrl(new Range(new Text("a")), new Range(new Text("m"))));
        setLocation(tservers, "tserver2", MTE, ke11, "l3");
        emb = cemb(nol("a", "l3", ke11), nol("m", "l3", ke11), nol("z", "l2", ke12));
        if (i == 0 || i == 2)
            runTest(metaCache, ml, emb);
        Map<String, Map<KeyExtent, List<Range>>> expected3 = createExpectedBinnings("l2", nol(nke("foo", null, "n"), nrl(new Range(new Text("z")))), "l3", nol(nke("foo", "n", null), nrl(new Range(new Text("a")), new Range(new Text("m")))));
        if (i == 1 || i == 2)
            runTest(new Text("foo"), ranges, metaCache, expected3);
    }
}
Also used : Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Mutation(org.apache.accumulo.core.data.Mutation) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Test(org.junit.Test)

Example 40 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class TabletLocatorImplTest method testBinMutations1.

@Test
public void testBinMutations1() throws Exception {
    // one tablet table
    KeyExtent ke1 = nke("foo", null, null);
    TabletLocatorImpl metaCache = createLocators("foo", ke1, "l1");
    List<Mutation> ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("c", "cf1:cq1=v3", "cf1:cq2=v4"));
    Map<String, Map<KeyExtent, List<String>>> emb = cemb(nol("a", "l1", ke1), nol("c", "l1", ke1));
    runTest(metaCache, ml, emb);
    ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"));
    emb = cemb(nol("a", "l1", ke1));
    runTest(metaCache, ml, emb);
    ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("a", "cf1:cq3=v3"));
    emb = cemb(nol("a", "l1", ke1), nol("a", "l1", ke1));
    runTest(metaCache, ml, emb);
}
Also used : Mutation(org.apache.accumulo.core.data.Mutation) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Test(org.junit.Test)

Aggregations

KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)142 Text (org.apache.hadoop.io.Text)54 Value (org.apache.accumulo.core.data.Value)47 Key (org.apache.accumulo.core.data.Key)43 Test (org.junit.Test)41 ArrayList (java.util.ArrayList)37 HashMap (java.util.HashMap)33 Range (org.apache.accumulo.core.data.Range)32 TreeMap (java.util.TreeMap)27 Scanner (org.apache.accumulo.core.client.Scanner)27 Mutation (org.apache.accumulo.core.data.Mutation)27 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)21 HashSet (java.util.HashSet)20 IOException (java.io.IOException)19 List (java.util.List)19 Table (org.apache.accumulo.core.client.impl.Table)19 MetadataTable (org.apache.accumulo.core.metadata.MetadataTable)19 AccumuloException (org.apache.accumulo.core.client.AccumuloException)18 PartialKey (org.apache.accumulo.core.data.PartialKey)17 TKeyExtent (org.apache.accumulo.core.data.thrift.TKeyExtent)17