use of org.drools.verifier.core.cache.inspectors.RuleInspector in project drools by kiegroup.
the class CheckRunManagerTest method setUp.
@Before
public void setUp() throws Exception {
configuration = new AnalyzerConfigurationMock();
checkStorage = new CheckStorage(new CheckFactory(configuration) {
@Override
public HashSet<Check> makeSingleChecks(final RuleInspector ruleInspector) {
final HashSet<Check> result = new HashSet<>();
result.add(new MockSingleCheck(ruleInspector));
return result;
}
});
ruleInspectors = new ArrayList<>();
when(cache.all()).thenReturn(ruleInspectors);
ruleInspector1 = mockRowInspector(1);
ruleInspectors.add(ruleInspector1);
ruleInspector2 = mockRowInspector(2);
ruleInspectors.add(ruleInspector2);
ruleInspector3 = mockRowInspector(3);
ruleInspectors.add(ruleInspector3);
checkRunManager.addChecks(ruleInspector1.getChecks());
checkRunManager.addChecks(ruleInspector2.getChecks());
checkRunManager.addChecks(ruleInspector3.getChecks());
}
use of org.drools.verifier.core.cache.inspectors.RuleInspector in project drools by kiegroup.
the class RuleInspectorCacheTest method assertContainsRowNumbers.
private void assertContainsRowNumbers(final Collection<RuleInspector> all, final int... numbers) {
final ArrayList<Integer> rowNumbers = new ArrayList<>();
for (final RuleInspector ruleInspector : all) {
final int rowIndex = ruleInspector.getRowIndex();
rowNumbers.add(rowIndex);
}
for (final int number : numbers) {
assertTrue(rowNumbers.toString(), rowNumbers.contains(number));
}
}
use of org.drools.verifier.core.cache.inspectors.RuleInspector in project drools by kiegroup.
the class SingleRangeCheck method partition.
private Map<PartitionKey, List<RuleInspector>> partition(Collection<ObjectField> partitionFields, Collection<RuleInspector> rules, int conditionIndex) {
List<PartitionKey> keysWithNull = new ArrayList<>();
Map<PartitionKey, List<RuleInspector>> partitions = new HashMap<>();
for (RuleInspector rule : rules) {
PartitionKey key = getPartitionKey(partitionFields, rule, conditionIndex);
partitions.computeIfAbsent(key, k -> {
if (k.hasNulls()) {
keysWithNull.add(k);
}
return new ArrayList<>();
}).add(rule);
}
for (PartitionKey key : keysWithNull) {
for (Map.Entry<PartitionKey, List<RuleInspector>> partition : partitions.entrySet()) {
if (key.subsumes(partition.getKey())) {
partition.getValue().addAll(partitions.get(key));
}
}
}
keysWithNull.forEach(partitions::remove);
return partitions;
}
use of org.drools.verifier.core.cache.inspectors.RuleInspector in project drools by kiegroup.
the class PairCheckStorage method removeByOther.
private List<PairCheckBundle> removeByOther(final RuleInspector ruleInspector) {
final MultiSet<RuleInspector, PairCheckBundle> removedMap = pairChecksByOtherRowInspector.remove(ruleInspector);
if (removedMap != null) {
for (final RuleInspector inspector : removedMap.keys()) {
final Collection<PairCheckBundle> collection = removedMap.get(inspector);
pairChecks.get(inspector).removeAll(collection);
getByOther(inspector).remove(ruleInspector);
}
return removedMap.allValues();
} else {
return Collections.EMPTY_LIST;
}
}
use of org.drools.verifier.core.cache.inspectors.RuleInspector in project drools by kiegroup.
the class RuleInspectorCache method reset.
public void reset() {
for (final RuleInspector ruleInspector : ruleInspectors.values()) {
ruleInspector.clearChecks();
}
ruleInspectors.clear();
generalChecks.clear();
for (final Rule rule : index.getRules().where(Rule.uuid().any()).select().all()) {
add(new RuleInspector(rule, checkStorage, this, configuration));
}
generalChecks.add(new SingleRangeCheck(configuration, ruleInspectors.values()));
}
Aggregations