Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java API to use for queries based on maxTimeuuid and minTimeuuid

What is the Java API for using maxTimeuuid and minTimeuuid based queries? I could not find any in the QueryBuilder or anywhere else. I am using DataStax client

        <artifactId>cassandra-driver-core</artifactId>
        <version>1.0.3</version>

Table "a" has 2 columns: 1. id of type String 2. LMD of type TimeUuid

This is what I am doing and does not seem right and of course does not work

    Query q = QueryBuilder
    .select()
    .all()
    .from("test","a")
    .where().and(QueryBuilder.gt("LMD", "minTimeUUid('2013-11-03 14:33:50')"))
    .and(QueryBuilder.lt("LMD", "maxTimeUUId('2013-11-03 14:45:50')"));

Any pointers are highly appreciated

Thanks

like image 786
Masti Avatar asked Dec 19 '22 21:12

Masti


1 Answers

You will need to generate the max/min TimeUUIDs programatically, from timestamps using the utils.UUIDs utility class, e.g.

final UUID min = UUIDs.startOf(lowerTimeStamp);
final UUID max = UUIDs.endOf(upperTimeStamp);
Query q = QueryBuilder
  .select()
  .all()
  .from("test","a")
  .where(QueryBuilder.gt("LMD", min))
  .and(QueryBuilder.lt("LMD", max));
like image 111
lorcan Avatar answered Dec 22 '22 12:12

lorcan