@Test public void multiIterator() { final String rowKey1 = UUIDGenerator.newTimeUUID().toString(); final String rowKey2 = UUIDGenerator.newTimeUUID().toString(); final String rowKey3 = UUIDGenerator.newTimeUUID().toString(); final long maxValue = 10000; Observable.from( new String[] { rowKey1, rowKey2, rowKey3 } ) .flatMap( stringObservable -> Observable.just( stringObservable ).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(); ColumnNameIterator<Long, Long> row1Iterator = createIterator( rowKey1, false ); ColumnNameIterator<Long, Long> row2Iterator = createIterator( rowKey2, false ); ColumnNameIterator<Long, Long> row3Iterator = createIterator( rowKey3, false ); final Comparator<Long> ascendingComparator = new Comparator<Long>() { @Override public int compare( final Long o1, final Long o2 ) { return Long.compare( o1, o2 ); } }; final MultiKeyColumnNameIterator<Long, Long> ascendingItr = new MultiKeyColumnNameIterator<>( Arrays.asList( row1Iterator, row2Iterator, row3Iterator ), ascendingComparator, 900 ); for ( long i = 0; i < maxValue; i++ ) { assertEquals( i, ascendingItr.next().longValue() ); } ColumnNameIterator<Long, Long> row1IteratorDesc = createIterator( rowKey1, true ); ColumnNameIterator<Long, Long> row2IteratorDesc = createIterator( rowKey2, true ); ColumnNameIterator<Long, Long> row3IteratorDesc = createIterator( rowKey3, true ); final Comparator<Long> descendingComparator = new Comparator<Long>() { @Override public int compare( final Long o1, final Long o2 ) { return ascendingComparator.compare( o1, o2 ) * -1; } }; final MultiKeyColumnNameIterator<Long, Long> descendingItr = new MultiKeyColumnNameIterator<>( Arrays.asList( row1IteratorDesc, row2IteratorDesc, row3IteratorDesc ), descendingComparator, 900 ); for ( long i = maxValue - 1; i > -1; i-- ) { assertEquals( i, descendingItr.next().longValue() ); } }
@Override public T next() { return iterator.next(); }
MultiKeyColumnNameIterator implements Iterable<T>, Iterator<T> { @Override public T next() { return iterator.next(); } }
MultiKeyColumnNameIterator implements Iterable<T>, Iterator<T> { @Override public T next() { return iterator.next(); } MultiKeyColumnNameIterator( final Collection<ColumnNameIterator<C, T>> columnNameIterators,
                                       final Comparator<T> comparator, final int bufferSize ); }
MultiKeyColumnNameIterator implements Iterable<T>, Iterator<T> { @Override public T next() { return iterator.next(); } MultiKeyColumnNameIterator( final Collection<ColumnNameIterator<C, T>> columnNameIterators,
                                       final Comparator<T> comparator, final int bufferSize ); @Override Iterator<T> iterator(); @Override boolean hasNext(); @Override T next(); @Override void remove(); }
MultiKeyColumnNameIterator implements Iterable<T>, Iterator<T> { @Override public T next() { return iterator.next(); } MultiKeyColumnNameIterator( final Collection<ColumnNameIterator<C, T>> columnNameIterators,
                                       final Comparator<T> comparator, final int bufferSize ); @Override Iterator<T> iterator(); @Override boolean hasNext(); @Override T next(); @Override void remove();  }