Search in sources :

Example 26 with RyaURI

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

Example 27 with RyaURI

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());
}
Also used : TypeStorage(org.apache.rya.indexing.entity.storage.TypeStorage) RyaURI(org.apache.rya.api.domain.RyaURI) Type(org.apache.rya.indexing.entity.model.Type) Test(org.junit.Test)

Example 28 with RyaURI

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);
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) EntityCentricIndex(org.apache.rya.indexing.accumulo.entity.EntityCentricIndex) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaURI(org.apache.rya.api.domain.RyaURI) Value(org.apache.accumulo.core.data.Value) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 29 with RyaURI

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

Example 30 with RyaURI

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();
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) StatementConstraints(org.apache.rya.indexing.StatementConstraints) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer) 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) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

RyaURI (org.apache.rya.api.domain.RyaURI)287 Test (org.junit.Test)190 RyaStatement (org.apache.rya.api.domain.RyaStatement)183 RyaType (org.apache.rya.api.domain.RyaType)146 BindingSet (org.openrdf.query.BindingSet)56 ArrayList (java.util.ArrayList)52 StatementPattern (org.openrdf.query.algebra.StatementPattern)50 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)49 HashSet (java.util.HashSet)43 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)43 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)42 ParsedQuery (org.openrdf.query.parser.ParsedQuery)42 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)42 StatementMetadata (org.apache.rya.api.domain.StatementMetadata)35 Entity (org.apache.rya.indexing.entity.model.Entity)30 Property (org.apache.rya.indexing.entity.model.Property)28 URIImpl (org.openrdf.model.impl.URIImpl)25 EntityStorage (org.apache.rya.indexing.entity.storage.EntityStorage)22 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)21 TripleRow (org.apache.rya.api.resolver.triple.TripleRow)21