@@ -37,14 +37,15 @@ Riak TS allows you to write multiple rows of data at a time. To demonstrate, we'
37
37
``` sql
38
38
CREATE TABLE GeoCheckin
39
39
(
40
+ id SINT64 NOT NULL ,
40
41
region VARCHAR NOT NULL ,
41
42
state VARCHAR NOT NULL ,
42
43
time TIMESTAMP NOT NULL ,
43
44
weather VARCHAR NOT NULL ,
44
45
temperature DOUBLE,
45
46
PRIMARY KEY (
46
- (region, state , QUANTUM(time , 15 , ' m' )),
47
- region, state , time
47
+ (id , QUANTUM(time , 15 , ' m' )),
48
+ id , time
48
49
)
49
50
)
50
51
```
@@ -67,16 +68,18 @@ public class RiakTSInsert {
67
68
RiakClient client = RiakClient . newClient(8087 , " myriakdb.host" );
68
69
List<Row > rows = Arrays . asList(
69
70
new Row (
71
+ new Cell (1 ),
70
72
new Cell (" South Atlantic" ),
71
- new Cell (" South Carolina " ),
72
- Cell . newTimestamp(1234567 ),
73
+ new Cell (" Florida " ),
74
+ Cell . newTimestamp(1451606401 ),
73
75
new Cell (" hot" ),
74
76
new Cell (23.5 )
75
77
),
76
78
new Row (
77
- new Cell (" Mid-Atlantic" ),
78
- new Cell (" New York" ),
79
- Cell . newTimestamp(1234567 ),
79
+ new Cell (2 ),
80
+ new Cell (" East North Central" ),
81
+ new Cell (" Illinois" ),
82
+ Cell . newTimestamp(1451606402 ),
80
83
new Cell (" windy" ),
81
84
new Cell (19.8 )
82
85
)
@@ -90,9 +93,13 @@ public class RiakTSInsert {
90
93
```
91
94
92
95
``` ruby
93
- client = Riak ::Client .new ' myriakdb.host' , pb_port: 8087
96
+ require ' riak'
97
+
98
+ client = Riak ::Client .new (:nodes => [
99
+ {:host => ' myriakdb.host' , :pb_port => 8087 },
100
+ ])
94
101
submission = Riak ::TimeSeries ::Submission .new client, " GeoCheckin"
95
- submission.measurements = [[" South Atlantic" , " South Carolina " , 1234567 , " hot" , 23.5 ], [" Mid-Atlantic " , " New York " , 1234567 , " windy" , 19.8 ]]
102
+ submission.measurements = [[1 , " South Atlantic" , " Florida " , 1451606401 , " hot" , 23.5 ], [2 , " East North Central " , " Illinois " , 1451606402 , " windy" , 19.8 ]]
96
103
submission.write!
97
104
```
98
105
@@ -103,14 +110,10 @@ from riak.client import RiakClient
103
110
# NB: modify 'host' and 'pb_port' to match your installation
104
111
client = RiakClient(host = ' myriakdb.host' , pb_port = 8087 )
105
112
106
- fiveMins = datetime.timedelta(0 , 300 )
107
- ts0 = datetime.datetime(2015 , 1 , 1 , 12 , 0 , 0 )
108
- ts1 = ts0 + fiveMins
109
-
110
113
table = client.table(' GeoCheckin' )
111
114
rows = [
112
- [' South Atlantic' , ' South Carolina ' , ts0 , ' hot' , 23.5 ],
113
- [' Mid-Atlantic ' , ' New York ' , ts1 , ' windy' , 19.8 ]
115
+ [1 , ' South Atlantic' , ' Florida ' , 1451606401 , ' hot' , 23.5 ],
116
+ [2 , ' East North Central ' , ' Illinois ' , 1451606402 , ' windy' , 19.8 ]
114
117
]
115
118
ts_obj = table.new(rows)
116
119
print " Store result:" , ts_obj.store()
@@ -162,10 +165,11 @@ RiakResult rslt = client.Execute(cmd);
162
165
``` javascript
163
166
var Riak = require (' basho-riak-client' );
164
167
165
- var hosts = [ ' riak-1:8087 ' , ' riak-2 :8087' ];
168
+ var hosts = [ ' myriakdb.host :8087' ];
166
169
var client = new Riak.Client (hosts);
167
170
168
- var columns = [
171
+ var columns = [
172
+ { name: ' id' , type: Riak .Commands .TS .ColumnType .Int64 },
169
173
{ name: ' region' , type: Riak .Commands .TS .ColumnType .Varchar },
170
174
{ name: ' state' , type: Riak .Commands .TS .ColumnType .Varchar },
171
175
{ name: ' time' , type: Riak .Commands .TS .ColumnType .Timestamp },
@@ -174,8 +178,8 @@ var columns = [
174
178
];
175
179
176
180
var rows = [
177
- [ ' South Atlantic' , ' South Carolina ' , 1234567 , ' hot' , 23.5 ],
178
- [ ' Mid-Atlantic ' , ' New York ' , 1234567 , ' windy' , 19.8 ]
181
+ [ 1 , ' South Atlantic' , ' Florida ' , 1451606401 , ' hot' , 23.5 ],
182
+ [ 2 , ' East North Central ' , ' Illinois ' , 1451606402 , ' windy' , 19.8 ]
179
183
];
180
184
181
185
var cb = function (err , response ) {
@@ -195,9 +199,9 @@ client.execute(store);
195
199
```
196
200
197
201
``` erlang
198
- % % TS 1.3 or newer. Records are represented as tuples.
199
- {ok , Pid } = riakc_pb_socket :start_link (" myriakdb.host " , 8087 ).
200
- riakc_ts :put (Pid , " GeoCheckin" , [{<<" South Atlantic" >>, <<" South Carolina " >>, 1234567 , <<" hot" >>, 23.5 }, {<<" Mid-Atlantic " >>, <<" New York " >>, 1234567 , <<" windy" >>, 19.8 }]).
202
+ % % TS 1.3 or newer. Records are represented as tuples.
203
+ {ok , Pid } = riakc_pb_socket :start_link (" localhost " , 8087 ).
204
+ riakc_ts :put (Pid , " GeoCheckin" , [{1 , <<" South Atlantic" >>, <<" Florida " >>, 1451606401 , <<" hot" >>, 23.5 }, {2 , <<" East North Central " >>, <<" Illinois " >>, 1451606402 , <<" windy" >>, 19.8 }]).
201
205
```
202
206
203
207
``` php
0 commit comments