use of org.apache.rya.indexing.geotemporal.model.EventQueryNode.EventQueryNodeBuilder in project incubator-rya by apache.
the class GeoTemporalIndexSetProvider method getGeoTemporalNode.
private EventQueryNode getGeoTemporalNode(final Var subj) {
final Collection<StatementPattern> patterns = patternMap.get(subj);
final Collection<FunctionCall> usedFilters = new ArrayList<>();
Optional<StatementPattern> geoPattern = Optional.empty();
Optional<StatementPattern> temporalPattern = Optional.empty();
Optional<Collection<IndexingExpr>> geoFilters = Optional.empty();
Optional<Collection<IndexingExpr>> temporalFilters = Optional.empty();
// should only be 2 patterns.
for (final StatementPattern sp : patterns) {
final Var obj = sp.getObjectVar();
if (filterMap.containsKey(obj)) {
final Collection<IndexingExpr> filters = filterMap.get(obj);
final IndexingFunctionRegistry.FUNCTION_TYPE type = ensureSameType(filters);
if (type != null && type == FUNCTION_TYPE.GEO) {
geoPattern = Optional.of(sp);
geoFilters = Optional.of(filters);
usedFilters.addAll(matchedFilters.get(obj));
} else if (type != null && type == FUNCTION_TYPE.TEMPORAL) {
temporalPattern = Optional.of(sp);
temporalFilters = Optional.of(filters);
usedFilters.addAll(matchedFilters.get(obj));
} else {
return null;
}
} else {
return null;
}
}
if (geoFilters.isPresent() && temporalFilters.isPresent() && geoPattern.isPresent() && temporalPattern.isPresent()) {
return new EventQueryNodeBuilder().setStorage(eventStorage).setGeoPattern(geoPattern.get()).setTemporalPattern(temporalPattern.get()).setGeoFilters(geoFilters.get()).setTemporalFilters(temporalFilters.get()).setUsedFilters(usedFilters).build();
} else {
return null;
}
}
Aggregations