Search in sources :

Example 31 with RyaStatement

use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.

the class RyaSubGraphSerializer method write.

/**
 * Use Kryo to write RyaSubGraph to {@link Output} stream
 * @param kryo - used to write subgraph to output stream
 * @param output - stream that subgraph is written to
 * @param object - subgraph written to output stream
 */
@Override
public void write(Kryo kryo, Output output, RyaSubGraph object) {
    output.writeString(object.getId());
    output.writeInt(object.getStatements().size());
    for (RyaStatement statement : object.getStatements()) {
        RyaStatementSerializer.writeToKryo(kryo, output, statement);
    }
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement)

Example 32 with RyaStatement

use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.

the class AccumuloQueryRuleset method getRange.

/**
 * Turn a single StatementPattern into a Range.
 * @param conf
 * @throws IOException if the range can't be resolved
 */
private Map.Entry<TABLE_LAYOUT, ByteRange> getRange(final StatementPattern sp) throws IOException {
    final Var context = sp.getContextVar();
    final Statement stmt = new NullableStatementImpl((Resource) sp.getSubjectVar().getValue(), (URI) sp.getPredicateVar().getValue(), sp.getObjectVar().getValue(), context == null ? null : (Resource) context.getValue());
    final RyaStatement rs = RdfToRyaConversions.convertStatement(stmt);
    final TriplePatternStrategy strategy = ryaContext.retrieveStrategy(rs);
    final Map.Entry<TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(rs.getSubject(), rs.getPredicate(), rs.getObject(), rs.getContext(), conf);
    return entry;
}
Also used : TABLE_LAYOUT(org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT) NullableStatementImpl(org.apache.rya.api.utils.NullableStatementImpl) TriplePatternStrategy(org.apache.rya.api.query.strategy.TriplePatternStrategy) ByteRange(org.apache.rya.api.query.strategy.ByteRange) Var(org.openrdf.query.algebra.Var) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) Resource(org.openrdf.model.Resource) RyaStatement(org.apache.rya.api.domain.RyaStatement) HashMap(java.util.HashMap) Map(java.util.Map)

Example 33 with RyaStatement

use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.

the class MongoFreeTextIndexerIT method testRestrictPredicatesSearch.

@Test
public void testRestrictPredicatesSearch() throws Exception {
    conf.setStrings(ConfigUtils.FREETEXT_PREDICATES_LIST, "pred:1,pred:2");
    try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) {
        f.setConf(conf);
        f.init();
        // These should not be stored because they are not in the predicate list
        f.storeStatement(new RyaStatement(new RyaURI("foo:subj1"), new RyaURI(RDFS.LABEL.toString()), new RyaType("invalid")));
        f.storeStatement(new RyaStatement(new RyaURI("foo:subj2"), new RyaURI(RDFS.COMMENT.toString()), new RyaType("invalid")));
        final RyaURI pred1 = new RyaURI("pred:1");
        final RyaURI pred2 = new RyaURI("pred:2");
        // These should be stored because they are in the predicate list
        final RyaStatement s3 = new RyaStatement(new RyaURI("foo:subj3"), pred1, new RyaType("valid"));
        final RyaStatement s4 = new RyaStatement(new RyaURI("foo:subj4"), pred2, new RyaType("valid"));
        f.storeStatement(s3);
        f.storeStatement(s4);
        // This should not be stored because the object is not a literal
        f.storeStatement(new RyaStatement(new RyaURI("foo:subj5"), pred1, new RyaURI("in:validURI")));
        f.flush();
        assertEquals(Sets.newHashSet(), getSet(f.queryText("invalid", EMPTY_CONSTRAINTS)));
        assertEquals(Sets.newHashSet(), getSet(f.queryText("in:validURI", EMPTY_CONSTRAINTS)));
        final Set<Statement> actual = getSet(f.queryText("valid", EMPTY_CONSTRAINTS));
        assertEquals(2, actual.size());
        assertTrue(actual.contains(RyaToRdfConversions.convertStatement(s3)));
        assertTrue(actual.contains(RyaToRdfConversions.convertStatement(s4)));
    }
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaType(org.apache.rya.api.domain.RyaType) MongoFreeTextIndexer(org.apache.rya.indexing.mongodb.freetext.MongoFreeTextIndexer) Test(org.junit.Test)

Example 34 with RyaStatement

use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.

the class MergeToolTest method createRyaStatementUniqueAdd.

private static RyaStatement createRyaStatementUniqueAdd(final String s, final String p, final String o, final Date date, final AccumuloRyaDAO dao1, final AccumuloRyaDAO dao2) throws Exception {
    final String uniquePart = Long.toString(System.currentTimeMillis() & 0xffffff, 64);
    final RyaStatement rs = createRyaStatement(s + uniquePart, p + uniquePart, o + uniquePart, date);
    if (dao1 != null) {
        dao1.add(rs);
    }
    if (dao2 != null) {
        dao2.add(rs);
    }
    return rs;
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement) TestUtils.createRyaStatement(org.apache.rya.accumulo.mr.merge.util.TestUtils.createRyaStatement)

Example 35 with RyaStatement

use of org.apache.rya.api.domain.RyaStatement in project incubator-rya by apache.

the class MergeToolTest method testOldParentMissingChild.

@Test
public void testOldParentMissingChild() throws Exception {
    final RyaStatement stmtMissingInChildOld = createRyaStatementUniqueAdd("s_notInChild", "p_notInChild", "o_notInChild", LAST_MONTH, parentDao, null);
    mergeToolRun(YESTERDAY);
    assertStatementInParent("Missing in child statement deleted old in parent ", 0, stmtMissingInChildOld);
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement) TestUtils.createRyaStatement(org.apache.rya.accumulo.mr.merge.util.TestUtils.createRyaStatement) 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