Search in sources :

Example 1 with AbstractIterator

use of com.datastax.oss.driver.shaded.guava.common.collect.AbstractIterator in project dsbulk by datastax.

the class ContinuousReadResultSubscription method toPage.

@Override
Page toPage(ContinuousAsyncResultSet rs, ExecutionContext local) {
    Iterator<Row> rows = rs.currentPage().iterator();
    Iterator<ReadResult> results = new AbstractIterator<ReadResult>() {

        @Override
        protected ReadResult computeNext() {
            if (rows.hasNext()) {
                Row row = rows.next();
                if (listener != null) {
                    listener.onRowReceived(row, local);
                }
                return new DefaultReadResult(statement, rs.getExecutionInfo(), row);
            }
            return endOfData();
        }
    };
    return new ContinuousPage(rs, results);
}
Also used : ReadResult(com.datastax.oss.dsbulk.executor.api.result.ReadResult) DefaultReadResult(com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult) Row(com.datastax.oss.driver.api.core.cql.Row) AbstractIterator(com.datastax.oss.driver.shaded.guava.common.collect.AbstractIterator) DefaultReadResult(com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult)

Example 2 with AbstractIterator

use of com.datastax.oss.driver.shaded.guava.common.collect.AbstractIterator in project dsbulk by datastax.

the class ReadResultSubscription method toPage.

@Override
Page toPage(AsyncResultSet rs, ExecutionContext local) {
    Iterator<Row> rows = rs.currentPage().iterator();
    Iterator<ReadResult> results = new AbstractIterator<ReadResult>() {

        @Override
        protected ReadResult computeNext() {
            if (rows.hasNext()) {
                Row row = rows.next();
                if (listener != null) {
                    listener.onRowReceived(row, local);
                }
                return new DefaultReadResult(statement, rs.getExecutionInfo(), row);
            }
            return endOfData();
        }
    };
    return new Page(results, rs.hasMorePages() ? rs::fetchNextPage : null);
}
Also used : ReadResult(com.datastax.oss.dsbulk.executor.api.result.ReadResult) DefaultReadResult(com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult) Row(com.datastax.oss.driver.api.core.cql.Row) AbstractIterator(com.datastax.oss.driver.shaded.guava.common.collect.AbstractIterator) DefaultReadResult(com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult)

Aggregations

Row (com.datastax.oss.driver.api.core.cql.Row)2 AbstractIterator (com.datastax.oss.driver.shaded.guava.common.collect.AbstractIterator)2 DefaultReadResult (com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult)2 ReadResult (com.datastax.oss.dsbulk.executor.api.result.ReadResult)2