You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Claude Warren <cl...@xenei.com> on 2019/10/07 17:01:30 UTC

[collections] ProtoBloomFilter.Builder -- opinions sought

Greetings,

 I am preparing a pull request to bring Bloom Filters in the the
collections package.  The pull requests is at
https://github.com/apache/commons-collections/pull/83 and the Jira ticket
is https://issues.apache.org/jira/browse/COLLECTIONS-728


The package has a builder that create ProtoBloomFilters that are then used
to construct real bloom filters based on the desired "shape" of the
Filter.  The question here is should the builder have the build() / with()
methods that is currently has or should the number of methods be pruned?

Currently the builder has the following methods

build()
build(byte)
build(byte[])
build(ByteBuffer)
build(ProtoBloomFilter)
build(String)
with(byte)
with(byte[])
with(ByteBuffer)
with(ProtoBloomFilter)
with(String)

It has been suggested that this should be reduced to

build()
with(byte)
with(byte[])
with(ByteBuffer)
with(ProtoBloomFilter)
with(String)

The reasoning behind this is that is is akin to building a message digest.
The java.security.MessageDigest class has multiple digest() and update()
methods that are logically the same as the build() and with() methods in
the ProtoBloomFilter.Builder.  Thus the ProtoBloomFilter.Builder follows
the same pattern.

If you have an opinion please respond.

Claude
-- 
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Re: [collections] ProtoBloomFilter.Builder -- opinions sought

Posted by Gilles Sadowski <gi...@gmail.com>.
Hi.

Le lun. 7 oct. 2019 à 19:01, Claude Warren <cl...@xenei.com> a écrit :
>
> Greetings,
>
>  I am preparing a pull request to bring Bloom Filters in the the
> collections package.  The pull requests is at
> https://github.com/apache/commons-collections/pull/83 and the Jira ticket
> is https://issues.apache.org/jira/browse/COLLECTIONS-728
>
>
> The package has a builder that create ProtoBloomFilters that are then used
> to construct real bloom filters based on the desired "shape" of the
> Filter.  The question here is should the builder have the build() / with()
> methods that is currently has or should the number of methods be pruned?
>
> Currently the builder has the following methods
>
> build()
> build(byte)
> build(byte[])
> build(ByteBuffer)
> build(ProtoBloomFilter)
> build(String)
> with(byte)
> with(byte[])
> with(ByteBuffer)
> with(ProtoBloomFilter)
> with(String)
>
> It has been suggested that this should be reduced to
>
> build()
> with(byte)
> with(byte[])
> with(ByteBuffer)
> with(ProtoBloomFilter)
> with(String)

+1 to a lean API.

>
> The reasoning behind this is that is is akin to building a message digest.
> The java.security.MessageDigest class has multiple digest() and update()

The number of variants is lower (but even in that case I don't think
that it was warranted).

> methods that are logically the same as the build() and with() methods in
> the ProtoBloomFilter.Builder.  Thus the ProtoBloomFilter.Builder follows
> the same pattern.

Since the classes are not directly related, why should we follow
the (dubious, IMO) pattern?
Best is to keep the API lean, and let future usage dictate whether this
must be revised.

Best,
Gilles

>
> If you have an opinion please respond.
>
> Claude
> --
> I like: Like Like - The likeliest place on the web
> <http://like-like.xenei.com>
> LinkedIn: http://www.linkedin.com/in/claudewarren

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