Search in sources :

Example 56 with Authorizations

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

the class DocumentIndexIntersectingIteratorTest method testOneHundredColumnSameCf.

// @Test
public void testOneHundredColumnSameCf() 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"), new Text(null + "\u0000" + "obj" + "\u0000" + "cq" + j), new Value(new byte[0]));
        }
        bw.addMutation(m);
    }
    DocumentIndexIntersectingIterator dii = new DocumentIndexIntersectingIterator();
    TextColumn tc1 = new TextColumn(new Text("cf"), new Text("obj" + "\u0000" + "cq" + 20));
    TextColumn tc2 = new TextColumn(new Text("cf"), new Text("obj" + "\u0000" + "cq" + 50));
    TextColumn tc3 = new TextColumn(new Text("cf"), new Text("obj" + "\u0000" + "cq" + 80));
    TextColumn tc4 = new TextColumn(new Text("cf"), new Text("obj"));
    tc4.setIsPrefix(true);
    TextColumn[] tc = new TextColumn[4];
    tc[0] = tc1;
    tc[1] = tc2;
    tc[2] = tc3;
    tc[3] = tc4;
    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 9****************************");
    for (Map.Entry<Key, Value> e : scan) {
        // System.out.println(e);
        results++;
    }
    Assert.assertEquals(10000, 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)

Example 57 with Authorizations

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

the class DocumentIndexIntersectingIteratorTest method testContext1.

// @Test
// public void testRangeBound() {
// 
// BatchWriter bw = null;
// 
// try {
// 
// 
// 
// 
// for (int i = 0; i < 100; i++) {
// 
// Mutation m = new Mutation(new Text("" + i));
// 
// m.put(new Text("cf" + 1), new Text("obj" + "\u0000" + "cq" + 1), new Value(new byte[0]));
// m.put(new Text("cf" + 2), new Text("obj" + "\u0000" + "cq" + 2), new Value(new byte[0]));
// m.put(new Text("cf" + 1), new Text("subj" + "\u0000" + "cq" + 1), new Value(new byte[0]));
// m.put(new Text("cf" + 2), new Text("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("obj" + "\u0000" + "cq" + 3), new Value(new byte[0]));
// m.put(new Text("cf" + 3), new Text("subj" + "\u0000" + "cq" + 3), new Value(new byte[0]));
// m.put(new Text("cf" + 3), new Text("obj" + "\u0000" + "cq" + 4), new Value(new byte[0]));
// m.put(new Text("cf" + 3), new Text("subj" + "\u0000" + "cq" + 4), new Value(new byte[0]));
// m.put(new Text("cf" + 3), new Text("obj" + "\u0000" + "cq" + 5), new Value(new byte[0]));
// m.put(new Text("cf" + 3), new Text("subj" + "\u0000" + "cq" + 5), new Value(new byte[0]));
// }
// 
// bw.addMutation(m);
// 
// }
// 
// 
// 
// Text cf = new Text("cf" + 3);
// Text cq = new Text("obj" + "\u0000" + "cq" + 3);
// 
// Scanner scan = accCon.createScanner(tablename, new Authorizations("auths"));
// scan.fetchColumn(cf, cq );
// scan.setRange(new Range());
// 
// 
// int results = 0;
// System.out.println("************************Test 14****************************");
// for (Map.Entry<Key, Value> e : scan) {
// System.out.println(e);
// results++;
// }
// 
// 
// 
// 
// 
// 
// } catch (MutationsRejectedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (TableNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// 
// }
@Test
public void testContext1() 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("context1" + "\u0000" + "obj" + "\u0000" + "cq" + 1), new Value(new byte[0]));
        m.put(new Text("cf" + 2), new Text("context1" + "\u0000" + "obj" + "\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("context1" + "\u0000" + "obj" + "\u0000" + "cq" + 3), new Value(new byte[0]));
            m.put(new Text("cf" + 3), new Text("context2" + "\u0000" + "obj" + "\u0000" + "cq" + 4), new Value(new byte[0]));
            m.put(new Text("cf" + 3), new Text("context1" + "\u0000" + "obj" + "\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("obj"));
    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);
    DocumentIndexIntersectingIterator.setContext(is, "context1");
    Scanner scan = accCon.createScanner(tablename, new Authorizations("auths"));
    scan.addScanIterator(is);
    int results = 0;
    System.out.println("************************Test 14****************************");
    for (Map.Entry<Key, Value> e : scan) {
        System.out.println(e);
        results++;
    }
    Assert.assertEquals(8, 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 58 with Authorizations

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

the class DocumentIndexIntersectingIteratorTest method testOneHundredColumnSubjObjPrefixFourTerms.

@Test
public void testOneHundredColumnSubjObjPrefixFourTerms() 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"));
    TextColumn tc4 = new TextColumn(new Text("cf" + 100), new Text("obj"));
    tc3.setIsPrefix(true);
    tc4.setIsPrefix(true);
    TextColumn[] tc = new TextColumn[4];
    tc[0] = tc1;
    tc[1] = tc2;
    tc[2] = tc3;
    tc[3] = tc4;
    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 8****************************");
    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 59 with Authorizations

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

the class DocumentIndexIntersectingIteratorTest method testBasicColumnObj.

@Test
public void testBasicColumnObj() 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"), new Text(null + "\u0000" + "obj" + "\u0000" + "cq"), new Value(new byte[0]));
        m.put(new Text("cF"), new Text(null + "\u0000" + "obj" + "\u0000" + "cQ"), new Value(new byte[0]));
        if (i == 30 || i == 60) {
            m.put(new Text("CF"), new Text(null + "\u0000" + "obj" + "\u0000" + "CQ"), new Value(new byte[0]));
        }
        bw.addMutation(m);
    }
    DocumentIndexIntersectingIterator dii = new DocumentIndexIntersectingIterator();
    TextColumn tc1 = new TextColumn(new Text("cf"), new Text("obj" + "\u0000" + "cq"));
    TextColumn tc2 = new TextColumn(new Text("cF"), new Text("obj" + "\u0000" + "cQ"));
    TextColumn tc3 = new TextColumn(new Text("CF"), new Text("obj" + "\u0000" + "CQ"));
    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 1****************************");
    for (Map.Entry<Key, Value> e : scan) {
        System.out.println(e);
        results++;
    }
    Assert.assertEquals(2, 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 60 with Authorizations

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

the class DocumentIndexIntersectingIteratorTest method testOneHundredColumnObjPrefix.

@Test
public void testOneHundredColumnObjPrefix() 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]));
        }
        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"));
    TextColumn[] tc = new TextColumn[3];
    tc[0] = tc1;
    tc[1] = tc2;
    tc[2] = tc3;
    tc3.setIsPrefix(true);
    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 5****************************");
    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)

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