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

vatamane pushed a commit to branch simplify-quickjs-scanner
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 225bec7ae759dbe846ba9d3667fa7b93a6632a4b
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Fri Feb 6 13:14:12 2026 -0500

    Simplify couch_quickjs scanner plugin
    
    Since we inspect the #full_doc_info{} record to skip deleted docs anyway, 
move
    all the doc_id clauses to the `doc_fdi/3` callback to have one less 
callback to
    worry about.
    
    There is not performance penalty as by the time we call `doc_id/3` we 
already
    have the full `#full_doc_info{}` record opened anyway.
---
 src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl 
b/src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl
index 52a252fc9..4c8d6b0f6 100644
--- a/src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl
+++ b/src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl
@@ -22,7 +22,6 @@
     ddoc/3,
     shards/2,
     db_opened/2,
-    doc_id/3,
     doc_fdi/3,
     doc/3,
     db_closing/2
@@ -152,23 +151,20 @@ db_opened(#st{} = St, Db) ->
     Step = min(MaxStep, max(1, DocTotal div MaxDocs)),
     {0, [], St#st{doc_cnt = 0, docs_size = 0, doc_step = Step, docs = []}}.
 
-doc_id(#st{} = St, <<?DESIGN_DOC_PREFIX, _/binary>>, _Db) ->
+doc_fdi(#st{} = St, #full_doc_info{deleted = true}, _Db) ->
+    % Skip deleted; don't even open the doc body
     {skip, St};
-doc_id(#st{sid = SId, doc_cnt = C, max_docs = M} = St, _DocId, Db) when C > M 
->
+doc_fdi(#st{} = St, #full_doc_info{id = <<?DESIGN_DOC_PREFIX, _/binary>>}, 
_Db) ->
+    {skip, St};
+doc_fdi(#st{sid = SId, doc_cnt = C, max_docs = M} = St, #full_doc_info{}, Db) 
when C > M ->
     Meta = #{sid => SId, db => Db},
     ?INFO("reached max docs ~p", [M], Meta),
     {stop, St};
-doc_id(#st{doc_cnt = C, doc_step = S} = St, _DocId, _Db) when C rem S /= 0 ->
+doc_fdi(#st{doc_cnt = C, doc_step = S} = St, #full_doc_info{}, _Db) when C rem 
S /= 0 ->
     {skip, St#st{doc_cnt = C + 1}};
-doc_id(#st{doc_cnt = C} = St, _DocId, _Db) ->
+doc_fdi(#st{doc_cnt = C} = St, #full_doc_info{}, _Db) ->
     {ok, St#st{doc_cnt = C + 1}}.
 
-doc_fdi(#st{} = St, #full_doc_info{deleted = true}, _Db) ->
-    % Skip deleted; don't even open the doc body
-    {skip, St};
-doc_fdi(#st{} = St, #full_doc_info{}, _Db) ->
-    {ok, St}.
-
 doc(#st{} = St, Db, #doc{id = DocId} = Doc) ->
     #st{sid = SId} = St,
     JsonDoc = couch_query_servers:json_doc(Doc),

Reply via email to