You cannot return an empty BloomFilter when there is no array of
BloomFilters to flatten. The BloomFilter is tied to a Shape. Without a
shape you cannot know what size filter to create. So we have to return
null or throw an exception. Whatever choice must be documented.

Note we do not currently check if the Shapes are all equal when
creating the BloomFilterExtractor. This is not essential but when
merging two Bloom filters in flatten an error will be thrown if the
filters are not compatible. I say it is not essential as the
functionality of the BloomFilterExtract in processBloomFilters does
not mandate any prerequisites on the Predicate for the filters. So for
example you could have many filters of different sizes and a predicate
that tests if they all contain a given IndexProducer.

Alex

On Fri, 4 Oct 2024 at 18:02, Gary Gregory <garydgreg...@gmail.com> wrote:
>
> OK, but how do you create an empty filter?
>
> Gary
>
> On Fri, Oct 4, 2024, 12:54 PM Claude Warren <cla...@xenei.com> wrote:
>
> > I think that it should return an empty filter as the javadoc says
> >
> >
> > On Fri 4 Oct 2024, 15:53 Gary D. Gregory, <ggreg...@apache.org> wrote:
> >
> > > See the new disabled test BloomFilterExtractorTest.
> > >
> > > Gary
> > >
> > > On 2024/10/04 14:51:55 "Gary D. Gregory" wrote:
> > > > Hi Claude and all,
> > > >
> > > > The method:
> > > >
> > > >
> > >
> > org.apache.commons.collections4.bloomfilter.BloomFilterExtractor.flatten()
> > > >
> > > > is documented as always returning a BloomFilter:
> > > >
> > > >     /**
> > > >      * Create a standard (non-layered) Bloom filter by merging all of
> > > the layers. If
> > > >      * the filter is empty this method will return an empty Bloom
> > filter.
> > > >      *
> > > >      * @return the merged bloom filter.
> > > >      */
> > > >
> > > > But that's not how it's coded, it can return null, the simplest
> > > reproducer is:
> > > >
> > > > BloomFilterExtractor.fromBloomFilterArray(new BloomFilter[0]).flatten()
> > > -> null
> > > >
> > > > Should we:
> > > >
> > > > - Change the Javadoc
> > > > - Change the code
> > > > -- How should this code be changed?
> > > > -- Should the method be moved to BloomFilter and use "this" as the
> > > default filter?
> > > >
> > > > TY,
> > > > Gary
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> > > > For additional commands, e-mail: dev-h...@commons.apache.org
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> > > For additional commands, e-mail: dev-h...@commons.apache.org
> > >
> > >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to