You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Selva Kumar <se...@gmail.com> on 2015/09/13 16:58:25 UTC

Lucene 5 : are FixedBitSet and SparseFixedBitSet thread-safe?


Re: Lucene 5 : are FixedBitSet and SparseFixedBitSet thread-safe?

Posted by Selva Kumar <se...@gmail.com>.
Just trying to understand which local extends are still relevant OR need
refactoring after migration to Lucene 5. We use BitSets in online and
multi-threaded batch applications.

it seems FixedBitSet can be potentially used in divide and conquer by
applications without any locking.

Thanks Toke.

On Sun, Sep 13, 2015 at 11:39 AM, Toke Eskildsen <te...@statsbiblioteket.dk>
wrote:

> Selva Kumar <se...@gmail.com> wrote:
> > Subject: Lucene 5 : are FixedBitSet and SparseFixedBitSet thread-safe?
> <eom>
>
> Short answer: No.
>
> Longer answer: Reading values and calling methods that does not modify the
> structure is fine. Writing values is not safe, but can work for
> FixedBitSet, if you take care not to update values within the same 64bit
> block from multiple Threads at a time.
>
> It is not too hard to make it Thread-safe and efficient
> (AtomicLongArray.compareandSet is your friend) and I made such a variant
> for a project, but the Solr-code is generaly very 1-request-1-Thread, so
> there is a lot of places to change code in order for it to take advantage
> of a changes FixedBitSet. What is it you are trying to achieve?
>
>
> - Toke Eskildsen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Lucene 5 : are FixedBitSet and SparseFixedBitSet thread-safe?

Posted by Toke Eskildsen <te...@statsbiblioteket.dk>.
Selva Kumar <se...@gmail.com> wrote:
> Subject: Lucene 5 : are FixedBitSet and SparseFixedBitSet thread-safe? <eom>

Short answer: No.

Longer answer: Reading values and calling methods that does not modify the structure is fine. Writing values is not safe, but can work for FixedBitSet, if you take care not to update values within the same 64bit block from multiple Threads at a time.

It is not too hard to make it Thread-safe and efficient (AtomicLongArray.compareandSet is your friend) and I made such a variant for a project, but the Solr-code is generaly very 1-request-1-Thread, so there is a lot of places to change code in order for it to take advantage of a changes FixedBitSet. What is it you are trying to achieve?


- Toke Eskildsen

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org