use of org.drools.core.spi.BetaNodeFieldConstraint in project drools by kiegroup.
the class TripleBetaConstraintsTest method testOneIndxed.
@Test
public void testOneIndxed() {
BetaNodeFieldConstraint constraint0 = getConstraint("cheeseType0", Operator.EQUAL, "type", Cheese.class);
BetaNodeFieldConstraint constraint1 = getConstraint("cheeseType1", Operator.NOT_EQUAL, "type", Cheese.class);
BetaNodeFieldConstraint constraint3 = getConstraint("cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
BetaNodeFieldConstraint[] constraints = new BetaNodeFieldConstraint[] { constraint0, constraint1, constraint3 };
checkBetaConstraints(constraints, TripleBetaConstraints.class);
constraint0 = getConstraint("cheeseType0", Operator.NOT_EQUAL, "type", Cheese.class);
constraint1 = getConstraint("cheeseType1", Operator.EQUAL, "type", Cheese.class);
constraint3 = getConstraint("cheeseType2", Operator.NOT_EQUAL, "type", Cheese.class);
constraints = new BetaNodeFieldConstraint[] { constraint0, constraint1, constraint3 };
checkBetaConstraints(constraints, TripleBetaConstraints.class);
constraint0 = getConstraint("cheeseType0", Operator.NOT_EQUAL, "type", Cheese.class);
constraint1 = getConstraint("cheeseType1", Operator.NOT_EQUAL, "type", Cheese.class);
constraint3 = getConstraint("cheeseType2", Operator.EQUAL, "type", Cheese.class);
constraints = new BetaNodeFieldConstraint[] { constraint0, constraint1, constraint3 };
checkBetaConstraints(constraints, TripleBetaConstraints.class);
}
use of org.drools.core.spi.BetaNodeFieldConstraint in project drools by kiegroup.
the class SingleBetaConstraintsTest method testNotIndexedForComparison.
@Test
public void testNotIndexedForComparison() {
BetaNodeFieldConstraint constraint0 = getConstraint("cheeseType0", Operator.LESS, "type", Cheese.class);
BetaNodeFieldConstraint[] constraints = new BetaNodeFieldConstraint[] { constraint0 };
checkBetaConstraints(constraints, SingleBetaConstraints.class, NodeTypeEnums.JoinNode);
}
use of org.drools.core.spi.BetaNodeFieldConstraint in project drools by kiegroup.
the class SingleBetaConstraintsTest method testIndexedForComparison.
@Test
public void testIndexedForComparison() {
BetaNodeFieldConstraint constraint0 = getConstraint("cheeseType0", Operator.LESS, "type", Cheese.class);
BetaNodeFieldConstraint[] constraints = new BetaNodeFieldConstraint[] { constraint0 };
checkBetaConstraints(constraints, SingleBetaConstraints.class, NodeTypeEnums.ExistsNode);
}
use of org.drools.core.spi.BetaNodeFieldConstraint in project drools by kiegroup.
the class IndexUtil method swap.
private static void swap(BetaNodeFieldConstraint[] constraints, int p1, int p2) {
if (p1 != p2) {
BetaNodeFieldConstraint temp = constraints[p2];
constraints[p2] = constraints[p1];
constraints[p1] = temp;
}
}
use of org.drools.core.spi.BetaNodeFieldConstraint in project drools by kiegroup.
the class IndexUtil method compositeAllowed.
public static boolean compositeAllowed(BetaNodeFieldConstraint[] constraints, short betaNodeType) {
// 1) If there is 1 or more unification restrictions it cannot be composite
// 2) Ensures any non unification restrictions are first
int firstUnification = -1;
int firstNonUnification = -1;
for (int i = 0, length = constraints.length; i < length; i++) {
if (isIndexable(constraints[i], betaNodeType)) {
final boolean isUnification = ((IndexableConstraint) constraints[i]).isUnification();
if (isUnification && firstUnification == -1) {
firstUnification = i;
} else if (!isUnification && firstNonUnification == -1) {
firstNonUnification = i;
}
}
if (firstUnification != -1 && firstNonUnification != -1) {
break;
}
}
if (firstNonUnification != -1 && firstNonUnification > 0) {
// Make sure a nonunification indexable constraint is first
swap(constraints, 0, firstNonUnification);
}
return (firstUnification == -1);
}
Aggregations