Search in sources :

Example 76 with RyaStatement

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

the class MongoGeoTemporalIndexerIT method ensureEvent.

@Test
public void ensureEvent() throws Exception {
    final RyaStatement geoStmnt = statement(point(0, 0));
    final RyaStatement timeStmnt = statement(makeInstant(0));
    final EventStorage store = indexer.getEventStorage();
    indexer.storeStatement(geoStmnt);
    Optional<Event> evnt = store.get(geoStmnt.getSubject());
    assertTrue(evnt.isPresent());
    Event expected = Event.builder().setSubject(geoStmnt.getSubject()).setGeometry(point(0, 0)).build();
    assertEquals(expected, evnt.get());
    indexer.storeStatement(timeStmnt);
    evnt = store.get(timeStmnt.getSubject());
    assertTrue(evnt.isPresent());
    expected = Event.builder().setSubject(geoStmnt.getSubject()).setGeometry(point(0, 0)).setTemporalInstant(makeInstant(0)).build();
    assertEquals(expected, evnt.get());
    indexer.deleteStatement(geoStmnt);
    evnt = store.get(timeStmnt.getSubject());
    assertTrue(evnt.isPresent());
    expected = Event.builder().setSubject(timeStmnt.getSubject()).setTemporalInstant(makeInstant(0)).build();
    assertEquals(expected, evnt.get());
    indexer.deleteStatement(timeStmnt);
    evnt = store.get(timeStmnt.getSubject());
    assertTrue(evnt.isPresent());
    expected = Event.builder().setSubject(timeStmnt.getSubject()).build();
    assertEquals(expected, evnt.get());
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement) Event(org.apache.rya.indexing.geotemporal.model.Event) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) Test(org.junit.Test)

Example 77 with RyaStatement

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

the class MongoIndexerDeleteIT method populateRya.

private void populateRya(final SailRepositoryConnection conn) throws Exception {
    final ValueFactory VF = new ValueFactoryImpl();
    // geo 2x2 points
    final GeometryFactory GF = new GeometryFactory();
    for (int x = 0; x <= 1; x++) {
        for (int y = 0; y <= 1; y++) {
            final Geometry geo = GF.createPoint(new Coordinate(x + .5, y + .5));
            final RyaStatement stmnt = statement(geo);
            final Statement statement = RyaToRdfConversions.convertStatement(stmnt);
            conn.add(statement);
        }
    }
    // freetext
    final URI person = VF.createURI("http://example.org/ontology/Person");
    String uuid;
    uuid = "urn:people";
    conn.add(VF.createURI(uuid), RDF.TYPE, person);
    conn.add(VF.createURI(uuid), RDFS.LABEL, VF.createLiteral("Alice Palace Hose", VF.createURI("http://www.w3.org/2001/XMLSchema#string")));
    conn.add(VF.createURI(uuid), RDFS.LABEL, VF.createLiteral("Bob Snob Hose", "en"));
    // temporal
    final TemporalInstant instant = new TemporalInstantRfc3339(1, 2, 3, 4, 5, 6);
    conn.add(VF.createURI("foo:time"), VF.createURI("Property:atTime"), VF.createLiteral(instant.toString()));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Coordinate(com.vividsolutions.jts.geom.Coordinate) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) RyaStatement(org.apache.rya.api.domain.RyaStatement) ValueFactory(org.openrdf.model.ValueFactory) TemporalInstant(org.apache.rya.indexing.TemporalInstant) URI(org.openrdf.model.URI)

Example 78 with RyaStatement

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

the class RyaEdgeReader method getCurrentEdge.

@Override
public Edge<Text, RyaStatementWritable> getCurrentEdge() throws IOException, InterruptedException {
    RyaStatementWritable currentStatement = reader.getCurrentValue();
    RyaStatement ryaStatement = currentStatement.getRyaStatement();
    Edge<Text, RyaStatementWritable> edge = EdgeFactory.create(new Text(ryaStatement.toString()), currentStatement);
    return edge;
}
Also used : RyaStatementWritable(org.apache.rya.accumulo.mr.RyaStatementWritable) RyaStatement(org.apache.rya.api.domain.RyaStatement) Text(org.apache.hadoop.io.Text)

Example 79 with RyaStatement

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

the class MongoGeoTemporalIndexer method updateEvent.

private void updateEvent(final RyaURI subject, final RyaStatement statement) throws IndexingException, ParseException {
    final EventStorage eventStore = events.get();
    checkState(events != null, "Must set this indexers configuration before storing statements.");
    new EventUpdater(eventStore).update(subject, old -> {
        final Event.Builder updated;
        if (!old.isPresent()) {
            updated = Event.builder().setSubject(subject);
        } else {
            updated = Event.builder(old.get());
        }
        final URI pred = statement.getObject().getDataType();
        if (pred.equals(GeoConstants.GEO_AS_WKT) || pred.equals(GeoConstants.GEO_AS_GML) || pred.equals(GeoConstants.XMLSCHEMA_OGC_WKT) || pred.equals(GeoConstants.XMLSCHEMA_OGC_GML)) {
            // is geo
            try {
                final Statement geoStatement = RyaToRdfConversions.convertStatement(statement);
                final Geometry geometry = GeoParseUtils.getGeometry(geoStatement, new GmlParser());
                updated.setGeometry(geometry);
            } catch (final ParseException e) {
                LOG.error(e.getMessage(), e);
            }
        } else {
            // is time
            final String dateTime = statement.getObject().getData();
            final Matcher matcher = TemporalInstantRfc3339.PATTERN.matcher(dateTime);
            if (matcher.find()) {
                final TemporalInterval interval = TemporalInstantRfc3339.parseInterval(dateTime);
                updated.setTemporalInterval(interval);
            } else {
                final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.parse(dateTime));
                updated.setTemporalInstant(instant);
            }
        }
        return Optional.of(updated.build());
    });
}
Also used : Matcher(java.util.regex.Matcher) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) GmlParser(org.apache.rya.indexing.mongodb.geo.GmlParser) TemporalInstant(org.apache.rya.indexing.TemporalInstant) URI(org.openrdf.model.URI) RyaURI(org.apache.rya.api.domain.RyaURI) Geometry(com.vividsolutions.jts.geom.Geometry) Event(org.apache.rya.indexing.geotemporal.model.Event) ParseException(com.vividsolutions.jts.io.ParseException) TemporalInterval(org.apache.rya.indexing.TemporalInterval) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage)

Example 80 with RyaStatement

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

the class EntityCentricIndexTest method testDeserializeObjectRow.

@Test
public void testDeserializeObjectRow() throws RyaTypeResolverException, IOException {
    RyaStatement deserialized = EntityCentricIndex.deserializeStatement(objectCentricKey, value);
    Assert.assertEquals("Deserialization of object-centric row failed to produce equivalent RyaStatement.", ryaStatement, deserialized);
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement) 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