You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2020/08/31 06:58:52 UTC

[couchdb] branch fix-explain-text-indexes created (now 6c54d3b)

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

tonysun83 pushed a change to branch fix-explain-text-indexes
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 6c54d3b  fix bookmark passing with text indexes

This branch includes the following new commits:

     new 6c54d3b  fix bookmark passing with text indexes

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: fix bookmark passing with text indexes

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tonysun83 pushed a commit to branch fix-explain-text-indexes
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 6c54d3b63b46c8aac25ca87ad4b0015edb84336b
Author: Tony Sun <to...@gmail.com>
AuthorDate: Sat Aug 29 09:43:09 2020 -0700

    fix bookmark passing with text indexes
    
    Previously, we passed in the unpacked version of the bookmark with
    the cursor inside the options field. This worked fine for _find because
    we didn't need to return it to the user. But for _explain, we return
    the value back as unpacked tuple instead of a string and jiffy:encode/1
    complains. Now we correctly extract the bookmark out of options, unpack
    it, and then pass it separately in it's own field. This way options
    retains it's original string form for the user so that invalid_ejson
    is not thrown.
---
 src/mango/src/mango_cursor_text.erl | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/mango/src/mango_cursor_text.erl b/src/mango/src/mango_cursor_text.erl
index 43ef84e..5989f34 100644
--- a/src/mango/src/mango_cursor_text.erl
+++ b/src/mango/src/mango_cursor_text.erl
@@ -43,7 +43,7 @@
 }).
 
 
-create(Db, Indexes, Selector, Opts0) ->
+create(Db, Indexes, Selector, Opts) ->
     Index = case Indexes of
         [Index0] ->
             Index0;
@@ -51,7 +51,7 @@ create(Db, Indexes, Selector, Opts0) ->
             ?MANGO_ERROR(multiple_text_indexes)
     end,
 
-    Opts = unpack_bookmark(couch_db:name(Db), Opts0),
+    Bookmark = unpack_bookmark(couch_db:name(Db), Opts),
 
     DreyfusLimit = get_dreyfus_limit(),
     Limit = erlang:min(DreyfusLimit, couch_util:get_value(limit, Opts, mango_opts:default_limit())),
@@ -66,7 +66,8 @@ create(Db, Indexes, Selector, Opts0) ->
         opts = Opts,
         limit = Limit,
         skip = Skip,
-        fields = Fields
+        fields = Fields,
+        bookmark = Bookmark
     }}.
 
 
@@ -90,7 +91,8 @@ execute(Cursor, UserFun, UserAcc) ->
         skip = Skip,
         selector = Selector,
         opts = Opts,
-        execution_stats = Stats
+        execution_stats = Stats,
+        bookmark = Bookmark
     } = Cursor,
     Query = mango_selector_text:convert(Selector),
     QueryArgs = #index_query_args{
@@ -104,7 +106,7 @@ execute(Cursor, UserFun, UserAcc) ->
         dbname = couch_db:name(Db),
         ddocid = ddocid(Idx),
         idx_name = mango_idx:name(Idx),
-        bookmark = get_bookmark(Opts),
+        bookmark = Bookmark,
         limit = Limit,
         skip = Skip,
         query_args = QueryArgs,
@@ -282,7 +284,7 @@ pack_bookmark(Bookmark) ->
 
 
 unpack_bookmark(DbName, Opts) ->
-    NewBM = case lists:keyfind(bookmark, 1, Opts) of
+    case lists:keyfind(bookmark, 1, Opts) of
         {_, nil} ->
             [];
         {_, Bin} ->
@@ -291,8 +293,7 @@ unpack_bookmark(DbName, Opts) ->
             catch _:_ ->
                 ?MANGO_ERROR({invalid_bookmark, Bin})
             end
-    end,
-    lists:keystore(bookmark, 1, Opts, {bookmark, NewBM}).
+    end.
 
 
 ddocid(Idx) ->