Skip to content

Commit

Permalink
Update cassandra.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lmangani authored Jan 1, 2018
1 parent cdd264c commit 3ed5fb2
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions examples/cassandra.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,8 @@ Once created, execute queryda with the following commandline using the *cqlexamp
```
bin/queryda --configfile="../jobs/cqlexample.json"
```
### Custom Time-Range Function
To allow simple time-range queries in Cassandra 3.x, the following custom Function can be used:
```
CREATE FUNCTION IF NOT EXISTS toTimestampLast(minutes int)
CALLED ON NULL INPUT
RETURNS timestamp
LANGUAGE java AS '
long now = System.currentTimeMillis();
if (minutes == null)
return new Date(now);
return new Date(now - (minutes.intValue() * 60 * 1000));
';
```
Usage:
```
SELECT value FROM test.TEST WHERE LAST_MODIFIED_DATE >= toTimestampLast(60) AND LAST_MODIFIED_DATE <= toTimestamp(now()) LIMIT 100 ALLOW FILTERING;
```

#### Configuration
#### Example Configuration
The following examples illustrates a time-bound
```
{
Expand All @@ -66,3 +49,21 @@ The following examples illustrates a time-bound
}
}
```

### Custom Time-Range Function
To allow simple time-range queries in Cassandra 3.x, the following custom Function can be used. Note custom functions requires ```enable_user_defined_functions=true``` in cassandra.yaml ahead of usage.
```
CREATE FUNCTION IF NOT EXISTS toTimestampLast(minutes int)
CALLED ON NULL INPUT
RETURNS timestamp
LANGUAGE java AS '
long now = System.currentTimeMillis();
if (minutes == null)
return new Date(now);
return new Date(now - (minutes.intValue() * 60 * 1000));
';
```
Usage:
```
SELECT value FROM test.TEST WHERE LAST_MODIFIED_DATE >= toTimestampLast(60) AND LAST_MODIFIED_DATE <= toTimestamp(now()) LIMIT 100 ALLOW FILTERING;
```

0 comments on commit 3ed5fb2

Please sign in to comment.