@Test public void getAll() throws Exception { AtomicLong counter = new AtomicLong(0); OperationResult<Rows<String, String>> rows = keyspace .prepareQuery(CF_ALL_ROWS).getAllRows().setConcurrencyLevel(2).setRowLimit(30) //.withColumnRange(new RangeBuilder().setLimit(0).build()) .setExceptionCallback(new ExceptionCallback() { @Override public boolean onException(ConnectionException e) { Assert.fail(e.getMessage()); return true; } }).execute(); for (Row<String, String> row : rows.getResult()) { counter.incrementAndGet(); LOG.info("ROW: " + row.getKey() + " " + row.getColumns().size()); } LOG.info("Read " + counter.get() + " keys"); Assert.assertEquals(26, counter.get()); } }
/** * Get all rows of the specified item * * @param columnFamily * column family of the item * @param itemClass * item's class * @return new instances with the item's columns propagated * @throws Exception * errors */ public <T, K> List<T> getAll(ColumnFamily<K, String> columnFamily, Class<T> itemClass) throws Exception { Mapping<T> mapping = getMapping(itemClass); Rows<K, String> result = keyspace.prepareQuery(columnFamily) .getAllRows().execute().getResult(); return mapping.getAll(result); }
setRowLimit(numRows). setIncludeEmptyRows(false). execute();