git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 3/6] bloom: add helper to check if any key in a vector is present

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 10, 2026, 07:03 UTC
Message-ID
<aqJWX0INerT8F687@pks.im>
In-Reply-To
<20260901-toon-speed-up-last-modified-v4-3-a09949800404@iotcl.com>
On Tue, Sep 01, 2026 at 11:10:23AM +0200, Toon Claes wrote:
Show 19 quoted lines
> diff --git a/bloom.c b/bloom.c
> index caf22f9831..b96534e6e3 100644
> --- a/bloom.c
> +++ b/bloom.c
> @@ -607,6 +607,18 @@ int bloom_filter_contains_vec(const struct bloom_filter *filter,
>  	return ret;
>  }
>  
> +int bloom_filter_contains_any_vec(const struct bloom_filter *filter,
> +				  const struct bloom_keyvec *vec,
> +				  const struct bloom_filter_settings *settings)
> +{
> +	int ret = 0;
> +
> +	for (size_t nr = 0; !ret && nr < vec->count; nr++)
> +		ret = bloom_filter_contains(filter, &vec->key[nr], settings);
> +
> +	return ret;
> +}

`bloom_filter_contains()` may also return -1 in case `filter->len == 0`, and we'd bubble up that code. But here...

Show 18 quoted lines
> diff --git a/bloom.h b/bloom.h
> index 92ab2100d3..f508db23ad 100644
> --- a/bloom.h
> +++ b/bloom.h
> @@ -164,6 +164,17 @@ int bloom_filter_contains_vec(const struct bloom_filter *filter,
>  			      const struct bloom_keyvec *v,
>  			      const struct bloom_filter_settings *settings);
>  
> +/*
> + * bloom_filter_contains_any_vec - Check if any key in a key vector is in the
> + * Bloom filter.
> + *
> + * Returns 1 if **any** key in the vector is present in the filter, 0 if none
> + * of them are.
> + */
> +int bloom_filter_contains_any_vec(const struct bloom_filter *filter,
> +				  const struct bloom_keyvec *v,
> +				  const struct bloom_filter_settings *settings);

... you only document that it may return 0 or 1. We should either properly document this or munge the returned value to be 0 or 1, only. And if so, we could probably adapt this function to have a boolean return value.

Patrick
Previous: Toon ClaesNext: Toon Claes
Message 16 of 22 in “last-modified: use the pathspec's Bloom key to pre-filter commits”
  1. 0/6 last-modified: use the pathspec's Bloom key to pre-filter commitsToon Claes, Aug 31, 2026
  2. 1/6 revision: move bloom keyvec precondition into functionToon Claes, Aug 31, 2026
  3. 2/6 revision: expose check for paths maybe changed in Bloom filterToon Claes, Aug 31, 2026
  4. 3/6 bloom: add helper to check if any key in a vector is presentToon Claes, Aug 31, 2026
  5. 4/6 revision: add Bloom check that includes parent directoriesToon Claes, Aug 31, 2026
  6. 5/6 last-modified: check pathspec against Bloom filter firstToon Claes, Aug 31, 2026
  7. 6/6 last-modified: keep per-path Bloom filters for wildcard pathspecsToon Claes, Aug 31, 2026
  8. Junio C HamanoSep 1, 2026
  9. Toon ClaesSep 1, 2026
  10. Junio C HamanoSep 1, 2026
  11. Junio C HamanoAug 31, 2026
  12. 0/6 last-modified: use the pathspec's Bloom key to pre-filter commitsToon Claes, Sep 1, 2026
  13. 1/6 revision: move bloom keyvec precondition into functionToon Claes, Sep 1, 2026
  14. 2/6 revision: expose check for paths maybe changed in Bloom filterToon Claes, Sep 1, 2026
  15. 3/6 bloom: add helper to check if any key in a vector is presentToon Claes, Sep 1, 2026
  16. Patrick SteinhardtSep 10, 2026
  17. 4/6 revision: add Bloom check that includes parent directoriesToon Claes, Sep 1, 2026
  18. Patrick SteinhardtSep 10, 2026
  19. 5/6 last-modified: check pathspec against Bloom filter firstToon Claes, Sep 1, 2026
  20. Patrick SteinhardtSep 10, 2026
  21. 6/6 last-modified: keep per-path Bloom filters for wildcard pathspecsToon Claes, Sep 1, 2026
  22. Patrick SteinhardtSep 10, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.