Skip to content

Commit

Permalink
HTTP client API
Browse files Browse the repository at this point in the history
A two month worth of commits by @hmmr and @lehoff, squashed.

The odd change in riak_kv_qry_worker (preserving lists for records in
the return value of query) goes with the list_to_tuple conversion now
happening in riak_kv_ts_api. Native lists from riak_kv_qry:submit are
immediately consumable by mochijson2:encode, and this is the form we
would like to have the query results in wm_timeseries_query.
  • Loading branch information
Andrei Zavada committed Apr 17, 2016
1 parent dcad486 commit 6348791
Show file tree
Hide file tree
Showing 8 changed files with 1,193 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/riak_kv_qry_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ prepare_final_results(#state{
prepare_final_results2(#riak_sel_clause_v1{col_return_types = ColTypes,
col_names = ColNames}, Rows) ->
%% filter out empty records
FinalRows = [list_to_tuple(R) || R <- Rows, R /= [[]]],
FinalRows = [R || R <- Rows, R /= [[]]],
{ColNames, ColTypes, FinalRows}.

%%%===================================================================
Expand All @@ -292,10 +292,8 @@ prepare_final_results2(#riak_sel_clause_v1{col_return_types = ColTypes,

prepare_final_results_test() ->
Rows = [[12, <<"windy">>], [13, <<"windy">>]],
RowsAsTuples = [{12, <<"windy">>}, {13, <<"windy">>}],
% IndexedChunks = [{1, Rows}],
?assertEqual(
{[<<"a">>, <<"b">>], [sint64, varchar], RowsAsTuples},
{[<<"a">>, <<"b">>], [sint64, varchar], Rows},
prepare_final_results(
#state{
qry =
Expand Down
5 changes: 3 additions & 2 deletions src/riak_kv_ts_svc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,9 @@ sub_tscoveragereq(Mod, _DDL, #tscoveragereq{table = Table,
{reply, ts_query_responses() | #rpberrorresp{}, #state{}}.
sub_tsqueryreq(_Mod, DDL = ?DDL{table = Table}, SQL, State) ->
case riak_kv_ts_api:query(SQL, DDL) of
{ok, Data} ->
{reply, make_tsqueryresp(Data), State};
{ok, {ColNames, ColTypes, LdbNativeRows}} ->
Rows = [list_to_tuple(R) || R <- LdbNativeRows],
{reply, make_tsqueryresp({ColNames, ColTypes, Rows}), State};

%% the following timeouts are known and distinguished:
{error, no_type} ->
Expand Down
14 changes: 12 additions & 2 deletions src/riak_kv_web.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%
%% riak_kv_web: setup Riak's KV HTTP interface
%%
%% Copyright (c) 2007-2010 Basho Technologies, Inc. All Rights Reserved.
%% Copyright (c) 2007-2016 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down Expand Up @@ -121,7 +121,17 @@ raw_dispatch(Name) ->
{Prefix ++ ["buckets", bucket, "index", field, '*'],
riak_kv_wm_index, Props}

] || {Prefix, Props} <- Props2 ]).
] || {Prefix, Props} <- Props2 ]) ++

lists:flatten(
[
%% Right now we only have version 1. When we get version 2 we have to
%% decide if we want to dispatch to separate resource modules or handle
%% the different versions inside the same resource handler module.
[{["ts", api_version, "tables", table, "list_keys"], riak_kv_wm_timeseries_listkeys, Props},
{["ts", api_version, "tables", table, "keys", '*'], riak_kv_wm_timeseries, Props},
{["ts", api_version, "query"], riak_kv_wm_timeseries_query, Props}
] || {_Prefix, Props} <- Props2]).

is_post(Req) ->
wrq:method(Req) == 'POST'.
Expand Down
Loading

0 comments on commit 6348791

Please sign in to comment.