This is an automated email from the ASF dual-hosted git repository. davisp pushed a commit to branch prototype/fdb-layer-couch-views-size-tests in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 77f031f0b858829fb60c6509ea90a848c78c9230 Author: Paul J. Davis <[email protected]> AuthorDate: Wed Mar 4 13:10:02 2020 -0600 Don't store `{0,0,[]}` for views with new results This saves us a key/value pair for any document that is not included as part of a view. --- src/couch_views/src/couch_views_fdb.erl | 8 ++++++++ src/couch_views/test/couch_views_indexer_test.erl | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/couch_views/src/couch_views_fdb.erl b/src/couch_views/src/couch_views_fdb.erl index 98257f3..a0224b2 100644 --- a/src/couch_views/src/couch_views_fdb.erl +++ b/src/couch_views/src/couch_views_fdb.erl @@ -205,6 +205,14 @@ clear_map_idx(TxDb, Sig, ViewId, DocId, ViewKeys) -> end, ViewKeys). +update_id_idx(TxDb, Sig, ViewId, DocId, [], _KVSize) -> + #{ + tx := Tx, + db_prefix := DbPrefix + } = TxDb, + Key = id_idx_key(DbPrefix, Sig, DocId, ViewId), + ok = erlfdb:clear(Tx, Key); + update_id_idx(TxDb, Sig, ViewId, DocId, NewRows, KVSize) -> #{ tx := Tx, diff --git a/src/couch_views/test/couch_views_indexer_test.erl b/src/couch_views/test/couch_views_indexer_test.erl index 9b12af6..d941d93 100644 --- a/src/couch_views/test/couch_views_indexer_test.erl +++ b/src/couch_views/test/couch_views_indexer_test.erl @@ -161,7 +161,7 @@ updated_docs_are_reindexed(Db) -> Sig = Mrst#mrst.sig, fabric2_fdb:transactional(Db, fun(TxDb) -> ?assertMatch( - [{0, 1, _, [1]}, {1, 0, 0, []}], + [{0, 1, _, [1]}], couch_views_fdb:get_view_keys(TxDb, Sig, <<"0">>) ) end). @@ -217,7 +217,7 @@ updated_docs_without_changes_are_reindexed(Db) -> Sig = Mrst#mrst.sig, fabric2_fdb:transactional(Db, fun(TxDb) -> ?assertMatch( - [{0, 1, _, [0]}, {1, 0, 0, []}], + [{0, 1, _, [0]}], couch_views_fdb:get_view_keys(TxDb, Sig, <<"0">>) ) end).
