use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.
the class TemporalIntervalTest method constructorTest.
@Test
public void constructorTest() throws Exception {
TemporalInterval ti = new //
TemporalInterval(//
new TemporalInstantRfc3339(2014, 12, 30, 12, 59, 59), //
new TemporalInstantRfc3339(2014, 12, 30, 13, 00, 00));
Assert.assertNotNull(ti.getAsKeyBeginning());
Assert.assertNotNull(ti.getHasEnd());
}
use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.
the class AccumuloTemporalIndexer method deleteStatement.
private void deleteStatement(final Statement statement) throws IOException, IllegalArgumentException {
Objects.requireNonNull(temporalIndexBatchWriter, "This is not initialized for writing. Must call setMultiTableBatchWriter() and init().");
// if the predicate list is empty, accept all predicates.
// Otherwise, make sure the predicate is on the "valid" list
final boolean isValidPredicate = validPredicates.isEmpty() || validPredicates.contains(statement.getPredicate());
if (!isValidPredicate || !(statement.getObject() instanceof Literal)) {
return;
}
// 0 begin, 1 end of interval
final DateTime[] indexDateTimes = new DateTime[2];
extractDateTime(statement, indexDateTimes);
if (indexDateTimes[0] == null) {
return;
}
// Remove this as an instant, or interval.
try {
if (indexDateTimes[1] != null) {
final TemporalInterval interval = new TemporalInterval(new TemporalInstantRfc3339(indexDateTimes[0]), new TemporalInstantRfc3339(indexDateTimes[1]));
removeInterval(temporalIndexBatchWriter, interval, statement);
} else {
final TemporalInstant instant = new TemporalInstantRfc3339(indexDateTimes[0]);
removeInstant(temporalIndexBatchWriter, instant, statement);
}
} catch (final MutationsRejectedException e) {
throw new IOException("While adding interval/instant for statement =" + statement, e);
}
}
use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.
the class GeoTemporalProviderTest method twoPatternsTwoFiltersNotValid_test.
@Test
public void twoPatternsTwoFiltersNotValid_test() throws Exception {
final ValueFactory vf = new ValueFactoryImpl();
final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString());
final URI tempPred = vf.createURI(URI_PROPERTY_AT_TIME);
// Only handles geo and temporal filters
final String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" + "PREFIX text: <http://rdf.useekm.com/fts#text>" + "SELECT * WHERE { " + "?subj <" + tempPred + "> ?time ." + "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " + " FILTER(geos:sfContains(?loc, " + geo + ")) . " + " FILTER(text:equals(?time, " + temp + ")) . " + "}";
final QuerySegment<EventQueryNode> node = getQueryNode(query);
final List<EventQueryNode> nodes = provider.getExternalSets(node);
assertEquals(0, nodes.size());
}
use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.
the class GeoTemporalProviderTest method twoNode_test.
@Test
public void twoNode_test() throws Exception {
final ValueFactory vf = new ValueFactoryImpl();
final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString());
final URI tempPred = vf.createURI(URI_PROPERTY_AT_TIME);
final String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" + "PREFIX time: <tag:rya-rdf.org,2015:temporal#>" + "SELECT * WHERE { " + "?subj <" + tempPred + "> ?time ." + "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " + "?subj2 <" + tempPred + "> ?time2 ." + "?subj2 <" + GeoConstants.GEO_AS_WKT + "> ?loc2 . " + " FILTER(geos:sfContains(?loc, " + geo + ")) . " + " FILTER(time:equals(?time, " + temp + ")) . " + " FILTER(geos:sfContains(?loc2, " + geo + ")) . " + " FILTER(time:equals(?time2, " + temp + ")) . " + "}";
final QuerySegment<EventQueryNode> node = getQueryNode(query);
final List<EventQueryNode> nodes = provider.getExternalSets(node);
assertEquals(2, nodes.size());
}
use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.
the class EventQueryNode2IT method evaluate_variableSubject.
@Test
public void evaluate_variableSubject() throws Exception {
final EventStorage storage = new MongoEventStorage(super.getMongoClient(), "testDB");
RyaURI subject = new RyaURI("urn:event-1111");
Geometry geo = GF.createPoint(new Coordinate(1, 1));
final TemporalInstant temp = new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0);
final Event event = Event.builder().setSubject(subject).setGeometry(geo).setTemporalInstant(temp).build();
subject = new RyaURI("urn:event-2222");
geo = GF.createPoint(new Coordinate(-1, -1));
final Event otherEvent = Event.builder().setSubject(subject).setGeometry(geo).setTemporalInstant(temp).build();
storage.create(event);
storage.create(otherEvent);
final String query = "PREFIX time: <http://www.w3.org/2006/time#> \n" + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n" + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>" + "SELECT ?event ?time ?point ?wkt " + "WHERE { " + " ?event time:atTime ?time . " + " ?event geo:asWKT ?wkt . " + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-3 -2, -3 2, 1 2, 1 -2, -3 -2))\"^^geo:wktLiteral)) " + " FILTER(tempo:equals(?time, \"2015-12-30T12:00:00Z\")) " + "}";
final EventQueryNode node = buildNode(storage, query);
final CloseableIteration<BindingSet, QueryEvaluationException> rez = node.evaluate(new MapBindingSet());
final MapBindingSet expected1 = new MapBindingSet();
expected1.addBinding("wkt", VF.createLiteral("POINT (1 1)"));
expected1.addBinding("time", VF.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString()));
final MapBindingSet expected2 = new MapBindingSet();
expected2.addBinding("wkt", VF.createLiteral("POINT (-1 -1)"));
expected2.addBinding("time", VF.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString()));
final List<BindingSet> actual = new ArrayList<>();
while (rez.hasNext()) {
actual.add(rez.next());
}
assertEquals(expected1, actual.get(0));
assertEquals(expected2, actual.get(1));
assertEquals(2, actual.size());
}
Aggregations