]
Soumitra Kumar commented on DROOLS-982:
---------------------------------------
I have submitted a pull request
.
I have only modified the Antlr grammar files, and have to checked in the generated
sources.
Please review it and let me know what else needs to be done.
DRL file with a rule having long LHS expression takes very long time
to parse
-----------------------------------------------------------------------------
Key: DROOLS-982
URL:
https://issues.jboss.org/browse/DROOLS-982
Project: Drools
Issue Type: Enhancement
Reporter: Soumitra Kumar
Assignee: Mark Proctor
My DRL file is:
package sk.rule.ruleset.r1;
import sk.event.Event;
// Event declaration
declare Event
@role(event)
@timestamp(time)
end
rule "Long LHS"
when
$event : Event ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (contains
("name", "foo") && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) &&
contains ("name", "foo")) && contains ("name",
"foo")) && contains ("name", "foo")) )
then
// Empty
end
// Event definition
package sk.event
sealed case class Event (time: Long, map: Map [String, String]) {
def contains (key: String, value: String): Boolean = false
}
// Main class
package sk.apps
import java.io.File
import com.typesafe.scalalogging.LazyLogging
import org.kie.api.io.ResourceType
import org.kie.internal.io.ResourceFactory
import org.kie.internal.builder.KnowledgeBuilderFactory
object DrlParsing extends LazyLogging {
def main (args: Array [String]): Unit = {
logger.info (s"Starting KnowledgeBuilder")
val kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder ()
args.foreach { fileName =>
logger.info (s"Adding file $fileName")
kbuilder.add (ResourceFactory.newFileResource (new File (fileName)),
ResourceType.DRL)
}
if (kbuilder.hasErrors ())
logger.error (kbuilder.getErrors ().toString ())
}
}
The project URL is
https://github.com/soumitrak/drl-parsing