-
-
Notifications
You must be signed in to change notification settings - Fork 17
LT-22190 Use BitArray for large symbolic feature value sets #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #322 +/- ##
==========================================
- Coverage 70.75% 70.72% -0.04%
==========================================
Files 390 392 +2
Lines 32806 33173 +367
Branches 4612 4653 +41
==========================================
+ Hits 23213 23461 +248
- Misses 8527 8624 +97
- Partials 1066 1088 +22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ddaspit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddaspit reviewed all commit messages.
Reviewable status: 0 of 18 files reviewed, 2 unresolved discussions
src/SIL.Machine/FeatureModel/SymbolicFeatureValueFactory.cs line 7 at r1 (raw file):
namespace SIL.Machine.FeatureModel { public class SymbolicFeatureValueFactory
Would it be possible to entirely encapsulate the different implementations of symbolic feature value within the SymbolicFeatureValue class instead of this new factory? You could use composition rather than inheritance to support the implementations. You could define an interface/ABC that abstracts the two implementations. The constructor for SymbolicFeatureValue would create the correct instance and delegate calls to the instance where necessary. This design should greatly reduce the number of changes that are required to the rest of parser.
src/SIL.Machine/FeatureModel/SymbolicFeatureValueBA.cs line 221 at r1 (raw file):
{ BitArray notOtherFlags = ((BitArray)otherFlags.Clone()).Not(); BitArray notOtherFlagsAndFeatureMask = new BitArray(notOtherFlags.And(Feature.MaskBA));
It feels like the number of BitArray instances could be reduced. Could we reuse some of the BitArray instances?
|
On the BitArray instances: Unlike with ulong, applying any operation to a BitArray changes its value. I ran into failed tests because of one being negated, say. Using Clone() or creating a new instance got around this problem. |
|
On using composition: I have no experience with using composition. It sounds good, but I'm afraid I'm rather clueless on how to do it. Could you point me to some examples?
Then the SymbolicFeatureValue class would have two new properties, one for each kind (ulong and BitArray). When creating a new instance of SymbolicFeatureValue, the constructor uses the appropriate property. How then does invoking one of the methods work? |
|
This is replaced by #330 |
This is a fix related to "LT-22190 Hermit Crab adds wrong POSes to compound rules when there are more than 64 POSes"
The problem is that Machine uses a ulong to represent the possible values of a feature. This solution uses a BitArray instead of a ulong whenever there are more than sizeof(ulong) * 8 (=64) values.
The solution has a subclass of SymbolicFeatureValue called SymbolicFeatureValueBA which is used whenever there are more than 64 possible symbol values. It adds a SymbolicFeatureValueFactory singleton class to create symbolic feature value objects.
The SymbolicFeatureValue class also now has a static method called GetFeatureSymbolFromFeatureStruct(). For reasons not clear to me, the static implicit operator SymbolicFeatureValue(FeatureSymbol symbol) method returns a null when invoked on a SymbolicFeatureValueBA oject. This GetFeatureSymbolFromFeatureStruct() method is a way I found to make things work. If there is a better way to do it, please let me know.
This change is