Search in sources :

Example 61 with Authorizations

use of org.apache.accumulo.core.security.Authorizations in project incubator-rya by apache.

the class DocumentIndexIntersectingIteratorTest method testGeneralStarQueryMultipleSubjPrefix.

@Test
public void testGeneralStarQueryMultipleSubjPrefix() throws Exception {
    BatchWriter bw = null;
    bw = accCon.createBatchWriter(tablename, 500L * 1024L * 1024L, Long.MAX_VALUE, 30);
    for (int i = 0; i < 100; i++) {
        Mutation m = new Mutation(new Text("" + i));
        m.put(new Text("cf" + 1), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + 1), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + 2), new Value(new byte[0]));
        m.put(new Text("cf" + 1), new Text(null + "\u0000" + "subj" + "\u0000" + "cq" + 1), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text(null + "\u0000" + "subj" + "\u0000" + "cq" + 2), new Value(new byte[0]));
        if (i == 30 || i == 60 || i == 90 || i == 99) {
            m.put(new Text("cf" + 3), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + 3), new Value(new byte[0]));
            m.put(new Text("cf" + 3), new Text(null + "\u0000" + "subj" + "\u0000" + "cq" + 3), new Value(new byte[0]));
            m.put(new Text("cf" + 3), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + 4), new Value(new byte[0]));
            m.put(new Text("cf" + 3), new Text(null + "\u0000" + "subj" + "\u0000" + "cq" + 4), new Value(new byte[0]));
            m.put(new Text("cf" + 3), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + 5), new Value(new byte[0]));
            m.put(new Text("cf" + 3), new Text(null + "\u0000" + "subj" + "\u0000" + "cq" + 5), new Value(new byte[0]));
        }
        bw.addMutation(m);
    }
    TextColumn tc1 = new TextColumn(new Text("cf" + 1), new Text("obj" + "\u0000" + "cq" + 1));
    TextColumn tc2 = new TextColumn(new Text("cf" + 2), new Text("obj" + "\u0000" + "cq" + 2));
    TextColumn tc3 = new TextColumn(new Text("cf" + 3), new Text("subj"));
    tc3.setIsPrefix(true);
    TextColumn[] tc = new TextColumn[3];
    tc[0] = tc1;
    tc[1] = tc2;
    tc[2] = tc3;
    IteratorSetting is = new IteratorSetting(30, "fii", DocumentIndexIntersectingIterator.class);
    DocumentIndexIntersectingIterator.setColumnFamilies(is, tc);
    Scanner scan = accCon.createScanner(tablename, new Authorizations("auths"));
    scan.addScanIterator(is);
    int results = 0;
    System.out.println("************************Test 12****************************");
    for (Map.Entry<Key, Value> e : scan) {
        System.out.println(e);
        results++;
    }
    Assert.assertEquals(12, results);
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) Text(org.apache.hadoop.io.Text) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 62 with Authorizations

use of org.apache.accumulo.core.security.Authorizations in project incubator-rya by apache.

the class DocumentIndexIntersectingIteratorTest method testOneHundredColumnSubjObjPrefix.

@Test
public void testOneHundredColumnSubjObjPrefix() throws Exception {
    BatchWriter bw = null;
    bw = accCon.createBatchWriter(tablename, 500L * 1024L * 1024L, Long.MAX_VALUE, 30);
    for (int i = 0; i < 100; i++) {
        Mutation m = new Mutation(new Text("" + i));
        for (int j = 0; j < 100; j++) {
            m.put(new Text("cf" + j), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + j), new Value(new byte[0]));
        }
        if (i == 30 || i == 60 || i == 90 || i == 99) {
            m.put(new Text("cf" + 100), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + (100 + i)), new Value(new byte[0]));
            m.put(new Text("cf" + 100), new Text(null + "\u0000" + "subj" + "\u0000" + "cq" + (100 + i + 1)), new Value(new byte[0]));
        }
        bw.addMutation(m);
    }
    DocumentIndexIntersectingIterator dii = new DocumentIndexIntersectingIterator();
    TextColumn tc1 = new TextColumn(new Text("cf" + 20), new Text("obj" + "\u0000" + "cq" + 20));
    TextColumn tc2 = new TextColumn(new Text("cf" + 50), new Text("obj" + "\u0000" + "cq" + 50));
    TextColumn tc3 = new TextColumn(new Text("cf" + 100), new Text("subj"));
    tc3.setIsPrefix(true);
    TextColumn[] tc = new TextColumn[3];
    tc[0] = tc1;
    tc[1] = tc2;
    tc[2] = tc3;
    IteratorSetting is = new IteratorSetting(30, "fii", DocumentIndexIntersectingIterator.class);
    dii.setColumnFamilies(is, tc);
    Scanner scan = accCon.createScanner(tablename, new Authorizations("auths"));
    scan.addScanIterator(is);
    int results = 0;
    System.out.println("************************Test 7****************************");
    for (Map.Entry<Key, Value> e : scan) {
        System.out.println(e);
        results++;
    }
    Assert.assertEquals(4, results);
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) Text(org.apache.hadoop.io.Text) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 63 with Authorizations

use of org.apache.accumulo.core.security.Authorizations in project incubator-rya by apache.

the class DocumentIndexIntersectingIteratorTest method testContext6.

@Test
public void testContext6() throws Exception {
    BatchWriter bw = null;
    bw = accCon.createBatchWriter(tablename, 500L * 1024L * 1024L, Long.MAX_VALUE, 30);
    for (int i = 0; i < 100; i++) {
        Mutation m = new Mutation(new Text("row" + i));
        m.put(new Text("cf" + 1), new Text("context1" + "\u0000" + "obj" + "\u0000" + "cq" + i), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text("context1" + "\u0000" + "subj" + "\u0000" + "cq" + i), new Value(new byte[0]));
        m.put(new Text("cf" + 1), new Text("context2" + "\u0000" + "obj" + "\u0000" + "cq" + i), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text("context2" + "\u0000" + "subj" + "\u0000" + "cq" + i), new Value(new byte[0]));
        bw.addMutation(m);
    }
    TextColumn tc1 = new TextColumn(new Text("cf" + 1), new Text("obj"));
    TextColumn tc2 = new TextColumn(new Text("cf" + 2), new Text("subj"));
    tc1.setIsPrefix(true);
    tc2.setIsPrefix(true);
    TextColumn[] tc = new TextColumn[2];
    tc[0] = tc1;
    tc[1] = tc2;
    IteratorSetting is = new IteratorSetting(30, "fii", DocumentIndexIntersectingIterator.class);
    DocumentIndexIntersectingIterator.setColumnFamilies(is, tc);
    DocumentIndexIntersectingIterator.setContext(is, "context2");
    Scanner scan = accCon.createScanner(tablename, new Authorizations("auths"));
    scan.addScanIterator(is);
    int results = 0;
    System.out.println("************************Test 19****************************");
    for (Map.Entry<Key, Value> e : scan) {
        System.out.println(e);
        results++;
    }
    Assert.assertEquals(100, results);
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) Text(org.apache.hadoop.io.Text) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 64 with Authorizations

use of org.apache.accumulo.core.security.Authorizations in project incubator-rya by apache.

the class DocumentIndexIntersectingIteratorTest method testOneHundredColumnSubjObj.

@Test
public void testOneHundredColumnSubjObj() throws Exception {
    BatchWriter bw = null;
    bw = accCon.createBatchWriter(tablename, 500L * 1024L * 1024L, Long.MAX_VALUE, 30);
    for (int i = 0; i < 100; i++) {
        Mutation m = new Mutation(new Text("" + i));
        for (int j = 0; j < 100; j++) {
            m.put(new Text("cf" + j), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + j), new Value(new byte[0]));
        }
        if (i == 30) {
            m.put(new Text("cf" + 100), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + 100), new Value(new byte[0]));
        }
        if (i == 60) {
            m.put(new Text("cf" + 100), new Text(null + "\u0000" + "subj" + "\u0000" + "cq" + 100), new Value(new byte[0]));
        }
        bw.addMutation(m);
    }
    DocumentIndexIntersectingIterator dii = new DocumentIndexIntersectingIterator();
    TextColumn tc1 = new TextColumn(new Text("cf" + 20), new Text("obj" + "\u0000" + "cq" + 20));
    TextColumn tc2 = new TextColumn(new Text("cf" + 50), new Text("obj" + "\u0000" + "cq" + 50));
    TextColumn tc3 = new TextColumn(new Text("cf" + 100), new Text("obj" + "\u0000" + "cq" + 100));
    TextColumn[] tc = new TextColumn[3];
    tc[0] = tc1;
    tc[1] = tc2;
    tc[2] = tc3;
    IteratorSetting is = new IteratorSetting(30, "fii", DocumentIndexIntersectingIterator.class);
    dii.setColumnFamilies(is, tc);
    Scanner scan = accCon.createScanner(tablename, new Authorizations("auths"));
    scan.addScanIterator(is);
    int results = 0;
    System.out.println("************************Test 4****************************");
    for (Map.Entry<Key, Value> e : scan) {
        System.out.println(e);
        results++;
    }
    Assert.assertEquals(1, results);
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) Text(org.apache.hadoop.io.Text) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 65 with Authorizations

use of org.apache.accumulo.core.security.Authorizations in project incubator-rya by apache.

the class DocumentIndexIntersectingIteratorTest method testContext7.

@Test
public void testContext7() throws Exception {
    BatchWriter bw = null;
    bw = accCon.createBatchWriter(tablename, 500L * 1024L * 1024L, Long.MAX_VALUE, 30);
    for (int i = 0; i < 10; i++) {
        Mutation m = new Mutation(new Text("row" + i));
        m.put(new Text("cf" + 1), new Text("context1" + "\u0000" + "obj" + "\u0000" + "cq" + i), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text("context1" + "\u0000" + "obj" + "\u0000" + "cq" + i), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text("context1" + "\u0000" + "obj" + "\u0000" + "cq" + 100 + i), new Value(new byte[0]));
        m.put(new Text("cf" + 1), new Text("context2" + "\u0000" + "obj" + "\u0000" + "cq" + i), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text("context2" + "\u0000" + "obj" + "\u0000" + "cq" + i), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text("context2" + "\u0000" + "obj" + "\u0000" + "cq" + 100 + i), new Value(new byte[0]));
        bw.addMutation(m);
    }
    TextColumn tc1 = new TextColumn(new Text("cf" + 1), new Text("obj"));
    TextColumn tc2 = new TextColumn(new Text("cf" + 2), new Text("obj"));
    tc1.setIsPrefix(true);
    tc2.setIsPrefix(true);
    TextColumn[] tc = new TextColumn[2];
    tc[0] = tc1;
    tc[1] = tc2;
    IteratorSetting is = new IteratorSetting(30, "fii", DocumentIndexIntersectingIterator.class);
    DocumentIndexIntersectingIterator.setColumnFamilies(is, tc);
    Scanner scan = accCon.createScanner(tablename, new Authorizations("auths"));
    scan.addScanIterator(is);
    int results = 0;
    System.out.println("************************Test 20****************************");
    for (Map.Entry<Key, Value> e : scan) {
        System.out.println(e);
        results++;
    }
    Assert.assertEquals(40, results);
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) Text(org.apache.hadoop.io.Text) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

Authorizations (org.apache.accumulo.core.security.Authorizations)242 Test (org.junit.Test)118 Scanner (org.apache.accumulo.core.client.Scanner)117 Key (org.apache.accumulo.core.data.Key)113 Value (org.apache.accumulo.core.data.Value)112 Text (org.apache.hadoop.io.Text)97 Mutation (org.apache.accumulo.core.data.Mutation)74 BatchWriter (org.apache.accumulo.core.client.BatchWriter)70 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)68 Range (org.apache.accumulo.core.data.Range)59 Map (java.util.Map)53 Entry (java.util.Map.Entry)47 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)39 Connector (org.apache.accumulo.core.client.Connector)34 ArrayList (java.util.ArrayList)31 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)30 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)29 AccumuloException (org.apache.accumulo.core.client.AccumuloException)28 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)26 Configuration (org.apache.hadoop.conf.Configuration)24