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