You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/12/03 19:45:07 UTC

[couchdb] 02/06: Expose rolled up view size in dbinfo blobs

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch prototype/fdb-layer-get-dbs-info
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit fa480d86c9b65e2577107beec40242a448f49fa0
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue Dec 3 10:32:36 2019 -0600

    Expose rolled up view size in dbinfo blobs
    
    This allows users to see the total view size for a given database with a
    single HTTP request.
---
 src/fabric/src/fabric2_fdb.erl | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index 643f839..64474fa 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -346,26 +346,26 @@ get_info(#{} = Db) ->
     end,
     CProp = {update_seq, RawSeq},
 
-    MProps = lists:flatmap(fun({K, V}) ->
+    MProps = lists:foldl(fun({K, V}, Acc) ->
         case erlfdb_tuple:unpack(K, DbPrefix) of
             {?DB_STATS, <<"doc_count">>} ->
-                [{doc_count, ?bin2uint(V)}];
+                [{doc_count, ?bin2uint(V)} | Acc];
             {?DB_STATS, <<"doc_del_count">>} ->
-                [{doc_del_count, ?bin2uint(V)}];
+                [{doc_del_count, ?bin2uint(V)} | Acc];
             {?DB_STATS, <<"size">>} ->
                 Val = ?bin2uint(V),
-                [
-                    {other, {[{data_size, Val}]}},
-                    {sizes, {[
-                        {active, 0},
-                        {external, Val},
-                        {file, 0}
-                    ]}}
-                ];
+                {_, {Sizes}} = lists:keyfind(sizes, 1, Acc),
+                NewSizes = [{external, Val} | Sizes],
+                lists:keystore(sizes, 1, {sizes, {NewSizes}});
+            {?DB_STATS, <<"view_size">>} ->
+                Val = ?bin2uint(V),
+                {_, {Sizes}} = lists:keyfind(sizes, 1, Acc),
+                NewSizes = [{views, Val} | Sizes],
+                lists:keystore(sizes, 1, {sizes, {NewSizes}});
             {?DB_STATS, _} ->
-                []
+                Acc
         end
-    end, erlfdb:wait(MetaFuture)),
+    end, [{sizes, []}], erlfdb:wait(MetaFuture)),
 
     [CProp | MProps].