Search in sources :

Example 1 with CloseableIteration

use of info.aduna.iteration.CloseableIteration in project blueprints by tinkerpop.

the class GraphSailConnection method getStatementsInternal.

public CloseableIteration<? extends Statement, SailException> getStatementsInternal(final Resource subject, final URI predicate, final Value object, final boolean includeInferred, final Resource... contexts) throws SailException {
    int index = 0;
    if (null != subject) {
        index |= 0x1;
    }
    if (null != predicate) {
        index |= 0x2;
    }
    if (null != object) {
        index |= 0x4;
    }
    if (0 == contexts.length) {
        return createIteration(store.matchers[index].match(subject, predicate, object, null, includeInferred));
    } else {
        Collection<CloseableIteration<Statement, SailException>> iterations = new LinkedList<CloseableIteration<Statement, SailException>>();
        // TODO: as an optimization, filter on multiple contexts simultaneously (when context is not used in the matcher), rather than trying each context consecutively.
        for (Resource context : contexts) {
            index |= 0x8;
            Matcher m = store.matchers[index];
            iterations.add(createIteration(m.match(subject, predicate, object, context, includeInferred)));
        }
        return new CompoundCloseableIteration<Statement, SailException>(iterations);
    }
}
Also used : CloseableIteration(info.aduna.iteration.CloseableIteration) CompoundCloseableIteration(net.fortytwo.sesametools.CompoundCloseableIteration) CompoundCloseableIteration(net.fortytwo.sesametools.CompoundCloseableIteration) Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource) SailException(org.openrdf.sail.SailException) LinkedList(java.util.LinkedList)

Aggregations

CloseableIteration (info.aduna.iteration.CloseableIteration)1 LinkedList (java.util.LinkedList)1 CompoundCloseableIteration (net.fortytwo.sesametools.CompoundCloseableIteration)1 Resource (org.openrdf.model.Resource)1 Statement (org.openrdf.model.Statement)1 SailException (org.openrdf.sail.SailException)1