All rows query - marcusbb/astyanax GitHub Wiki

A common (and arguably bad) use case for cassandra clients is to read all the data in a column family. Astyanax provides a recipe to perform this operation in parallel and using pagination so as not to put excessive heap pressure on the Cassandra nodes.

boolean result = new AllRowsReader.Builder<String, String>(keyspace, CF_STANDARD1)
        .forEachRow(new Function<Row<String, String>, Boolean>() {
            @Override
            public Boolean apply(@Nullable Row<String, String> row) {
                // Process the row here ...
                return true;
            }
        })
        .build()
        .call();

Reading only the row keys

boolean result = new AllRowsReader.Builder<String, String>(keyspace, CF_STANDARD1)
        .withColumnRange(null, null, false, 0)
        .forEachRow(new Function<Row<String, String>, Boolean>() {
            @Override
            public Boolean apply(@Nullable Row<String, String> row) {
                // Process the row here ...
                return true;
            }
        })
        .build()
        .call();