All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.drools.verifier.optimisation.PatternOrder.drl Maven / Gradle / Ivy

There is a newer version: 9.44.0.Final
Show newest version
#created on: 27.10.2007
package org.drools.verifier.optimisation

#list any import classes here.
import java.util.Collection;
import java.util.ArrayList;

import org.drools.verifier.components.Pattern;
import org.drools.verifier.components.VerifierRule;
import org.drools.verifier.components.OperatorDescr;
import org.drools.verifier.components.VerifierEvalDescr;
import org.drools.verifier.components.VerifierComponent;
import org.drools.verifier.components.VerifierComponentType;
import org.drools.verifier.report.components.VerifierMessage;
import org.drools.verifier.report.components.Severity;
import org.drools.verifier.report.components.MessageType;
import org.drools.verifier.dao.VerifierResult;


#declare any global variables here
global VerifierResult result;




# Informs that rule would be more effective if eval
# was after fact patterns.
#
# Type: Note
# Dependencies: None
# Example: 
#		eval(function( $something )) 
#		Pattern()
#
rule "Optimise evals inside pattern"
	when
		$operator :OperatorDescr()

		$eval :VerifierEvalDescr(
			parent == $operator
		)

		# Any other VerifierComponent that is not predicate or operator
		$other :VerifierComponent(
			parent == $operator,
			orderNumber > $eval.orderNumber,
			( componentType != VerifierComponentType.OPERATOR && != VerifierComponentType.EVAL )
		)

		$rule :VerifierRule(
			id == $eval.ruleId
		)
	then
		Collection list = new ArrayList();
		list.add( $eval );
		list.add( $other );
		result.add( new VerifierMessage(
								Severity.NOTE,
								MessageType.OPTIMISATION,
								$rule,
								"Rule \"" + $eval.getRuleName() +
								"\" would be more effective if the less expensive component, (" +
								$other +
								"), could be before (" +
								$eval + ").",
								list ) );
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy