You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/02/14 15:14:44 UTC

[couchdb] 03/05: mango: Add type specification for the JSON index selection

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

vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 1c90b504a9439a6c7c2a8754b03955b17780d6a8
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Mon Feb 13 22:57:25 2023 +0100

    mango: Add type specification for the JSON index selection
---
 src/mango/src/mango_cursor_view.erl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/mango/src/mango_cursor_view.erl b/src/mango/src/mango_cursor_view.erl
index 3f67f667b..883f2e448 100644
--- a/src/mango/src/mango_cursor_view.erl
+++ b/src/mango/src/mango_cursor_view.erl
@@ -31,6 +31,7 @@
 -include_lib("fabric/include/fabric.hrl").
 
 -include("mango_cursor.hrl").
+-include("mango_idx.hrl").
 -include("mango_idx_view.hrl").
 
 -define(HEARTBEAT_INTERVAL_IN_USEC, 4000000).
@@ -230,6 +231,11 @@ composite_prefix([Col | Rest], Ranges) ->
 % In the future we can look into doing a cached parallel
 % reduce view read on each index with the ranges to find
 % the one that has the fewest number of rows or something.
+-type range() :: {binary(), any(), binary(), any()} | empty.
+
+-spec choose_best_index(IndexRanges) -> Selection when
+    IndexRanges :: nonempty_list({#idx{}, [range()], integer()}),
+    Selection :: {#idx{}, [range()]}.
 choose_best_index(IndexRanges) ->
     Cmp = fun({IdxA, _PrefixA, PrefixDifferenceA}, {IdxB, _PrefixB, PrefixDifferenceB}) ->
         case PrefixDifferenceA - PrefixDifferenceB of