Search in sources :

Example 56 with RyaStatement

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();
}
Also used : MapDriver(org.apache.hadoop.mrunit.mapreduce.MapDriver) RyaStatementWritable(org.apache.rya.accumulo.mr.RyaStatementWritable) RyaStatement(org.apache.rya.api.domain.RyaStatement) LongWritable(org.apache.hadoop.io.LongWritable) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 57 with RyaStatement

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();
    }
}
Also used : MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) Entry(java.util.Map.Entry) RyaStatement(org.apache.rya.api.domain.RyaStatement) URIImpl(org.openrdf.model.impl.URIImpl) MapBindingSet(org.openrdf.query.impl.MapBindingSet) Map(java.util.Map) Test(org.junit.Test)

Example 58 with RyaStatement

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();
    }
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement) Test(org.junit.Test)

Example 59 with RyaStatement

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;
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatementBuilder(org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder) RyaStatement(org.apache.rya.api.domain.RyaStatement)

Example 60 with RyaStatement

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();
    }
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatementBuilder(org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder) RyaStatement(org.apache.rya.api.domain.RyaStatement) DocumentVisibility(org.apache.rya.mongodb.document.visibility.DocumentVisibility) Document(org.bson.Document) MongoDatabase(com.mongodb.client.MongoDatabase) Test(org.junit.Test)

Aggregations

RyaStatement (org.apache.rya.api.domain.RyaStatement)327 RyaURI (org.apache.rya.api.domain.RyaURI)184 Test (org.junit.Test)179 RyaType (org.apache.rya.api.domain.RyaType)115 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)63 BindingSet (org.openrdf.query.BindingSet)58 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)49 ArrayList (java.util.ArrayList)47 TripleRow (org.apache.rya.api.resolver.triple.TripleRow)42 StatementPattern (org.openrdf.query.algebra.StatementPattern)40 HashSet (java.util.HashSet)39 ParsedQuery (org.openrdf.query.parser.ParsedQuery)39 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)39 StatementMetadata (org.apache.rya.api.domain.StatementMetadata)36 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)36 Map (java.util.Map)33 Statement (org.openrdf.model.Statement)27 Key (org.apache.accumulo.core.data.Key)21 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)21 Value (org.apache.accumulo.core.data.Value)20