-
Notifications
You must be signed in to change notification settings - Fork 354
Paginating
smarsching edited this page Oct 19, 2014
·
2 revisions
cqlsh:astyanaxunittests> describe columnfamily paginate1;
CREATE TABLE paginate1 (
key int,
column1 int,
value int,
PRIMARY KEY (key, column1)
) WITH COMPACT STORAGE AND
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
cqlsh:astyanaxunittests> select * from paginate1;
key | column1 | value
-----+---------+-------
1 | 0 | 1
1 | 1 | 1
1 | 2 | 1
1 | 3 | 1
1 | 4 | 1
1 | 5 | 1
1 | 6 | 1
1 | 7 | 1
1 | 8 | 1
1 | 9 | 1
cqlsh:astyanaxunittests>
Keyspace ks = ....;
MutationBatch m = ks.prepareMutationBatch();
for (int i=0; i<=9; i++) {
m.withRow(CF, 1).putColumn(i, 1);
}
m.execute();
RowQuery<Integer, Integer> query = ks.prepareQuery(CF)
.getRow(1)
.withColumnRange(0, 9, false, 4)
.autoPaginate(true);
OperationResult<ColumnList<Integer>> result;
while (!(result = query.execute()).getResult().isEmpty()) {
System.out.println("\nNEXT PAGE \n");
for (Column<Integer> col : result.getResult()) {
System.out.println(col.getName() + " " + col.getIntegerValue());
}
}
RowQuery<Integer, Integer> query = ks.prepareQuery(CF)
.getRow(1)
.withColumnRange(9, 0, true, 4)
.autoPaginate(true);
OperationResult<ColumnList<Integer>> result;
while (!(result = query.execute()).getResult().isEmpty()) {
System.out.println("\nNEXT PAGE \n");
for (Column<Integer> col : result.getResult()) {
System.out.println(col.getName() + " " + col.getIntegerValue());
}
}
A Netflix Original Production
Tech Blog | Twitter @NetflixOSS | Jobs
- Getting-Started
- Configuration
- Features
- Monitoring
- Thread Safety
- Timeouts
- Recipes
- Examples
- Javadoc
- Utilities
- Cassandra-Compatibility
- FAQ
- End-to-End Examples
- Astyanax Integration with Java Driver