use of org.springframework.data.cassandra.core.query.CassandraPageRequest in project spring-data-cassandra by spring-projects.
the class SimpleCassandraRepositoryUnitTests method shouldSelectWithPaging.
// DATACASS-56
@Test
void shouldSelectWithPaging() {
CassandraPageRequest pageRequest = CassandraPageRequest.first(10, Direction.ASC, "foo");
repository = new SimpleCassandraRepository<Object, String>(new MappingCassandraEntityInformation(converter.getMappingContext().getRequiredPersistentEntity(SimplePerson.class), converter), cassandraOperations);
repository.findAll(pageRequest);
verify(cassandraOperations).slice(Query.empty().sort(pageRequest.getSort()).queryOptions(QueryOptions.builder().pageSize(10).build()), SimplePerson.class);
}
use of org.springframework.data.cassandra.core.query.CassandraPageRequest in project spring-data-cassandra by spring-projects.
the class EntityQueryUtils method readSlice.
/**
* Read a {@link Slice} of data from the {@link Iterable} of {@link Row}s for a {@link Pageable}.
*
* @param rows must not be {@literal null}.
* @param pagingState
* @param mapper must not be {@literal null}.
* @param page
* @param pageSize
* @return the resulting {@link Slice}.
* @since 2.1
*/
static <T> Slice<T> readSlice(Iterable<Row> rows, @Nullable ByteBuffer pagingState, RowMapper<T> mapper, int page, int pageSize) {
List<T> result = new ArrayList<>(pageSize);
Iterator<Row> iterator = rows.iterator();
int index = 0;
while (iterator.hasNext()) {
T element = mapper.mapRow(iterator.next(), index++);
result.add(element);
}
CassandraPageRequest pageRequest = CassandraPageRequest.of(PageRequest.of(page, pageSize), pagingState);
return new SliceImpl<>(result, pageRequest, pagingState != null);
}
Aggregations