Search in sources :

Example 11 with KeyExtent

use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.

the class ConcurrentKeyExtentCacheTest method setupSplits.

@BeforeAll
public static void setupSplits() {
    Text prev = null;
    for (int i = 1; i < 255; i++) {
        Text endRow = new Text(String.format("%02x", i));
        extents.add(new KeyExtent(TableId.of("1"), endRow, prev));
        prev = endRow;
    }
    extents.add(new KeyExtent(TableId.of("1"), null, prev));
    extentsSet.addAll(extents);
}
Also used : Text(org.apache.hadoop.io.Text) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 12 with KeyExtent

use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.

the class ConcurrentKeyExtentCacheTest method testLookup.

private void testLookup(TestCache tc, Text lookupRow) {
    KeyExtent extent = tc.lookup(lookupRow);
    assertTrue(extent.contains(lookupRow));
    assertTrue(extentsSet.contains(extent));
}
Also used : KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent)

Example 13 with KeyExtent

use of org.apache.accumulo.core.dataImpl.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.dataImpl.KeyExtent) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Test(org.junit.jupiter.api.Test)

Example 14 with KeyExtent

use of org.apache.accumulo.core.dataImpl.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(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(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(ranges, metaCache, expected3);
    }
}
Also used : Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) KeyExtent(org.apache.accumulo.core.dataImpl.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.jupiter.api.Test)

Example 15 with KeyExtent

use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.

the class TabletLocatorImplTest method createExpectedBinnings.

@SuppressWarnings("unchecked")
static Map<String, Map<KeyExtent, List<Range>>> createExpectedBinnings(Object... data) {
    Map<String, Map<KeyExtent, List<Range>>> expBinnedRanges = new HashMap<>();
    for (int i = 0; i < data.length; i += 2) {
        String loc = (String) data[i];
        Object[] binData = (Object[]) data[i + 1];
        HashMap<KeyExtent, List<Range>> binnedKE = new HashMap<>();
        expBinnedRanges.put(loc, binnedKE);
        for (int j = 0; j < binData.length; j += 2) {
            KeyExtent ke = (KeyExtent) binData[j];
            List<Range> ranges = (List<Range>) binData[j + 1];
            binnedKE.put(ke, ranges);
        }
    }
    return expBinnedRanges;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Range(org.apache.accumulo.core.data.Range) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent)

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