@Test public void singleIterator() { final String rowKey1 = UUIDGenerator.newTimeUUID().toString(); final long maxValue = 10000; Observable.just( rowKey1 ).flatMap( rowKey -> Observable.just( rowKey ).doOnNext( key -> { final MutationBatch batch = keyspace.prepareMutationBatch(); for ( long i = 0; i < maxValue; i++ ) { batch.withRow( COLUMN_FAMILY, key ).putColumn( i, TRUE ); if ( i % 1000 == 0 ) { try { batch.execute(); } catch ( ConnectionException e ) { throw new RuntimeException( e ); } } } try { batch.execute(); } catch ( ConnectionException e ) { throw new RuntimeException( e ); } } ).subscribeOn( Schedulers.io() ) ).toBlocking().last(); final ColumnParser<Long, Long> longParser = new ColumnParser<Long, Long>() { @Override public Long parseColumn( final Column<Long> column ) { return column.getName(); } }; final ColumnSearch<Long> ascendingSearch = new ColumnSearch<Long>() { @Override public void buildRange(final RangeBuilder rangeBuilder, final Long value, Long end) { rangeBuilder.setStart( value ); } @Override public void buildRange( final RangeBuilder rangeBuilder ) { } @Override public boolean skipFirst( final Long first ) { return false; } }; final Comparator<Long> ascendingComparator = new Comparator<Long>() { @Override public int compare( final Long o1, final Long o2 ) { return Long.compare( o1, o2 ); } }; final Collection<String> rowKeys = Arrays.asList( rowKey1 ); MultiRowColumnIterator<String, Long, Long> ascendingItr = new MultiRowColumnIterator<>( keyspace, COLUMN_FAMILY, ConsistencyLevel.CL_QUORUM, longParser, ascendingSearch, ascendingComparator, rowKeys, 712 ); for ( long i = 0; i < maxValue; i++ ) { assertEquals( i, ascendingItr.next().longValue() ); } final ColumnSearch<Long> descendingSearch = new ColumnSearch<Long>() { @Override public void buildRange(final RangeBuilder rangeBuilder, final Long value, Long end) { rangeBuilder.setStart( value ); buildRange( rangeBuilder ); } @Override public void buildRange( final RangeBuilder rangeBuilder ) { rangeBuilder.setReversed( true ); } @Override public boolean skipFirst( final Long first ) { return false; } }; final Comparator<Long> descendingComparator = new Comparator<Long>() { @Override public int compare( final Long o1, final Long o2 ) { return ascendingComparator.compare( o1, o2 ) * -1; } }; MultiRowColumnIterator<String, Long, Long> descendingItr = new MultiRowColumnIterator<>( keyspace, COLUMN_FAMILY, ConsistencyLevel.CL_QUORUM, longParser, descendingSearch, descendingComparator, rowKeys, 712 ); for ( long i = maxValue - 1; i > -1; i-- ) { assertEquals( i, descendingItr.next().longValue() ); } }
@Override public T next() { if ( !hasNext() ) { throw new NoSuchElementException( "No new element exists" ); } final T next = currentColumnIterator.next(); return next; }
MultiRowColumnIterator implements Iterator<T> { @Override public T next() { if ( !hasNext() ) { throw new NoSuchElementException( "No new element exists" ); } final T next = currentColumnIterator.next(); return next; } }
MultiRowColumnIterator implements Iterator<T> { @Override public T next() { if ( !hasNext() ) { throw new NoSuchElementException( "No new element exists" ); } final T next = currentColumnIterator.next(); return next; } MultiRowColumnIterator( final Keyspace keyspace, final ColumnFamily<R, C> cf,
                                   final ConsistencyLevel consistencyLevel, final ColumnParser<C, T> columnParser,
                                   final ColumnSearch<T> columnSearch, final Comparator<T> comparator,
                                   final Collection<R> rowKeys, final int pageSize ); }
MultiRowColumnIterator implements Iterator<T> { @Override public T next() { if ( !hasNext() ) { throw new NoSuchElementException( "No new element exists" ); } final T next = currentColumnIterator.next(); return next; } MultiRowColumnIterator( final Keyspace keyspace, final ColumnFamily<R, C> cf,
                                   final ConsistencyLevel consistencyLevel, final ColumnParser<C, T> columnParser,
                                   final ColumnSearch<T> columnSearch, final Comparator<T> comparator,
                                   final Collection<R> rowKeys, final int pageSize ); @Override boolean hasNext(); @Override T next(); @Override void remove(); void advance(); }
MultiRowColumnIterator implements Iterator<T> { @Override public T next() { if ( !hasNext() ) { throw new NoSuchElementException( "No new element exists" ); } final T next = currentColumnIterator.next(); return next; } MultiRowColumnIterator( final Keyspace keyspace, final ColumnFamily<R, C> cf,
                                   final ConsistencyLevel consistencyLevel, final ColumnParser<C, T> columnParser,
                                   final ColumnSearch<T> columnSearch, final Comparator<T> comparator,
                                   final Collection<R> rowKeys, final int pageSize ); @Override boolean hasNext(); @Override T next(); @Override void remove(); void advance();  }