use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class EntityCentricIndexTest method testDeserializeSubjectRow.
@Test
public void testDeserializeSubjectRow() throws RyaTypeResolverException, IOException {
RyaStatement deserialized = EntityCentricIndex.deserializeStatement(subjectCentricKey, value);
Assert.assertEquals("Deserialization of subject-centric row failed to produce equivalent RyaStatement.", ryaStatement, deserialized);
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class StatementPatternStorageTest method testSimplePredicateRange.
public void testSimplePredicateRange() throws Exception {
ryaDAO.add(new RyaStatement(new RyaURI(namespace, "a"), new RyaURI(namespace, "p"), new RyaType("l")));
ryaDAO.add(new RyaStatement(new RyaURI(namespace, "b"), new RyaURI(namespace, "p"), new RyaType("l")));
ryaDAO.add(new RyaStatement(new RyaURI(namespace, "c"), new RyaURI(namespace, "n"), new RyaType("l")));
int count = 0;
List<StatementPatternStorage> storages = createStorages("accumulo://" + tablePrefix + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&predicate=<" + namespace + "p>&mock=true");
for (StatementPatternStorage storage : storages) {
while (true) {
Tuple next = storage.getNext();
if (next == null) {
break;
}
count++;
}
}
assertEquals(2, count);
ryaDAO.destroy();
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class StatementPatternStorageTest method testContext.
public void testContext() throws Exception {
ryaDAO.add(new RyaStatement(new RyaURI(namespace, "a"), new RyaURI(namespace, "p"), new RyaType("l1")));
ryaDAO.add(new RyaStatement(new RyaURI(namespace, "a"), new RyaURI(namespace, "p"), new RyaType("l2"), new RyaURI(namespace, "g1")));
int count = 0;
List<StatementPatternStorage> storages = createStorages("accumulo://" + tablePrefix + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&predicate=<" + namespace + "p>&mock=true");
for (StatementPatternStorage storage : storages) {
while (true) {
Tuple next = storage.getNext();
if (next == null) {
break;
}
count++;
}
}
assertEquals(2, count);
count = 0;
storages = createStorages("accumulo://" + tablePrefix + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&predicate=<" + namespace + "p>&context=<" + namespace + "g1>&mock=true");
for (StatementPatternStorage storage : storages) {
while (true) {
Tuple next = storage.getNext();
if (next == null) {
break;
}
count++;
}
}
assertEquals(1, count);
ryaDAO.destroy();
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class StatementPatternStorage method getNext.
@Override
public Tuple getNext() throws IOException {
try {
if (reader.nextKeyValue()) {
Key key = (Key) reader.getCurrentKey();
org.apache.accumulo.core.data.Value value = (org.apache.accumulo.core.data.Value) reader.getCurrentValue();
ByteArrayDataInput input = ByteStreams.newDataInput(key.getRow().getBytes());
RyaStatement ryaStatement = ryaContext.deserializeTriple(layout, new TripleRow(key.getRow().getBytes(), key.getColumnFamily().getBytes(), key.getColumnQualifier().getBytes()));
Tuple tuple = TupleFactory.getInstance().newTuple(7);
tuple.set(0, ryaStatement.getSubject().getData());
tuple.set(1, ryaStatement.getPredicate().getData());
tuple.set(2, ryaStatement.getObject().getData());
tuple.set(3, (ryaStatement.getContext() != null) ? (ryaStatement.getContext().getData()) : (null));
tuple.set(4, ryaStatement.getSubject().getDataType());
tuple.set(5, ryaStatement.getPredicate().getDataType());
tuple.set(6, ryaStatement.getObject().getDataType());
return tuple;
}
} catch (Exception e) {
throw new IOException(e);
}
return null;
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class MergeJoinTest method testSimpleMergeJoinPredicateOnly.
@Test
public void testSimpleMergeJoinPredicateOnly() throws Exception {
// add data
RyaURI pred1 = new RyaURI(litdupsNS, "pred1");
RyaURI pred2 = new RyaURI(litdupsNS, "pred2");
RyaType one = new RyaType("1");
RyaURI subj1 = new RyaURI(litdupsNS, "subj1");
RyaURI subj2 = new RyaURI(litdupsNS, "subj2");
RyaURI subj3 = new RyaURI(litdupsNS, "subj3");
RyaURI subj4 = new RyaURI(litdupsNS, "subj4");
dao.add(new RyaStatement(subj1, pred1, one));
dao.add(new RyaStatement(subj1, pred2, one));
dao.add(new RyaStatement(subj2, pred1, one));
dao.add(new RyaStatement(subj2, pred2, one));
dao.add(new RyaStatement(subj3, pred1, one));
dao.add(new RyaStatement(subj3, pred2, one));
dao.add(new RyaStatement(subj4, pred1, one));
dao.add(new RyaStatement(subj4, pred2, one));
// 1 join
MergeJoin mergeJoin = new MergeJoin(dao.getQueryEngine());
CloseableIteration<RyaStatement, RyaDAOException> join = mergeJoin.join(null, pred1, pred2);
int count = 0;
while (join.hasNext()) {
RyaStatement next = join.next();
count++;
}
assertEquals(4, count);
join.close();
}
Aggregations