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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations