Search in sources :

Example 1 with EventQueryNodeBuilder

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;
    }
}
Also used : Var(org.openrdf.query.algebra.Var) IndexingFunctionRegistry(org.apache.rya.indexing.IndexingFunctionRegistry) ArrayList(java.util.ArrayList) EventQueryNodeBuilder(org.apache.rya.indexing.geotemporal.model.EventQueryNode.EventQueryNodeBuilder) StatementPattern(org.openrdf.query.algebra.StatementPattern) FUNCTION_TYPE(org.apache.rya.indexing.IndexingFunctionRegistry.FUNCTION_TYPE) Collection(java.util.Collection) FunctionCall(org.openrdf.query.algebra.FunctionCall) IndexingExpr(org.apache.rya.indexing.IndexingExpr)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 IndexingExpr (org.apache.rya.indexing.IndexingExpr)1 IndexingFunctionRegistry (org.apache.rya.indexing.IndexingFunctionRegistry)1 FUNCTION_TYPE (org.apache.rya.indexing.IndexingFunctionRegistry.FUNCTION_TYPE)1 EventQueryNodeBuilder (org.apache.rya.indexing.geotemporal.model.EventQueryNode.EventQueryNodeBuilder)1 FunctionCall (org.openrdf.query.algebra.FunctionCall)1 StatementPattern (org.openrdf.query.algebra.StatementPattern)1 Var (org.openrdf.query.algebra.Var)1