nickva commented on code in PR #4291:
URL: https://github.com/apache/couchdb/pull/4291#discussion_r1170848858


##########
src/nouveau/src/nouveau_fabric_search.erl:
##########
@@ -0,0 +1,213 @@
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%%     http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+
+-module(nouveau_fabric_search).
+
+-export([go/4]).
+
+-include_lib("mem3/include/mem3.hrl").
+-include_lib("couch/include/couch_db.hrl").
+
+-record(state, {
+    limit,
+    sort,
+    counters,
+    search_results
+}).
+
+go(DbName, GroupId, IndexName, QueryArgs0) when is_binary(GroupId) ->
+    {ok, DDoc} = fabric:open_doc(
+        DbName,
+        <<"_design/", GroupId/binary>>,
+        [ejson_body]
+    ),
+    go(DbName, DDoc, IndexName, QueryArgs0);
+go(DbName, #doc{} = DDoc, IndexName, QueryArgs0) ->
+    {ok, Index} = nouveau_util:design_doc_to_index(DbName, DDoc, IndexName),
+    Shards = mem3:shards(DbName),
+    Bookmark = nouveau_bookmark:unpack(DbName, maps:get(bookmark, QueryArgs0)),

Review Comment:
   If we're getting the bookmark with `maps:get/2` we assume it's always going 
to be present. That's should be the case here?
   
   Also [maps:take/2](https://www.erlang.org/doc/man/maps.html#take-2) might 
work here for getting and removing at the same time, instead of a `get` 
followed by a `remove`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to