Github user ejwhite922 commented on a diff in the pull request:
https://github.com/apache/incubator-rya/pull/218#discussion_r135882345
--- Diff:
sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java
---
@@ -405,6 +382,30 @@ public void refreshGraph() throws
InferenceEngineException {
}
/**
+ * Query for and collect all instances of a given type. Should only be
called for types expected
+ * to have few members, such as ontology vocabulary terms, as
instances will be collected in
+ * memory.
+ */
+ private Set<URI> fetchInstances(final URI type) throws
QueryEvaluationException {
+ final Set<URI> instances = new HashSet<>();
+ CloseableIteration<Statement, QueryEvaluationException> iter =
RyaDAOHelper.query(
+ ryaDAO, null, RDF.TYPE, type, conf);
+ try {
+ while (iter.hasNext()) {
+ final Statement st = iter.next();
+ if (st.getSubject() instanceof URI) {
+ instances.add((URI) st.getSubject());
+ }
+ }
+ } finally {
+ if (iter != null) {
+ iter.close();
+ }
+ }
--- End diff --
This can be reduced to:
```
ryaDaoQueryWrapper.queryAll(null, RDF.TYPE, type, new
RDFHandlerBase() {
@Override
public void handleStatement(final Statement st) throws
RDFHandlerException {
if (st.getSubject() instanceof URI) {
instances.add((URI) st.getSubject());
}
}
});
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---