use of org.drools.verifier.core.index.model.ObjectField in project drools by kiegroup.
the class ConditionsInspectorTest method setUp.
@Before
public void setUp() throws Exception {
configurationMock = new AnalyzerConfigurationMock();
field = new Field(new ObjectField("Person", "Integer", "age", configurationMock), "Person", "Integer", "age", configurationMock);
}
use of org.drools.verifier.core.index.model.ObjectField in project drools by kiegroup.
the class ConditionsInspectorTest method testSubsume003.
@Test
public void testSubsume003() throws Exception {
final Field nameField = new Field(new ObjectField("Person", "String", "name", configurationMock), "Person", "String", "name", configurationMock);
final Field lastNameField = new Field(new ObjectField("Person", "String", "lastName", configurationMock), "Person", "String", "lastName", configurationMock);
final ConditionsInspectorMultiMap a = getConditions(new ComparableConditionInspector<String>(new FieldCondition(nameField, mock(Column.class), "==", new Values<>("Toni"), configurationMock), configurationMock));
final ConditionsInspectorMultiMap b = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(12), configurationMock), configurationMock), new ComparableConditionInspector<String>(new FieldCondition(nameField, mock(Column.class), "==", new Values<>("Toni"), configurationMock), configurationMock), new ComparableConditionInspector<String>(new FieldCondition(lastNameField, mock(Column.class), "==", new Values<>("Rikkola"), configurationMock), configurationMock));
assertFalse(a.subsumes(b));
assertTrue(b.subsumes(a));
}
use of org.drools.verifier.core.index.model.ObjectField in project drools by kiegroup.
the class FieldInspectorUpdateTest method setUp.
@Before
public void setUp() throws Exception {
configurationMock = new AnalyzerConfigurationMock();
final Field field = spy(new Field(objectField, "org.Person", "String", "name", configurationMock));
fieldCondition = makeCondition(field);
fieldAction = makeAction(field);
new FieldInspector(field, ruleInspectorUpdater, new AnalyzerConfigurationMock());
}
use of org.drools.verifier.core.index.model.ObjectField 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.index.model.ObjectField in project drools by kiegroup.
the class SingleRangeCheck method checkRanges.
private void checkRanges(Collection<ObjectField> rangeFields, Map<PartitionKey, List<RuleInspector>> partitions, int conditionIndex) {
for (Map.Entry<PartitionKey, List<RuleInspector>> partition : partitions.entrySet()) {
List<List<? extends Range<?>>> dimensions = new ArrayList<>();
for (ObjectField field : rangeFields) {
if ("Integer".equals(field.getFieldType())) {
checkMonodimensionalRange(partition, dimensions, field, conditionIndex, IntegerRange::new, Integer.MIN_VALUE, Integer.MAX_VALUE);
} else if ("Double".equals(field.getFieldType())) {
checkMonodimensionalRange(partition, dimensions, field, conditionIndex, NumericRange::new, Double.MIN_VALUE, Double.MAX_VALUE);
} else {
checkMonodimensionalRange(partition, dimensions, field, conditionIndex, ComparableRange::new, ComparableWrapper.MIN_VALUE, ComparableWrapper.MAX_VALUE);
}
}
checkBidimensionalRanges(partition, dimensions);
}
}
Aggregations