import gnu.trove.procedure.TIntProcedure;
-final public class TypeHierarchy extends UnaryQuery<InternalProcedure<IntSet>> {
+final public class TypeHierarchy extends UnaryQueryP<IntSet> {
TypeHierarchy(final int resource) {
super(resource);
provider.cache.remove(this);
}
- //@Override
- public IntSet compute(ReadGraphImpl graph, final InternalProcedure<IntSet> procedure) throws DatabaseException {
+ @Override
+ public void compute(final ReadGraphImpl graph, final InternalProcedure<IntSet> procedure) throws DatabaseException {
+ computeForEach(graph, id, this, procedure);
+ }
+
+ public static IntSet computeForEach(ReadGraphImpl graph, int id, TypeHierarchy entry, final InternalProcedure<IntSet> procedure_) throws DatabaseException {
+
+ InternalProcedure<IntSet> procedure = entry != null ? entry : procedure_;
QueryProcessor processor = graph.processor;
}
};
- QueryCache.runnerSuperTypes(graph, id, TypeHierarchy.this, null, new InternalProcedure<IntSet>() {
+ QueryCache.runnerSuperTypes(graph, id, entry, null, new InternalProcedure<IntSet>() {
@Override
public void execute(ReadGraphImpl graph, IntSet types) throws DatabaseException {
-
types.forEach(addToResult);
- addOrSet(graph, result, processor);
procedure.execute(graph, result);
-
}
@Override
});
- return result;
-
- }
-
- @Override
- public String toString() {
- return "TypeHierarchy[" + id + "]";
- }
-
- private void addOrSet(ReadGraphImpl graph, final IntSet value, QueryProcessor provider) {
-
- assert(!isReady());
-
- synchronized(this) {
-
- value.trim();
- setResult(value);
- setReady();
-
- }
-
- }
-
- @Override
- public Object performFromCache(ReadGraphImpl graph, InternalProcedure<IntSet> procedure) throws DatabaseException {
-
- assert(isReady());
-
- if(handleException(graph, procedure)) return null;
-
- IntSet result = getResult();
-
- procedure.execute(graph, result);
+ if(entry != null) entry.performFromCache(graph, procedure_);
return result;
-
- }
-
- @Override
- public void recompute(ReadGraphImpl graph) throws DatabaseException {
-
- compute(graph, new InternalProcedure<IntSet>() {
-
- @Override
- public void execute(ReadGraphImpl graph, IntSet result) {
- }
-
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) {
- new Error("Error in recompute.", t).printStackTrace();
- }
- });
-
}
@Override
- boolean isImmutable(ReadGraphImpl graph) {
- return graph.processor.isImmutable(id);
+ public String toString() {
+ return "TypeHierarchy[" + id + "]";
}
}