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