@Override public boolean hasPages(){ return results != null && results.hasCursor(); }
private void advance(){ //map to our old results objects, return a default empty if required final Observable<Results> observable = buildNewResultsPage( cursor ).map( resultsPage -> createResultsInternal( resultsPage ) ).defaultIfEmpty( new Results() ); if (logger.isTraceEnabled()) { logger.trace("Trying to load results page"); } //take the first from our observable final Results resultsPage = observable.take(1).toBlocking().first(); if (logger.isTraceEnabled()) { logger.trace("Results page loaded {}", resultsPage); } //set the results for the iterator this.results = resultsPage; //set the complete flag this.complete = !resultsPage.hasCursor(); //if not comlete, set our cursor for the next iteration if(!complete){ this.cursor = Optional.of( results.getCursor()); }else{ this.cursor = Optional.absent(); } }
while ( results.hasCursor() );
while ( results.hasCursor() );
while ( results.hasCursor() );
while ( results.hasCursor() );
while ( results.hasCursor() );
while ( results.hasCursor() );
while (r.hasCursor());
private int countEntities( EntityManager em, String collectionName, int expectedEntities) throws Exception { app.waitForQueueDrainAndRefreshIndex(); Query q = Query.fromQL( "select * where key1=1000" ).withLimit( 1000 ); Results results = em.searchCollectionConsistent( em.getApplicationRef(), collectionName, q, expectedEntities ); int count = 0; while ( true ) { count += results.size(); if ( results.hasCursor() ) { logger.info( "Counted {} : query again with cursor", count ); q.setCursor( results.getCursor() ); results = em.searchCollection( em.getApplicationRef(), collectionName, q ); } else { break; } } assertEquals( "Did not get expected entities", expectedEntities, count ); return count; }
private int countEntities( EntityManager em, String collectionName, int expectedEntities) throws Exception { app.waitForQueueDrainAndRefreshIndex(); Query q = Query.fromQL( "select * where key1=1000" ).withLimit( 1000 ); Results results = em.searchCollectionConsistent( em.getApplicationRef(), collectionName, q, expectedEntities ); int count = 0; while ( true ) { count += results.size(); if ( results.hasCursor() ) { logger.info( "Counted {} : query again with cursor", count ); q.setCursor( results.getCursor() ); results = em.searchCollection( em.getApplicationRef(), collectionName, q ); } else { break; } } assertEquals( "Did not get expected entities", expectedEntities, count ); return count; }
private int readData( EntityManager em, String collectionName, int expectedEntities, int expectedConnections ) throws Exception { app.waitForQueueDrainAndRefreshIndex(); Query q = Query.fromQL( "select * where key1=1000" ).withLimit( 1000 ); Results results = em.searchCollectionConsistent( em.getApplicationRef(), collectionName, q, expectedEntities ); int count = 0; while ( true ) { for ( Entity e : results.getEntities() ) { assertEquals( 2000, e.getProperty( "key2" ) ); Results catResults = em.searchTargetEntities( e, Query.fromQL( "select *" ).setConnectionType( "herds" ) ); assertEquals( expectedConnections, catResults.size() ); if ( count % 100 == 0 ) { logger.info( "read {} entities", count ); } count++; } if ( results.hasCursor() ) { logger.info( "Counted {} : query again with cursor", count ); q.setCursor( results.getCursor() ); results = em.searchCollection( em.getApplicationRef(), collectionName, q ); } else { break; } } return count; }