You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/02/05 18:11:07 UTC
[couchdb] branch shard-split updated: Use the same order for
history in ejson and the tuple
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch shard-split
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/shard-split by this push:
new 8321779 Use the same order for history in ejson and the tuple
8321779 is described below
commit 8321779b2361608aad88985d2fb286ee1caabd1e
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Tue Feb 5 11:32:31 2019 -0500
Use the same order for history in ejson and the tuple
---
src/mem3/src/mem3_reshard.erl | 21 ++++++++-------------
src/mem3/src/mem3_reshard_store.erl | 4 ++--
2 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/src/mem3/src/mem3_reshard.erl b/src/mem3/src/mem3_reshard.erl
index 9e83b94..07279f8 100644
--- a/src/mem3/src/mem3_reshard.erl
+++ b/src/mem3/src/mem3_reshard.erl
@@ -756,20 +756,20 @@ update_history(State, Detail, Ts, History) ->
TrimmedRev = lists:sublist(UpdatedRev, max_history()),
lists:reverse(TrimmedRev).
-update_history_rev(State, null, Ts, [{State, Detail, _} | Rest]) ->
+update_history_rev(State, null, Ts, [{_, State, Detail} | Rest]) ->
% Just updated the detail, state stays the same, no new entry added
- [{State, Detail, Ts} | Rest];
+ [{Ts, State, Detail} | Rest];
-update_history_rev(State, Detail, Ts, [{State, Detail, _} | Rest]) ->
+update_history_rev(State, Detail, Ts, [{_, State, Detail} | Rest]) ->
% State and detail were same as last event, just update the timestamp
- [{State, Detail, Ts} | Rest];
+ [{Ts, State, Detail} | Rest];
-update_history_rev(State, Detail, Ts, [{State, Detail, _} | Rest]) ->
+update_history_rev(State, Detail, Ts, [{_, State, Detail} | Rest]) ->
% State and detail were same as last event, just update the timestamp
- [{State, Detail, Ts} | Rest];
+ [{Ts, State, Detail} | Rest];
update_history_rev(State, Detail, Ts, History) ->
- [{State, Detail, Ts} | History].
+ [{Ts, State, Detail} | History].
-spec max_history() -> non_neg_integer().
@@ -778,12 +778,7 @@ max_history() ->
-spec statefmt(#state{} | term()) -> string().
-statefmt(#state{} = State) ->
- #state{
- state = StateName,
- update_time = Updated,
- db_monitor = Pid
- } = State,
+statefmt(#state{state = StateName, db_monitor = Pid}) ->
Total = ets:info(?MODULE, size),
Active = mem3_reshard_job_sup:count_children(),
Msg = "#state{~s total:~B active:~B mon:~p}",
diff --git a/src/mem3/src/mem3_reshard_store.erl b/src/mem3/src/mem3_reshard_store.erl
index f2f2e9e..1d0c754 100644
--- a/src/mem3/src/mem3_reshard_store.erl
+++ b/src/mem3/src/mem3_reshard_store.erl
@@ -257,10 +257,10 @@ state_info_from_ejson({Props}) ->
history_to_ejson(Hist, true) when is_list(Hist) ->
- [{[{timestamp, iso8601(T)}, {type, S}, {detail, D}]} || {S, D, T} <- Hist];
+ [{[{timestamp, iso8601(T)}, {type, S}, {detail, D}]} || {T, S, D} <- Hist];
history_to_ejson(Hist, _) when is_list(Hist) ->
- [{[{timestamp, T}, {type, S}, {detail, D}]} || {S, D, T} <- Hist].
+ [{[{timestamp, T}, {type, S}, {detail, D}]} || {T, S, D} <- Hist].
history_from_ejson(HistoryEJson) when is_list(HistoryEJson) ->