incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Wright <>
Subject Re: how-to scan a table using CQL3
Date Fri, 10 May 2013 20:33:54 GMT
What you are proposing should work and I started to implement that using
multiple threads over the token ranges but decided instead to use to
Astyanax's read all rows recipe as it does much of that already.  It
required some work to convert the composite CQL2 format returned from
Astayanx into what is expected for CQL3 but did work.  Here's an outline
of what you would do:

	.forEachPage(new Function<Rows<String, Composite>, Boolean>() {
		public Boolean apply(Rows<String, Composite> rows) {
			try {
				for (Row<String,Composite> row : rows) {
					// rowkey serializer matches the time of the first column in your
primary key definition
					String rowKey =
					for (Column<Composite> column : row.getColumns()) {
						// the first portion of the column name composite is the parts of
your primary definition beyond the first item
						// you will need to "build" the tuples accordingly
						String column1 =
						Integer column2 =
						// the "leaf" column name is the last portion of the composite
column name as a string
						String columnName =
						Integer columnValue =
			} catch (Exception e) { e.printStackTrace(); }
			return true;

I hope that helps!

On 5/10/13 12:11 PM, "Thorsten von Eicken" <> wrote:

>What is the proper way to scan a table in CQL3 when using the random
>partitioner? Specifically, what is the proper way to *start* the scan?
>E.g., is it something like:
>select rowkey from my_table limit N;
>while some_row_is_returned do
>  select rowkey from my_table where token(rowkey) >
>token(last_rowkey_returned) limit N;
>or is it:
>select rowkey from my_table where token(rowkey) >= 0 limit N;
>while some_row_is_returned do
>  select rowkey from my_table where token(rowkey) >
>token(last_rowkey_returned) limit N;
>Is there a docs page I overlooked that spells this out?

View raw message