[
https://issues.apache.org/jira/browse/DERBY-2191?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dyre Tjeldvoll updated DERBY-2191:
----------------------------------
Attachment: shrink.v1.stat
shrink.v1.diff
Attaching shrink.v1 which tries get rid of some of the unexpected behavior when
growing and shrinking bitsets (commented in the unit test). The goal was that
both grow(int) and shrink(int) should disallow negative arguments and grow(int)
should only to accept arguments larger than the current bitset size, and by
symmetry shrink(int) should only allow arguments smaller than the current size.
Unfortunately, that is currently not possible since the existing usage requires
grow(int n) where n is smaller than the current size to be a noop. So in the
patch there is an asymmetry between grow(int) and shrink(int) where shrink(int)
will not accept n larger than the current size.
The patch also changes the order of the asserts in the tests so that the assert
on the length of the byte array always is the last assert. This is necessary
since getByteArray() trims away any unused bytes of the byte array making any
later invariant checks etc. worthless.
The patch fixes a bug in shrink(int). Without this patch shrink(int) will not
clear any bytes beyond the new last byte. E.g. if a bitset is shrunk from 18 to
9 bits, the now unused bits in the second byte will be cleared, but NOT the
bits in the third byte. This error was not caught by any tests because they
called getByteArray() before checking the invariant.
> Cleanup of FormatableBitSet
> ---------------------------
>
> Key: DERBY-2191
> URL: https://issues.apache.org/jira/browse/DERBY-2191
> Project: Derby
> Issue Type: Improvement
> Components: Miscellaneous
> Affects Versions: 10.2.1.6
> Reporter: Dyre Tjeldvoll
> Assigned To: Dyre Tjeldvoll
> Priority: Trivial
> Fix For: 10.3.0.0
>
> Attachments: anysetbit.v1.diff, anysetbit.v1.stat, anysetbit.v2.diff,
> bitops.v1.diff, bitops.v1.stat, bitops.v2.diff, bitops.v2.stat,
> bitops.v3.diff, bitopt.v1.diff, bitopt.v1.stat, bitopt.v2.diff,
> boundarycheck.v1.diff, boundarycheck.v1.stat, cleanup2191.diff,
> cleanup2191.stat, deadcode.v1.diff, deadcode.v2.diff, fbstst.v1.diff,
> fbstst.v1.stat, FormatableBitSetTest.java, numbitsset.v1.diff,
> numbitsset.v1.stat, numbitsset.v2.diff, numbitstest.diff, shrink.v1.diff,
> shrink.v1.stat, unusedmethods.v1.diff, unusedmethods.v1.stat,
> valuenotnull.v1.diff, valuenotnull.v1.stat
>
>
> The implementation of FormatableBitSet could be streamlined. Dead code can be
> removed and the implementation of some methods can be simplified.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.