summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Sun <tony.sun427@gmail.com>2020-07-23 10:26:54 -0700
committerTony Sun <tony.sun427@gmail.com>2020-07-23 10:26:54 -0700
commit9f68eda15c55bd4c8246f6fc05882e8f56ba0338 (patch)
tree2c9442902c3f0bfff2fa138ba230f32a18ad49fc
parentd7e4ce7da08b375be3fa6a66d675b7863fa3bd79 (diff)
downloadcouchdb-9f68eda15c55bd4c8246f6fc05882e8f56ba0338.tar.gz
move active_task_info into util
-rw-r--r--src/couch_views/src/couch_views_indexer.erl27
-rw-r--r--src/couch_views/src/couch_views_util.erl27
2 files changed, 28 insertions, 26 deletions
diff --git a/src/couch_views/src/couch_views_indexer.erl b/src/couch_views/src/couch_views_indexer.erl
index 68cef3144..c6c6102c4 100644
--- a/src/couch_views/src/couch_views_indexer.erl
+++ b/src/couch_views/src/couch_views_indexer.erl
@@ -508,8 +508,8 @@ report_progress(State, UpdateType) ->
N -> N + ChangesDone
end,
- NewActiveTasks = active_tasks_info(TotalDone, DbName, DDocId,
- LastSeq, DBSeq),
+ NewActiveTasks = couch_views_util:active_tasks_info(TotalDone,
+ DbName, DDocId, LastSeq, DBSeq),
% Reconstruct from scratch to remove any
% possible existing error state.
@@ -560,26 +560,3 @@ key_size_limit() ->
value_size_limit() ->
config:get_integer("couch_views", "value_size_limit", ?VALUE_SIZE_LIMIT).
-
-active_tasks_info(ChangesDone, DbName, DDocId, LastSeq, DBSeq) ->
- {[
- {<<"type">>, <<"indexer">>},
- {<<"database">>, DbName},
- {<<"changes_done">>, ChangesDone},
- {<<"design_document">>, DDocId},
- {<<"current_version_stamp">>, convert_seq_to_stamp(LastSeq)},
- {<<"db_version_stamp">>, convert_seq_to_stamp(DBSeq)}
- ]}.
-
-
-convert_seq_to_stamp(<<"0">>) ->
- <<"0-0-0">>;
-
-convert_seq_to_stamp(undefined) ->
- <<"0-0-0">>;
-
-convert_seq_to_stamp(Seq) ->
- {_, Stamp, Batch, DocNumber} = fabric2_fdb:seq_to_vs(Seq),
- VS = integer_to_list(Stamp) ++ "-" ++ integer_to_list(Batch)
- ++ "-" ++ integer_to_list(DocNumber),
- list_to_binary(VS). \ No newline at end of file
diff --git a/src/couch_views/src/couch_views_util.erl b/src/couch_views/src/couch_views_util.erl
index 154e9e270..a05890468 100644
--- a/src/couch_views/src/couch_views_util.erl
+++ b/src/couch_views/src/couch_views_util.erl
@@ -17,7 +17,8 @@
ddoc_to_mrst/2,
validate_args/1,
validate_args/2,
- is_paginated/1
+ is_paginated/1,
+ active_tasks_info/5
]).
@@ -276,3 +277,27 @@ is_paginated(#mrargs{page_size = PageSize}) when is_integer(PageSize) ->
is_paginated(_) ->
false.
+
+
+active_tasks_info(ChangesDone, DbName, DDocId, LastSeq, DBSeq) ->
+ #{
+ <<"type">> => <<"indexer">>,
+ <<"database">> => DbName,
+ <<"changes_done">> => ChangesDone,
+ <<"design_document">> => DDocId,
+ <<"current_version_stamp">> => convert_seq_to_stamp(LastSeq),
+ <<"db_version_stamp">> => convert_seq_to_stamp(DBSeq)
+ }.
+
+
+convert_seq_to_stamp(<<"0">>) ->
+ <<"0-0-0">>;
+
+convert_seq_to_stamp(undefined) ->
+ <<"0-0-0">>;
+
+convert_seq_to_stamp(Seq) ->
+ {_, Stamp, Batch, DocNumber} = fabric2_fdb:seq_to_vs(Seq),
+ VS = integer_to_list(Stamp) ++ "-" ++ integer_to_list(Batch)
+ ++ "-" ++ integer_to_list(DocNumber),
+ list_to_binary(VS).