Lucene - Core
  1. Lucene - Core
  2. LUCENE-5277

Modify FixedBitSet copy constructor to take numBits to allow grow/shrink the new bitset

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.6, 6.0
    • Component/s: core/index
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      FixedBitSet copy constructor is redundant the way it is now – one can call FBS.clone() to achieve that (and indeed, no code in Lucene calls this ctor). I think it will be useful to add a numBits parameter to that method to allow growing/shrinking the new bitset, while copying all relevant bits from the passed one.

        Activity

        Hide
        Shai Erera added a comment -

        Patch adds the extra parameter and tests. I think it's ok to not deprecate this ctor and add another one since it's not used in Lucene code, and I imagine it's quite expert to do + there's an easy alternative (call clone()). We can also add size() to return numBits (actually I think it's useful to add that anyway?)

        Show
        Shai Erera added a comment - Patch adds the extra parameter and tests. I think it's ok to not deprecate this ctor and add another one since it's not used in Lucene code, and I imagine it's quite expert to do + there's an easy alternative (call clone()). We can also add size() to return numBits (actually I think it's useful to add that anyway?)
        Hide
        Uwe Schindler added a comment -

        Is there any issue that will use the new ctor? As the current ctor is unused why not simply remove it and leave adding the new one to an issue that really needs it?

        Show
        Uwe Schindler added a comment - Is there any issue that will use the new ctor? As the current ctor is unused why not simply remove it and leave adding the new one to an issue that really needs it?
        Hide
        Shai Erera added a comment -

        I thought of that ... it started in LUCENE-5248 where I want to keep a growable bitset alongside the docs/values arrays to mark whether a document has an updated value or not (following Rob's idea). When I implemented that using OpenBitSet, I discovered the bug and opened LUCENE-5272. As I worked on fixing the bug, I realized OBS has other issues as well and thought that perhaps I can use FixedBitSet, only grow it by copying its array. This is doable even without the ctor, since I can call getBits() and do it like that:

        FixedBitSet newBits = new FixedBitSet(17); // new capacity
        System.arraycopy(oldBits.getBits(), 0, newBits.getBits(), 0, oldBits.getBits().length);
        

        I then noticed there is a ctor already in FixedBitSet which copies another FBS so I thought just to improve it. It seems more intuitive to do t than let users figure out they can grow a FixedBitSet like above?

        Show
        Shai Erera added a comment - I thought of that ... it started in LUCENE-5248 where I want to keep a growable bitset alongside the docs/values arrays to mark whether a document has an updated value or not (following Rob's idea). When I implemented that using OpenBitSet, I discovered the bug and opened LUCENE-5272 . As I worked on fixing the bug, I realized OBS has other issues as well and thought that perhaps I can use FixedBitSet, only grow it by copying its array. This is doable even without the ctor, since I can call getBits() and do it like that: FixedBitSet newBits = new FixedBitSet(17); // new capacity System .arraycopy(oldBits.getBits(), 0, newBits.getBits(), 0, oldBits.getBits().length); I then noticed there is a ctor already in FixedBitSet which copies another FBS so I thought just to improve it. It seems more intuitive to do t than let users figure out they can grow a FixedBitSet like above?
        Hide
        ASF subversion and git services added a comment -

        Commit 1531627 from Shai Erera in branch 'dev/trunk'
        [ https://svn.apache.org/r1531627 ]

        LUCENE-5277: Modify FixedBitSet copy constructor to take numBits to allow grow/shrink the new bitset

        Show
        ASF subversion and git services added a comment - Commit 1531627 from Shai Erera in branch 'dev/trunk' [ https://svn.apache.org/r1531627 ] LUCENE-5277 : Modify FixedBitSet copy constructor to take numBits to allow grow/shrink the new bitset
        Hide
        ASF subversion and git services added a comment -

        Commit 1531630 from Shai Erera in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1531630 ]

        LUCENE-5277: Modify FixedBitSet copy constructor to take numBits to allow grow/shrink the new bitset

        Show
        ASF subversion and git services added a comment - Commit 1531630 from Shai Erera in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1531630 ] LUCENE-5277 : Modify FixedBitSet copy constructor to take numBits to allow grow/shrink the new bitset
        Hide
        Shai Erera added a comment -

        Committed to trunk and 4x.

        Show
        Shai Erera added a comment - Committed to trunk and 4x.

          People

          • Assignee:
            Shai Erera
            Reporter:
            Shai Erera
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development