如何为巨大的数据Excel表写下Drool规则?

时间:2018-04-05 12:13:54

标签: java

尝试加载大量数据(大约1,00,000条记录)时会抛出“超出GC开销限制”错误。使用的代码段如下:

public static void GridUploadPVT() throws Exception {
    try {
        KnowledgeBase knowledgeBaseTest = genKnowledgeBaseXlsx("GridUploadPVT.xlsx");
        StatelessKnowledgeSession session = knowledgeBaseTest.newStatelessKnowledgeSession();

        GridUploadPVT griduploadpvt = new GridUploadPVT(prodName, xAxis, yAxis, tranType, vehAge, "YES");
        session.execute(griduploadpvt);

    } catch (Exception ex) {
        System.out.println("Exception:" + ex.toString());
        throw new RuntimeException(excommonItem);
    }
}

private static KnowledgeBase genKnowledgeBaseXlsx(String xlsx) throws Exception {
    DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
    dtconf.setInputType(DecisionTableInputType.XLSX);

    KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    knowledgeBuilder.add(ResourceFactory.newClassPathResource(xlsx),
            ResourceType.DTABLE, dtconf);

    if (knowledgeBuilder.hasErrors()) {
        throw new RuntimeException(knowledgeBuilder.getErrors().toString());
    }

    KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
    knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
    return knowledgeBase;
}

0 个答案:

没有答案