@Test public void testGetListsForkedValidStressShallow() { int iCount = 30; int kCount = 60; Set<Resource> heads = new HashSet<>((int) (iCount * 1.5)); for (int i = 0; i < iCount; i++) { BNode nextHeadBNode = vf.createBNode("i-" + i); BNode nextRestBNode = nextHeadBNode; for (int k = 0; k < kCount; k++) { BNode nextTreeBNode1 = vf.createBNode("i-" + i + "_k-" + k + "_a"); BNode nextTreeBNode2 = vf.createBNode("i-" + i + "_k-" + k + "_b"); Statement nextTestStatement1 = vf.createStatement( nextRestBNode, RDF.FIRST, vf.createLiteral("literal: i-" + i + "_k-" + k)); this.testGraph.add(nextTestStatement1); Statement nextTestStatement2 = vf.createStatement(nextRestBNode, RDF.REST, nextTreeBNode1); this.testGraph.add(nextTestStatement2); Statement nextTestStatement3 = vf.createStatement(nextRestBNode, RDF.REST, nextTreeBNode2); this.testGraph.add(nextTestStatement3); Statement nextTestNilStatement1 = vf.createStatement( nextTreeBNode2, RDF.FIRST, vf.createLiteral("terminating i-" + i + "_k-" + k + "_b")); this.testGraph.add(nextTestNilStatement1); Statement nextTestNilStatement2 = vf.createStatement( nextTreeBNode2, RDF.REST, RDF.NIL); this.testGraph.add(nextTestNilStatement2); if (k == kCount - 1) { Statement nextTestNilStatement3 = vf.createStatement( nextTreeBNode1, RDF.FIRST, vf.createLiteral("terminating i-" + i + "_k-" + k + "_a")); this.testGraph.add(nextTestNilStatement3); Statement nextTestNilStatement4 = vf.createStatement(nextTreeBNode1, RDF.REST, RDF.NIL); this.testGraph.add(nextTestNilStatement4); } else { nextRestBNode = nextTreeBNode1; } } heads.add(nextHeadBNode); } int expectedGraphCount = ( (iCount * kCount * 5) + (iCount * 2) ); log.info("expectedGraphCount=" + expectedGraphCount); log.info("this.testGraph.size()=" + this.testGraph.size()); assertEquals(expectedGraphCount, this.testGraph.size()); log.info("start"); final Collection<List<Value>> results = this.testRdfListUtilDefaults.getLists(heads, this.testGraph); log.info("end"); int expectedResultsCount = ( (iCount * kCount) + iCount); log.info("expectedResultsCount=" + expectedResultsCount); log.info("results.size()=" + results.size()); assertEquals(expectedResultsCount, results.size()); }
public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; }
RdfListUtil { public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; } }
RdfListUtil { public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; } RdfListUtil();  RdfListUtil(boolean checkCycles, boolean checkIncomplete, boolean useIterativeOnError); }
RdfListUtil { public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; } RdfListUtil();  RdfListUtil(boolean checkCycles, boolean checkIncomplete, boolean useIterativeOnError); void addList(final Resource head,
                        final List<Value> nextValues,
                        final Model graphToAddTo,
                        final Resource... contexts); void addListAtNode(final Resource subject,
                              final IRI predicate, final List<Value> nextValues,
                              final Model graphToAddTo, final Resource... contexts); List<Value> getList(final Resource head,
                               final Model graphToSearch, final Resource... contexts); List<Value> getListAtNode(final Resource subject,
                                     final IRI predicate,
                                     final Model graphToSearch,
                                     final Resource... contexts); Collection<List<Value>> getListsIterative(final Set<Resource> heads,
                                                     final Model graphToSearch,
                                                     final Resource... contexts); Collection<List<Value>> getLists(final Set<Resource> heads,
                                            final Model graphToSearch,
                                            final Resource... contexts); Collection<List<Value>> getListsRecursive(final Resource head,
                                                     final Model graph,
                                                     final Resource... contexts); Collection<List<Value>> getListsAtNode(
            final Resource subject, final IRI predicate,
            final Model graphToSearch, final Resource... contexts); boolean getCheckCycles(); boolean getCheckIncomplete(); boolean getUseIterativeOnError(); }
RdfListUtil { public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; } RdfListUtil();  RdfListUtil(boolean checkCycles, boolean checkIncomplete, boolean useIterativeOnError); void addList(final Resource head,
                        final List<Value> nextValues,
                        final Model graphToAddTo,
                        final Resource... contexts); void addListAtNode(final Resource subject,
                              final IRI predicate, final List<Value> nextValues,
                              final Model graphToAddTo, final Resource... contexts); List<Value> getList(final Resource head,
                               final Model graphToSearch, final Resource... contexts); List<Value> getListAtNode(final Resource subject,
                                     final IRI predicate,
                                     final Model graphToSearch,
                                     final Resource... contexts); Collection<List<Value>> getListsIterative(final Set<Resource> heads,
                                                     final Model graphToSearch,
                                                     final Resource... contexts); Collection<List<Value>> getLists(final Set<Resource> heads,
                                            final Model graphToSearch,
                                            final Resource... contexts); Collection<List<Value>> getListsRecursive(final Resource head,
                                                     final Model graph,
                                                     final Resource... contexts); Collection<List<Value>> getListsAtNode(
            final Resource subject, final IRI predicate,
            final Model graphToSearch, final Resource... contexts); boolean getCheckCycles(); boolean getCheckIncomplete(); boolean getUseIterativeOnError(); final static boolean DEFAULT_CHECK_CYCLES; final static boolean DEFAULT_CHECK_INCOMPLETE; final static boolean DEFAULT_USE_ITERATIVE_ON_ERROR; }