RuleEngine2

public void executeRules(UserData[] uds)
    {
        List<FactHandle> lf = new ArrayList<FactHandle>();
        for (UserData data : uds)
        {
            lf.add(ksession.insert(data));
        }
        ksession.fireAllRules();
        for (FactHandle handle : lf)
        {
            ksession.retract(handle);
        }
    }
   
    //测试
    public static void main(String[] agrs) throws Exception
    {
        String path1 = "D:/wKF19407/MyPrj/ups/hadoop/HadoopTask/src/101.drl";   //tagrule_101.drl
        //String path2 = "D:/3/character_3.drl";
        RulesEngine2 t1 = new RulesEngine2(new String[]{path1});
        //RulesEngine2 t2 = new RulesEngine2(path1);
        UserData us = new UserData();
        us.getCharacters().put("10001002", 1);
        us.getCharacters().put("10001001", 0);
        us.setUserId("15850632186");
        t1.executeRules(new UserData[]{us});
        //t1.executeRule(us);
        //t2.executeRules(new UserData[]{us});
        System.out.println(us.getTagRules().get("101"));
    }

你可能感兴趣的:(hadoop)