mysql - 如何在StatefulKnowledgeSession中插入大量事实(Drools)

标签 mysql drools

我想在 StatefulKnowledgeSession 中插入很多事实。

但它没有到达 fireAllRules() 部分

我的事实有 10k 个事实。进入MySQL。

http://i.stack.imgur.com/Xbnoh.png

http://i.stack.imgur.com/7tJEU.png

而且陈旧

我的代码:

public void runDrools() {
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    starttime = new Date();

    if (PersonalCondition1.isSelected() && ConvenienceDay_jCheckBox.isSelected()) {
        kbuilder.add(ResourceFactory.newClassPathResource("Rules1_Conv_Schedule.drl", getClass()), ResourceType.DRL);
    } else if (PersonalCondition1.isSelected() && !ConvenienceDay_jCheckBox.isSelected()) { 
        kbuilder.add(ResourceFactory.newClassPathResource("Rules1_Non-Conv_Schedule.drl", getClass()), ResourceType.DRL);
    } else if (PersonalCondition2.isSelected() && ConvenienceDay_jCheckBox.isSelected()) { 
        kbuilder.add(ResourceFactory.newClassPathResource("Rules2_Conv_Schedule.drl", getClass()), ResourceType.DRL);
    } else if (PersonalCondition2.isSelected() && !ConvenienceDay_jCheckBox.isSelected()) { 
        kbuilder.add(ResourceFactory.newClassPathResource("Rules2_Non-Conv_Schedule.drl", getClass()), ResourceType.DRL);
    }
    if (kbuilder.hasErrors()) {
        System.err.println(kbuilder.getErrors().toString());
    }

    kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

    boolean InBuild, NearbyBuild, OutBuild;

    if (NearbyBuild1.isSelected()) {
        InBuild = false;
        NearbyBuild = true;
        OutBuild = true;
    } else if (NearbyBuild2.isSelected()) {
        InBuild = true;
        NearbyBuild = true;
        OutBuild = true;
    } else {
        InBuild = false;
        NearbyBuild = false;
        OutBuild = true;
    }

    if (Control3_jCheckBox.isSelected()) {
        Amount_Test = (Integer) Amount_jSpinner.getValue();
    } else {
        Amount_Test = 0;
    }

    Check check = new Check(Amount_Test, InBuild, NearbyBuild, OutBuild, Status_JLabel);
    ksession.insert(check);

    Data_List list = new Data_List();
    ksession.insert(list);

    if (Control3_jCheckBox.isSelected()) {
        Amount_Test = (Integer) Amount_jSpinner.getValue();
    } else {
        Amount_Test = 2;
    }

    try {

        rs_ro = stm_ro.executeQuery("SELECT * FROM room");
        while (rs_ro.next()) {
            String code = rs_ro.getString("ro_code"),
                    capa = rs_ro.getString("ro_capacity");
            Room room = new Room(code, Integer.parseInt(capa));
            ksession.insert(room);
        }

        rs_sch_exam = stm_sch_exam.executeQuery("SELECT *,DATE_FORMAT(sch_date,'%a') AS day FROM schedule_exam ORDER BY sch_date ASC");
        while (rs_sch_exam.next()) {
            String date = rs_sch_exam.getString("sch_date"),
                    day = rs_sch_exam.getString("day"),
                    start = rs_sch_exam.getString("sch_start"),
                    end = rs_sch_exam.getString("sch_end"),
                    subj = rs_sch_exam.getString("sch_subject"),
                    depa = rs_sch_exam.getString("sch_depart"),
                    sec = rs_sch_exam.getString("sch_sec"),
                    room = rs_sch_exam.getString("sch_room");
            Schedule schedule = new Schedule(date, day, subj, sec, depa, room, start, end);
            schedule.setConnect(getHost(), getUser(), getPass());
            ksession.insert(schedule);
        }

        Random rand = new Random();
        rs_peo = stm_peo.executeQuery("SELECT * FROM control_exam");
        while (rs_peo.next()) {
            String code = rs_peo.getString("ce_code"),
                    depart = rs_peo.getString("ce_department"),
                    room = rs_peo.getString("ce_room"),
                    sun = rs_peo.getString("ce_sunday"),
                    mon = rs_peo.getString("ce_monday"),
                    tue = rs_peo.getString("ce_tuesday"),
                    wed = rs_peo.getString("ce_wednesday"),
                    thu = rs_peo.getString("ce_thursday"),
                    fri = rs_peo.getString("ce_friday"),
                    sat = rs_peo.getString("ce_saturday"),
                    max = rs_peo.getString("ce_maxcontrol");
            if (max.equals("")) {
                max = MaxDays_jSpinner.getValue() + "";
            }
            Control_Exam controlExam = new Control_Exam(code, depart, room,
                    Integer.parseInt(sun), Integer.parseInt(mon), Integer.parseInt(tue),
                    Integer.parseInt(wed), Integer.parseInt(thu), Integer.parseInt(fri),
                    Integer.parseInt(sat), Integer.parseInt(max));
            controlExam.setConnect(getHost(), getUser(), getPass());
            ksession.insert(controlExam);
        }

        rs_sub = stm_sub.executeQuery("SELECT * FROM subject");
        while (rs_sub.next()) {
            String code = rs_sub.getString("su_code"),
                    name = rs_sub.getString("su_name"),
                    educator = rs_sub.getString("su_educator");
            Subject subject = new Subject(code, name, educator);
            System.out.println(" subject:" + subject.getCode());
            ksession.insert(subject);
        }

        rs_nea = stm_nea.executeQuery("SELECT * FROM nearby");
        while (rs_nea.next()) {
            String build = rs_nea.getString("nb_build"),
                    near;
            if (NearbyBuild1.isSelected()) {
                near = rs_nea.getString("nb_nearby") + "," + build;
            } else {
                near = rs_nea.getString("nb_nearby");
            }
            Nearby nearby = new Nearby(build, near);
            System.out.println(" nearby:" + nearby.getBuild());
            ksession.insert(nearby);
        }
        databasetime = new Date();

        if ((((databasetime.getTime() - starttime.getTime()) / 1000) / 60) >= 1) {
            DatabaseTime = MTime.format(databasetime.getTime() - starttime.getTime()) + " นาที";
        } else {
            DatabaseTime = MSTime.format(databasetime.getTime() - starttime.getTime()) + " วินาที";
        }
        ksession.fireAllRules();
        ksession.dispose();

    } catch (Exception e) {
        Amount_Test = -1;
        Manage_Schedule.this.dispose();
    }
}

简单规则 (Rules1_Non-Conv_Schedule.drl):

import schedule.Schedule
import schedule.Nearby
import schedule.Room
import schedule.Subject
import schedule.Control_Exam
import schedule.Check
import schedule.Data_List
rule "Add control exam first in Build"
    salience 14
    when
        $check : Check( )
        eval( $check.getInBuildState() )
        $scheduleCheck : Schedule( )
        $controlExamCondition : Control_Exam( max > 0 )
        $room : Room( build == $controlExamCondition.getBuild() ) 
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( room == $room.getCode() , 
                                subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() )
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
                              starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval($schedule.getStateEmptyCE1()) 
    then
        modify( $schedule ) { setControlExam1( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 1: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

rule "Add control exam first nearby Build"
    salience 11
    when
        $check : Check( )
        eval( $check.getNearbyBuildState() )
        $scheduleCheck : Schedule( )
        $near : Nearby(  )
        $room : Room( build == $near.getBuild() ) 
        $controlExamCondition : Control_Exam( build memberOf ( $near.getArrayNearBy() ) , max > 0 )
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( room == $room.getCode() , 
                                subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() ) 
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
                              starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval($schedule.getStateEmptyCE1()) 
    then
        modify( $schedule ) { setControlExam1( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 1: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

rule "Add control exam first out Build"
    salience 0
    when
        $check : Check( )
        eval( $check.getOutBuildState() )
        $scheduleCheck : Schedule( )
        $controlExamCondition : Control_Exam( max > 0 )
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() ) 
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
                              starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval($schedule.getStateEmptyCE1()) 
    then
        modify( $schedule ) { setControlExam1( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 1: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

rule "Add control exam second in Build"
    salience 14
    when
        $check : Check( )
        eval( $check.getInBuildState() )
        $scheduleCheck : Schedule( )
        $controlExamCondition : Control_Exam( max > 0 )
        $room : Room( build == $controlExamCondition.getBuild() ) 
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( room == $room.getCode() , 
                                subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() ) 
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
                              starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval( !$schedule.getStateEmptyCE1() && $schedule.getStateEmptyCE2() )
    then
        modify( $schedule ) { setControlExam2( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 2: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

rule "Add control exam second nearby Build"
    salience 11
    when
        $check : Check( )
        eval( $check.getNearbyBuildState() )
        $scheduleCheck : Schedule( )
        $near : Nearby(  )
        $room : Room( build == $near.getBuild() ) 
        $controlExamCondition : Control_Exam( build memberOf ( $near.getArrayNearBy() ) , max > 0 )
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( room == $room.getCode() , 
                                subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() ) 
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
                              starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval( !$schedule.getStateEmptyCE1() && $schedule.getStateEmptyCE2() )
    then
        modify( $schedule ) { setControlExam2( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 2: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

rule "Add control exam second out Build"
    salience 0
    when
        $check : Check( )
        eval( $check.getOutBuildState() )
        $scheduleCheck : Schedule( )
        $controlExamCondition : Control_Exam( max > 0 )
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() ) 
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule(  ) from $scheduleCheck ,

                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval( !$schedule.getStateEmptyCE1() && $schedule.getStateEmptyCE2() )
    then
        modify( $schedule ) { setControlExam2( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 2: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

rule "Add control exam third in Build"
    salience 14
    when
        $check : Check( )
        eval( $check.getInBuildState() && $check.getThirdControlState() )
        $scheduleCheck : Schedule( )
        $controlExamCondition : Control_Exam( max > 0 )
        $room : Room( build == $controlExamCondition.getBuild() ) 
        eval($room.getCapacity() > $check.getAmountThirdControl())
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( room == $room.getCode() , 
                                subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() ) 
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
                              starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval( !$schedule.getStateEmptyCE1() && !$schedule.getStateEmptyCE2() && $schedule.getStateEmptyCE3() )
    then
        modify( $schedule ) { setControlExam3( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 3: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

rule "Add control exam third nearby Build"
    salience 11
    when
        $check : Check( )
        eval( $check.getNearbyBuildState() && $check.getThirdControlState() )
        $scheduleCheck : Schedule( )
        $near : Nearby(  )
        $room : Room( build == $near.getBuild() ) 
        eval($room.getCapacity() > $check.getAmountThirdControl())
        $controlExamCondition : Control_Exam( build memberOf ( $near.getArrayNearBy() ) , max > 0 )
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( room == $room.getCode() , 
                                subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() ) 
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
                              starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval( !$schedule.getStateEmptyCE1() && !$schedule.getStateEmptyCE2() && $schedule.getStateEmptyCE3() )
    then
        modify( $schedule ) { setControlExam3( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 3: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

rule "Add control exam third out Build"
    salience 0
    when
        $check : Check( )
        eval( $check.getOutBuildState() && $check.getThirdControlState() )
        $scheduleCheck : Schedule( )
        $controlExamCondition : Control_Exam( max > 0 )
        $room : Room( ) 
        eval($room.getCapacity() > $check.getAmountThirdControl())
        $subject : Subject( educator1 not in( $controlExamCondition.getCode() ),
                            educator2 not in( $controlExamCondition.getCode() ),
                            educator3 not in( $controlExamCondition.getCode() ),
                            educator4 not in( $controlExamCondition.getCode() ),
                            educator5 not in( $controlExamCondition.getCode() ) )
        $schedule : Schedule( room == $room.getCode() ,
                                subject == $subject.getCode() , 
                                date == $scheduleCheck.getDate() &&
                                starttime <= $scheduleCheck.getStarttime() && endtime > $scheduleCheck.getStarttime() ) 
        $controlExamList : Data_List( ) from accumulate( $scheduleCECheck : Schedule( date == $scheduleCheck.getDate() ,
                              starttime == $scheduleCheck.getStarttime() || endtime == $scheduleCheck.getStarttime() ) ,
                              init( Data_List DataList = new Data_List(); ),
                              action( DataList.addData($scheduleCECheck.getControl1()); DataList.addData($scheduleCECheck.getControl2()); DataList.addData($scheduleCECheck.getControl3()); ),
                              result( DataList ) )
        $controlExam : Control_Exam( code not memberOf ( $controlExamList.getArrayCode() ) ) from $controlExamCondition
        eval( !$schedule.getStateEmptyCE1() && !$schedule.getStateEmptyCE2() && $schedule.getStateEmptyCE3() )
    then
        modify( $schedule ) { setControlExam3( $controlExam.getCode() ) };
        modify( $controlExam ) { checkMax( $schedule.getDate() ) };
        $check.setTextState("เพิ่มผู้คุมสอบที่ 3: "+$controlExam.getCode() + " ในห้องสอบ: " + $schedule.getRoom() + " วันที่: " + $schedule.getDate() + " เวลา: " +  $schedule.getRealStartTime() + " - " + $schedule.getRealEndTime());
end

抱歉我的英语不好。

最佳答案

对我来说,这看起来不像是流口水的问题。

由于项目中有大量对象,因此内存不足。如果您有超过 10k 的事实,您会创建超过 10k 的对象,只是因为您的 System.out.println(new Date().toLocaleString()..... 日志。记住 String 不是原始数据类型。

您必须调整代码并增加 JVM 的最大堆大小(默认值约为 64mb)。

关于mysql - 如何在StatefulKnowledgeSession中插入大量事实(Drools),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23722612/

相关文章:

java - 出现错误 org.drools.compiler.kie.builder.impl.AbstractKieModule - 无法构建 KieBaseModel :defaultKieBase

php - 如何知道收件人收到邮件并阅读邮件

mysql - 在 MySQL 查询中使用 'distinct'

PHP 脚本超时

mysql - MySQL 在给定一周内检索值的最有效方法?

java - 我可以使用什么技术/方法在 J2EE 环境中热部署更改?

java - 线程 "main"java.lang.NoClassDefFoundError : org/kie/api/KieServices$Factory with Drools version 7. 59.0 中的依赖关系异常问题

mysql - 当范围 > 30 天时,MYSQL 会过滤结果

java - 有没有办法从类路径外部导入规则文件?

php - 如何将 Drools 与 PHP 应用程序一起使用?