RDBURIReferences implements URIReferences, Closeable { public Iterator<AbstractMap.SimpleEntry<String, List<String>>> walkThroughCrawledGraph(int offset, boolean latest, boolean onlyCrawledUris) { long entryCount = r.db(DATABASE_NAME).table(TABLE_NAME).count().run(connector.connection); if (entryCount <= offset) { if (latest) { LOGGER.debug("Your offset (" + offset + ") is higher or equal than the number of entries (" + entryCount + "), so we'll return an iterator over the whole graph from the beginning!"); } else { LOGGER.warn("Your offset (" + offset + ") is higher or equal than the number of entries (" + entryCount + ")! Return an empty iterator..."); return Collections.emptyIterator(); } } long finalOffset = (offset < 0) ? -1 : ((latest) ? entryCount - offset : offset); return new org.dice_research.squirrel.data.uri.info.URIReferencesIterator(connector, finalOffset, onlyCrawledUris); } RDBURIReferences(String hostname, Integer port);  RDBURIReferences(String hostname, Integer port, URIShortcutMode mode); void open(); synchronized void add(CrawleableUri uri, List<CrawleableUri> urisFound); @Override void close(); Iterator<AbstractMap.SimpleEntry<String, List<String>>> walkThroughCrawledGraph(int offset, boolean latest, boolean onlyCrawledUris); static final String DATABASE_NAME; static final String TABLE_NAME; static final String COLUMN_URI; static final String COLUMN_FOUNDURIS; }
@Test public void walkThroughCrawledGraph() { assertTrue("Get iterator for crawled graph. Should contain only one empty entry because \"onlyCrawledURIs\" is true", rdburiReferences.walkThroughCrawledGraph(1, true, true).next().getValue().isEmpty()); assertTrue("Get iterator for crawled graph. Should be not empty because \"onlyCrawledURIs\" is false", rdburiReferences.walkThroughCrawledGraph(1, true, false).hasNext()); assertFalse("Get iterator for crawled graph. Should be empty because \"offset\" is 2 (skip 2 from the beginning) and we have only 2 entries", rdburiReferences.walkThroughCrawledGraph(2, false, false).hasNext()); }