summaryrefslogtreecommitdiff
path: root/src/couch_views
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2020-03-04 13:10:02 -0600
committerPaul J. Davis <paul.joseph.davis@gmail.com>2020-03-05 14:18:12 -0600
commite6f6e2d6baf91521e3a756f6d42db4f42fcee8c9 (patch)
tree68573d2f6ac12a6be39f1f0548723c11872c96c4 /src/couch_views
parent69fc02bf17545f37c1aad0847552ecefbdc8e539 (diff)
downloadcouchdb-e6f6e2d6baf91521e3a756f6d42db4f42fcee8c9.tar.gz
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.
Diffstat (limited to 'src/couch_views')
-rw-r--r--src/couch_views/src/couch_views_fdb.erl8
-rw-r--r--src/couch_views/test/couch_views_indexer_test.erl4
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 98257f308..a0224b2b8 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 c3f704911..cd5b2b0bf 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).