summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@apache.org>2022-02-09 11:53:17 -0800
committerILYA Khlopotov <iilyak@apache.org>2022-02-10 10:35:39 -0800
commitea15c8689bd2f79fb231148b76de430bb37cdad4 (patch)
treeeb9b510a9e8012814ac1e48e506eb5c1c5f0400c
parent46c1a874cc8a2392b86d78b49ea6a36d3c15ca46 (diff)
downloadcouchdb-ea15c8689bd2f79fb231148b76de430bb37cdad4.tar.gz
Add couch_mrview_debug:view_signature/2
-rw-r--r--src/couch_mrview/src/couch_mrview_debug.erl50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/couch_mrview/src/couch_mrview_debug.erl b/src/couch_mrview/src/couch_mrview_debug.erl
new file mode 100644
index 000000000..a4203d49d
--- /dev/null
+++ b/src/couch_mrview/src/couch_mrview_debug.erl
@@ -0,0 +1,50 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_mrview_debug).
+
+-export([
+ help/0,
+ help/1
+]).
+
+-export([
+ view_signature/2
+]).
+
+-include_lib("couch_mrview/include/couch_mrview.hrl").
+
+help() ->
+ [
+ view_signature
+ ].
+
+-spec help(Function :: atom()) -> ok.
+%% erlfmt-ignore
+help(view_signature) ->
+ io:format("
+ view_signature(ShardName, DDocName)
+ --------------
+ Returns a view signature for given ddoc for a given (non clustered) database.
+ ---
+ ", []);
+help(Unknown) ->
+ io:format("Unknown function: `~p`. Please try one of the following:~n", [Unknown]),
+ [io:format(" - ~s~n", [Function]) || Function <- help()],
+ io:format(" ---~n", []),
+ ok.
+
+view_signature(DbName, DDocName) ->
+ {ok, Db} = couch_db:open_int(DbName, []),
+ {ok, DDoc} = couch_db:open_doc_int(Db, <<"_design/", DDocName/binary>>, []),
+ {ok, IdxState} = couch_mrview_util:ddoc_to_mrst(DDocName, DDoc),
+ couch_util:to_hex(IdxState#mrst.sig).