Skip to content

Commit

Permalink
Merge pull request #24 from basho/bk-ts-writing-erlang-fixes
Browse files Browse the repository at this point in the history
erlang put example now uses binaries
  • Loading branch information
erjohnson committed Oct 27, 2015
2 parents 7b7fc2e + ddc5cb8 commit f96a303
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 18 additions & 16 deletions source/languages/en/timeseries/querying.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ Basic queries return the full range of values between two given times for a seri

````erlang
{ok, Pid} = riakc_pb_socket:start_link("myriakdb.host", 10017).
riakc_ts:query(Pid, "select * from GeoCheckin where time > 123456 and time < 987654 and myfamily = family1 and myseries = series1").
riakc_ts:query(Pid, "select * from GeoCheckin where time > 1234560 and time < 1234569 and myfamily = 'family1' and myseries = 'series1'").
```

```java
RiakClient client = RiakClient.newClient(10017, "myriakdb.host");
String queryText = "select * from GeoCheckin " +
"where time > 123456 and time < 987654 and " +
"myfamily = family1 and myseries = series1";
"where time > 1234560 and time < 1234569 and " +
"myfamily = 'family1' and myseries = 'series1'";

Query query = new Query.Builder(queryText).build();
QueryResult queryResult = client.execute(query);
```

```ruby
client = Riak::Client.new 'myriakdb.host', pb_port: 10017
query = Riak::Timeseries::Query.new client, "select * from GeoCheckin where time > 123456 and time < 987654 and myfamily = family1 and myseries = series1"
query = Riak::Timeseries::Query.new client, "select * from GeoCheckin where time > 1234560 and time < 1234569 and myfamily = 'family1' and myseries = 'series1'"
results = query.issue!
>>>>>>> a0580a2273f2b212e24c716e5afb823ed7527f3b
```
Expand All @@ -61,16 +61,16 @@ The SQL query must cover the entire time series key (`time`, `myfamily`, `myser
You can also select particular fields from the data. In the below example, **??** what specifically is happening here?:

```erlang
riakc_ts:query(Pid, "select weather, temperature from GeoCheckin where time > 123456 and time < 987654 and myfamily = family1 and myseries = series1").
riakc_ts:query(Pid, "select weather, temperature from GeoCheckin where time > 1234560 and time < 1234569 and myfamily = 'family1' and myseries = 'series1'").
```
```ruby
Riak::Timeseries::Query.new(client, "select weather, temperature from GeoCheckin where time > 123456 and time < 987654 and myfamily = family1 and myseries = series1").issue!
Riak::Timeseries::Query.new(client, "select weather, temperature from GeoCheckin where time > 1234560 and time < 1234569 and myfamily = 'family1' and myseries = 'series1'").issue!
```

```java
String queryText = "select weather, temperature from GeoCheckin " +
"where time > 123456 and time < 987654 and " +
"myfamily = family1 and myseries = series1";
"where time > 1234560 and time < 1234569 and " +
"myfamily = 'family1' and myseries = 'series1'";

Query query = new Query.Builder(queryText).build();
QueryResult queryResult = client.execute(query);
Expand All @@ -79,16 +79,16 @@ QueryResult queryResult = client.execute(query);
Additionally, you can extend the query beyond the key. For example, **??** what's happening in this example?:
```erlang
riakc_ts:query(Pid, "select weather, temperature from GeoCheckin where time > 123456 and time < 987654 and myfamily = family1 and myseries = series1 and temperature > 27.0").
riakc_ts:query(Pid, "select weather, temperature from GeoCheckin where time > 1234560 and time < 1234569 and myfamily = 'family1' and myseries = 'series1' and temperature > 27.0").
```
```ruby
Riak::Timeseries::Query.new(client, "select weather, temperature from GeoCheckin where time > 123456 and time < 987654 and myfamily = family1 and myseries = series1 and temperature > 27.0").issue!
Riak::Timeseries::Query.new(client, "select weather, temperature from GeoCheckin where time > 1234560 and time < 1234569 and myfamily = 'family1' and myseries = 'series1' and temperature > 27.0").issue!
```
```java
String queryText = "select weather, temperature from GeoCheckin " +
"where time > 123456 and time < 987654 and " +
"myfamily = family1 and myseries = series1 " +
"where time > 1234560 and time < 1234569 and " +
"myfamily = 'family1' and myseries = 'series1' " +
"temperature > 27.0";
Query query = new Query.Builder(queryText).build();
Expand All @@ -103,17 +103,17 @@ eliminate the need to escape data on the client:
riakc_ts:query(Pid,
"select weather, temperature from GeoCheckin where time > :start and time < :end and myfamily = :family and myseries = :series and temperature > :temperature",
[
{"start", 123456},
{"end", 987654},
{"start", 1234560},
{"end", 1234569},
{"family", "myfamily"},
{"series", "myseries"}
]).
```
```ruby
query = Riak::Timeseries::Query.new(client, "select weather, temperature from GeoCheckin where time > :start and time < :end and myfamily = :family and myseries = :series and temperature > :temperature")
query.interpolations = {
'start' => 123456,
'end' => 987654,
'start' => 1234560,
'end' => 1234569,
'family' => 'myfamily',
'series' => 'myseries'
}
Expand All @@ -138,6 +138,8 @@ The following operators are supported for each data type
In this early version queries can only range over 1 to 4 quanta. If you write a range that is too large, your query will generate too many subqueries and the query system will refuse to run.
**??** will the "1 o’clock" thing actually work or am i being trolled
For instance, if you have the default system with a `15m quanta`, then a query such as:
`time > 1 o’clock and time < 2 o’clock`
Expand Down
2 changes: 1 addition & 1 deletion source/languages/en/timeseries/writingdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ submission.write!

```erlang
{ok, Pid} = riakc_pb_socket:start_link("myriakdb.host", 10017).
riakc_ts:put(Pid, "GeoCheckin", [[family1”, “series1, 1234567, hot, 23.5], [family2”, “series99, 1234567, windy, 19.8]]).
riakc_ts:put(Pid, "GeoCheckin", [[<<"family1">>, <<"series1">>, 1234567, <<"hot">>, 23.5], [<<"family2">>, <<"series99">>, 1234567, <<"windy">>, 19.8]]).
```

```java
Expand Down

0 comments on commit f96a303

Please sign in to comment.