use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class DuplicateEliminationTest method testRdfMapperOutput.
@Test
public void testRdfMapperOutput() throws Exception {
RyaStatement rya = TestUtils.ryaStatement("x", "subOrganizationOf", "y");
RyaStatementWritable rsw = new RyaStatementWritable();
rsw.setRyaStatement(rya);
LongWritable l = new LongWritable();
new MapDriver<LongWritable, RyaStatementWritable, Fact, Derivation>().withMapper(new DuplicateElimination.DuplicateRdfMapper()).withInput(l, rsw).withOutput(X_SUB_Y, X_SUB_Y.getDerivation()).runTest();
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class MongoDBQueryEngineIT method bindingSetsQuery.
@SuppressWarnings("unchecked")
@Test
public void bindingSetsQuery() throws Exception {
final MongoDBRyaDAO dao = new MongoDBRyaDAO();
try (final MongoDBQueryEngine engine = new MongoDBQueryEngine()) {
engine.setConf(conf);
// Add data.
dao.setConf(conf);
dao.init();
dao.add(getStatement("u:a", "u:tt", "u:b"));
dao.add(getStatement("u:a", "u:tt", "u:c"));
// Run the test.
final RyaStatement s = getStatement("u:a", null, null);
final MapBindingSet bs1 = new MapBindingSet();
bs1.addBinding("foo", new URIImpl("u:x"));
final Map.Entry<RyaStatement, BindingSet> e1 = new RdfCloudTripleStoreUtils.CustomEntry<>(s, bs1);
final Collection<Entry<RyaStatement, BindingSet>> stmts1 = Lists.newArrayList(e1);
assertEquals(2, size(engine.queryWithBindingSet(stmts1, conf)));
final MapBindingSet bs2 = new MapBindingSet();
bs2.addBinding("foo", new URIImpl("u:y"));
final Map.Entry<RyaStatement, BindingSet> e2 = new RdfCloudTripleStoreUtils.CustomEntry<>(s, bs2);
final Collection<Entry<RyaStatement, BindingSet>> stmts2 = Lists.newArrayList(e1, e2);
assertEquals(4, size(engine.queryWithBindingSet(stmts2, conf)));
} finally {
dao.destroy();
}
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class MongoDBQueryEngineIT method statementQuery.
@Test
public void statementQuery() throws Exception {
final MongoDBRyaDAO dao = new MongoDBRyaDAO();
try (final MongoDBQueryEngine engine = new MongoDBQueryEngine()) {
engine.setConf(conf);
// Add data.
dao.setConf(conf);
dao.init();
dao.add(getStatement("u:a", "u:tt", "u:b"));
dao.add(getStatement("u:a", "u:tt", "u:c"));
final RyaStatement s = getStatement("u:a", null, null);
assertEquals(2, size(engine.query(s, conf)));
} finally {
dao.destroy();
}
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class MongoDBRyaDAOIT method buildVisibilityTestRyaStatement.
private static RyaStatement buildVisibilityTestRyaStatement(final String documentVisibility) {
final RyaStatementBuilder builder = new RyaStatementBuilder();
builder.setPredicate(new RyaURI("http://temp.com"));
builder.setSubject(new RyaURI("http://subject.com"));
builder.setObject(new RyaURI("http://object.com"));
builder.setContext(new RyaURI("http://context.com"));
builder.setColumnVisibility(documentVisibility != null ? documentVisibility.getBytes() : null);
final RyaStatement statement = builder.build();
return statement;
}
use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.
the class MongoDBRyaDAOIT method testDelete.
@Test
public void testDelete() throws RyaDAOException, MongoException, IOException {
final MongoDBRyaDAO dao = new MongoDBRyaDAO();
try {
dao.setConf(conf);
dao.init();
final RyaStatementBuilder builder = new RyaStatementBuilder();
builder.setPredicate(new RyaURI("http://temp.com"));
builder.setSubject(new RyaURI("http://subject.com"));
builder.setObject(new RyaURI("http://object.com"));
builder.setColumnVisibility(new DocumentVisibility("C").flatten());
final RyaStatement statement = builder.build();
final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
dao.add(statement);
assertEquals(1, coll.count());
dao.delete(statement, conf);
assertEquals(0, coll.count());
} finally {
dao.destroy();
}
}
Aggregations