* Dmitry Simonenko <[email protected]> [12/06/19 18:29]:
>   Changed paths:
>     M mod/box/box.lua
>     M mod/box/box_lua.m
>     M test/box_big/lua.result
>     M test/box_big/lua.test
>     M test/box_big/tarantool.cfg
> 
>   Log Message:
>   -----------
>   lua-subtree: Blueprint Add a Lua built-in function to return a size of 
> subtree

Hi, looks good overall, please fix the below details and push.

> diff --git a/doc/user/stored-procedures.xml b/doc/user/stored-procedures.xml
> index d4d9f26..29b1f19 100644
> --- a/doc/user/stored-procedures.xml
> +++ b/doc/user/stored-procedures.xml
> @@ -1070,6 +1070,17 @@ localhost> lua for k,v in i.next, i, nil do print(v) 
> end
>          </listitem>
>      </varlistentry>
>  
> +    <varlistentry>
> +        <term>
> +            <emphasis role="lua">index:count()</emphasis>
> +        </term>
> +        <listitem><simpara>
> +            Function iterates over an index, counting number of tuples which
> +         equals key search criteria. Key can be multi-parted.
> +        </simpara>
> +        </listitem>
> +    </varlistentry>
> +

Please change text to:


Iterate over an index, count the number of tuples which equal the
provided search criteria. The argument can either point to a
tuple, a key, or one or more key parts. Returns the number of matched
tuples.
>  static const struct luaL_reg lbox_index_meta[] = {
>       {"__tostring", lbox_index_tostring},
>       {"__len", lbox_index_len},
> @@ -572,6 +616,7 @@ static const struct luaL_reg lbox_index_meta[] = {
>       {"prev", lbox_index_prev},
>       {"next_equal", lbox_index_next_equal},
>       {"prev_equal", lbox_index_prev_equal},
> +     {"count", lbox_index_count},
>       {NULL, NULL}
>  };

Since you support zero-arguments version of this function, I think
we should merge it with already existing index:size(). Having two 
ways to calculate the total number of tuples in an index, where
the second way has linear complexity is dangerous. 

Please either do not support no-arguments count(), or merge
count() with size() (I think the second is better).
>  
> +lua box.space[17].index[1].idx:count()
> +---
> + - 6

Full scan here, oh-oh.


Thank you for working on this!

-- 
http://tarantool.org - an efficient, extensible in-memory data store

_______________________________________________
Mailing list: https://launchpad.net/~tarantool-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~tarantool-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to