use of org.apache.rya.api.domain.RyaURI in project incubator-rya by apache.
the class TestUtils method createRyaStatement.
/**
* Creates a {@link RyaStatement} from the specified subject, predicate, and object.
* @param subject the subject.
* @param predicate the predicate.
* @param object the object.
* @param date the {@link Date} to use for the key's timestamp.
* @return the {@link RyaStatement}.
*/
public static RyaStatement createRyaStatement(final String subject, final String predicate, final String object, final Date date) {
final RyaURI subjectUri = createRyaUri(subject);
final RyaURI predicateUri = createRyaUri(predicate);
final RyaURI objectUri = createRyaUri(object);
final RyaStatement ryaStatement = new RyaStatement(subjectUri, predicateUri, objectUri);
if (date != null) {
ryaStatement.setTimestamp(date.getTime());
}
return ryaStatement;
}
use of org.apache.rya.api.domain.RyaURI in project incubator-rya by apache.
the class MongoTypeStorageIT method get_nonexisting.
@Test
public void get_nonexisting() throws TypeStorageException {
// Get a Type that hasn't been created.
final TypeStorage storage = new MongoTypeStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
final Optional<Type> storedType = storage.get(new RyaURI("urn:icecream"));
// Verify nothing was returned.
assertFalse(storedType.isPresent());
}
use of org.apache.rya.api.domain.RyaURI in project incubator-rya by apache.
the class RyaOutputFormatTest method testEntityIndexing.
@Test
public void testEntityIndexing() throws Exception {
final EntityCentricIndex entity = new EntityCentricIndex();
entity.setConf(conf);
final RyaStatement input = RyaStatement.builder().setSubject(new RyaURI(GRAPH + ":s")).setPredicate(new RyaURI(GRAPH + ":p")).setObject(new RyaURI(GRAPH + ":o")).build();
RyaOutputFormat.setCoreTablesEnabled(job, false);
RyaOutputFormat.setFreeTextEnabled(job, false);
RyaOutputFormat.setTemporalEnabled(job, false);
RyaOutputFormat.setEntityEnabled(job, true);
write(input);
entity.close();
final Set<Statement> expected = new HashSet<>();
final Set<Statement> inserted = new HashSet<>();
expected.add(RyaToRdfConversions.convertStatement(input));
final String table = EntityCentricIndex.getTableName(conf);
final Scanner scanner = connector.createScanner(table, new Authorizations(CV));
for (final Map.Entry<Key, Value> row : scanner) {
System.out.println(row);
inserted.add(RyaToRdfConversions.convertStatement(EntityCentricIndex.deserializeStatement(row.getKey(), row.getValue())));
}
Assert.assertEquals(expected, inserted);
}
use of org.apache.rya.api.domain.RyaURI in project incubator-rya by apache.
the class RyaOutputFormatTest method testOutputFormat.
@Test
public void testOutputFormat() throws Exception {
final RyaStatement input = RyaStatement.builder().setSubject(new RyaURI("http://www.google.com")).setPredicate(new RyaURI("http://some_other_uri")).setObject(new RyaURI("http://www.yahoo.com")).setColumnVisibility(CV.getBytes()).setValue(new byte[0]).setContext(new RyaURI(GRAPH)).build();
RyaOutputFormat.setCoreTablesEnabled(job, true);
RyaOutputFormat.setFreeTextEnabled(job, false);
RyaOutputFormat.setTemporalEnabled(job, false);
RyaOutputFormat.setEntityEnabled(job, false);
write(input);
TestUtils.verify(connector, conf, input);
}
use of org.apache.rya.api.domain.RyaURI in project incubator-rya by apache.
the class RyaOutputFormatTest method testFreeTextIndexing.
@Test
public void testFreeTextIndexing() throws Exception {
final AccumuloFreeTextIndexer ft = new AccumuloFreeTextIndexer();
ft.setConf(conf);
final RyaStatement input = RyaStatement.builder().setSubject(new RyaURI(GRAPH + ":s")).setPredicate(new RyaURI(GRAPH + ":p")).setObject(new RyaType(XMLSchema.STRING, "one two three four five")).build();
RyaOutputFormat.setCoreTablesEnabled(job, false);
RyaOutputFormat.setFreeTextEnabled(job, true);
RyaOutputFormat.setTemporalEnabled(job, false);
RyaOutputFormat.setEntityEnabled(job, false);
write(input);
final Set<Statement> empty = new HashSet<>();
final Set<Statement> expected = new HashSet<>();
expected.add(RyaToRdfConversions.convertStatement(input));
Assert.assertEquals(expected, getSet(ft.queryText("one", new StatementConstraints())));
Assert.assertEquals(empty, getSet(ft.queryText("!two", new StatementConstraints())));
Assert.assertEquals(expected, getSet(ft.queryText("*r", new StatementConstraints())));
Assert.assertEquals(empty, getSet(ft.queryText("r*", new StatementConstraints())));
Assert.assertEquals(expected, getSet(ft.queryText("!r*", new StatementConstraints())));
Assert.assertEquals(expected, getSet(ft.queryText("t* & !s*", new StatementConstraints())));
ft.close();
}
Aggregations