Skip to content

Commit

Permalink
Merge pull request #276 from javajolt/bch-fix-tsgetresp
Browse files Browse the repository at this point in the history
Standardize the success response from tsgetresp and tsqueryresp

Reviewed-by: lukebakken
  • Loading branch information
borshop committed Apr 15, 2016
2 parents 49142ee + fc6cb24 commit 46d1a8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/riakc_ts.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@


-spec query(pid(), Query::string()|binary()) ->
{ColumnNames::[ts_columnname()], Rows::[tuple()]} | {error, Reason::term()}.
{ok, {ColumnNames::[ts_columnname()], Rows::[tuple()]}} | {error, Reason::term()}.
%% @equiv query/5.
query(Pid, Query) ->
query(Pid, Query, [], undefined, []).

-spec query(pid(), Query::string()|binary(), Interpolations::[{binary(), binary()}]) ->
{ColumnNames::[binary()], Rows::[tuple()]} | {error, term()}.
{ok, {ColumnNames::[binary()], Rows::[tuple()]}} | {error, term()}.
%% @equiv query/5.
query(Pid, Query, Interpolations) ->
query(Pid, Query, Interpolations, undefined, []).
Expand All @@ -58,7 +58,7 @@ query(Pid, Query, Interpolations) ->
Query::string(),
Interpolations::[{binary(), binary()}],
Cover::term()) ->
{ColumnNames::[binary()], Rows::[tuple()]} | {error, term()}.
{ok, {ColumnNames::[binary()], Rows::[tuple()]}} | {error, term()}.
%% @equiv query/5.
query(Pid, Query, Interpolations, Cover) ->
query(Pid, Query, Interpolations, Cover, []).
Expand All @@ -68,7 +68,7 @@ query(Pid, Query, Interpolations, Cover) ->
Interpolations::[{binary(), binary()}],
Cover::term(),
Options::proplists:proplist()) ->
{ColumnNames::[binary()], Rows::[tuple()]} | {error, term()}.
{ok, {ColumnNames::[binary()], Rows::[tuple()]}} | {error, term()}.
%% @doc Execute a Query with client. The result returned
%% is a tuple containing a list of columns as binaries in the
%% first element, and a list of records, each represented as a
Expand Down
2 changes: 2 additions & 0 deletions src/riakc_ts_get_operator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ deserialize({error, {Code, Message}}) when is_integer(Code), is_atom(Message) ->
{error, {Code, iolist_to_binary(atom_to_list(Message))}};
deserialize({error, Message}) ->
{error, Message};
deserialize(tsgetresp) ->
{ok, {[], []}};
deserialize({tsgetresp, {ColumnNames, _ColumnTypes, Rows}}) ->
{ok, {ColumnNames, Rows}};
deserialize(#tsgetresp{columns = C, rows = R}) ->
Expand Down
8 changes: 3 additions & 5 deletions src/riakc_ts_query_operator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ deserialize({error, {Code, Message}}) when is_integer(Code), is_atom(Message) ->
deserialize({error, Message}) ->
{error, Message};
deserialize(tsqueryresp) ->
{[], []};
deserialize({tsqueryresp, {_, _, []}}) ->
{[], []};
{ok, {[], []}};
deserialize({tsqueryresp, {ColumnNames, _ColumnTypes, Rows}}) ->
{ColumnNames, Rows};
{ok, {ColumnNames, Rows}};
deserialize(#tsqueryresp{columns = C, rows = R}) ->
ColumnNames = [ColName || #tscolumndescription{name = ColName} <- C],
Rows = riak_pb_ts_codec:decode_rows(R),
{ColumnNames, Rows}.
{ok, {ColumnNames, Rows}}.

0 comments on commit 46d1a8c

Please sign in to comment.