Single Key Fetch in Riak TS
You may find the need to fetch a single key from Riak TS. The below examples show you how to perform a single key fetch in each of our official clients that support Riak TS.
final List<Cell> keyCells = Arrays.asList(new Cell("South Atlantic"), new Cell("South Carolina"), Cell.newTimestamp(1420113600000));
Fetch fetch = new Fetch.Builder("GeoCheckin", keyCells).build();
QueryResult queryResult = client.execute(fetch);
read_operation = Riak::TimeSeries::Read.new client, 'GeoCheckin'
read_operation.key = ['South Atlantic', 'South Carolina', 1420113600000]
results = read_operation.read!
client.ts_get('GeoCheckin', ['South Atlantic', 'South Carolina', datetime.datetime(2015, 1, 1, 12, 0, 0)])
var keyCells = new Cell[]
{
new Cell<string>("hash1"),
new Cell<string>("user2"),
new Cell<DateTime>(FiveMinsAgo)
};
var key = new Row(keyCells);
var cmd = new Get.Builder()
.WithTable("GeoCheckin")
.WithKey(key)
.Build();
RiakResult rslt = client.Execute(cmd);
var key = [ 'South Atlantic', 'South Carolina', 1420113600000 ];
var cb = function (err, rslt) {
// NB: rslt will be an object with two properties:
// 'columns' - table columns
// 'rows' - row matching the Get request
};
var cmd = new Riak.Commands.TS.Get.Builder()
.withTable('GeoCheckin')
.withKey(key)
.withCallback(cb)
.build();
client.execute(cmd);
riakc_ts:get(Pid, <<"GeoCheckin">>, [<<"South Atlantic">>, <<"South Carolina">>, 1420113600000], []).
$response = (new Command\Builder\TimeSeries\FetchRow($riak))
->atKey([
(new Cell("region"))->setValue("South Atlantic"),
(new Cell("state"))->setValue("South Carolina"),
(new Cell("time"))->setTimestampValue(1420113600),
])
->inTable('GeoCheckins')
->build()
->execute();
key := make([]riak.TsCell, 3)
key[0] = NewStringTsCell("South Atlantic")
key[1] = NewStringTsCell("South Carolina")
key[2] = NewTimestampTsCell(1420113600)
cmd, err := riak.NewTsFetchRowCommandBuilder()
.WithTable("GeoCheckin").WithKey(key)
.Build()
if err != nil {
return err
}
err = cluster.Execute(cmd)