2

My column family stores data in the column names and I want to perform range query on the columns using Astyanax. Can anyone suggest how to do that?

labyrinth
  • 1,104
  • 3
  • 11
  • 32

3 Answers3

1

There are lots example on range query available here

Sample one

keyspace.prepareQuery(CF_TIME_UUID)
    .getKey(rowKey)
    .withColumnRange(
        new RangeBuilder()
            .setLimit(10)
            .setStart(TimeUUIDUtils.getTimeUUID(0))
            .setEnd(TimeUUIDUtils
                .getTimeUUID(Long.MAX_VALUE >> 8))
            .build()).execute();
abhi
  • 4,762
  • 4
  • 29
  • 49
1

I agree with abhi and this is exactly how Playorm has implemented it. You may see the code of columnSlice() API at https://github.com/deanhiller/playorm/blob/master/src/main/java/com/alvazan/orm/layer9z/spi/db/cassandra/CassandraSession.java

Also, if you are using Playorm for Cassandra you can just use its ColumnSlice API. The example is given at https://github.com/deanhiller/playorm/blob/master/src/test/java/com/alvazan/test/TestColumnSlice.java

Easility
  • 716
  • 2
  • 8
  • 19
  • Could you please refer to the following link also: http://stackoverflow.com/questions/15744575/querying-columns-with-prefix-not-working-using-astyanax I am working on a problem described there. Thanks im advance for the help – labyrinth Apr 03 '13 at 10:03
0

Actually, you could just use PlayOrm Query language as well if you final goal is getting the entities out.

Dean Hiller
  • 19,235
  • 25
  • 129
  • 212