QueryHandler queryHandler = graph.queryHandler() ;
ExtendedIterator<Node> subjects = queryHandler.subjectsFor(Node.ANY, Node.ANY) ;
try {
Map<Node, Set<Node>> predicates = new HashMap<Node, Set<Node>>() ;
while ( subjects.hasNext() ) {
Node subject = subjects.next() ;
ExtendedIterator<Triple> triples = graph.find(subject, Node.ANY, Node.ANY) ;
try {
while ( triples.hasNext() ) {
Triple triple = triples.next() ;
Node p = triple.getPredicate() ;
if ( predicates.containsKey(p) ) {
predicates.get(p).add(triple.getObject()) ;
} else {
Set<Node> objects = new HashSet<Node>() ;
objects.add(triple.getObject()) ;