繁体   English   中英

如何将RScript Operator与IBM Streams Java Application Api一起使用?

[英]How to use RScript Operator with IBM Streams Java Application Api?

我正在IBM Streams中探索Java Application Api,因此它看起来很有希望。 我能够创建拓扑并在分布式模式下独立运行它们。

现在,我试图查看如何从Java拓扑调用R脚本。 我想的一种方法是在Java拓扑中使用com.ibm.streams.rproject :: RScript运算符。

这是我完整的代码:

SPLStream tuples = testTupleStream(topology);

        //tuples.print();
        topology.createSubmissionParameter("rCommand", "/usr/local/bin/R --vanilla");



        // Filter on the vi attribute, passing the value 321.
        Map<String,Object> params = new HashMap<>();
        params.put("rObjects", "first, second");
        params.put("rScriptFileName", "./etc/print.r");
        params.put("streamAttributes", "number1, number2");

        //params.put("filter", SPL.createValue(" vi == 321 ", MetaType.BOOLEAN));
        SPL.createSubmissionParameter(topology, "rsample", SPL.createValue(true, MetaType.BOOLEAN), true);

        //String toolkitRoot = "/opt/ibm/InfoSphere_Streams/4.0.1.0/toolkits";
        //SPL.addToolkit(tuples, new File(toolkitRoot));
        SPLStream int32Filtered = SPL.invokeOperator("rsampleoperator","com.ibm.streams.rproject::RScript", tuples, tuples.getSchema(), params);
        int32Filtered.print();

但是当我在拓扑之上运行时,出现以下错误:

        09 Nov 2015 04:09:53.234 [5407] ERROR #splapptrc,J[5],P[5],rsampleoperator,spl_pe M[PEImpl.cpp:process:841]  - CDISR5079E: An exception occurred during the processing of the processing element. The error is: An operator was attempting to access the data directory and no data directory has been specified..
09 Nov 2015 04:09:53.241 [5407] ERROR #splapptrc,J[5],P[5],rsampleoperator,spl_operator M[PEImpl.cpp:process:872]  - CDISR5053E: Runtime failures occurred in the following operators: rsampleoperator.

你能告诉我我在做什么错吗? 对在Java API中使用SPL运算符有任何见解会有所帮助吗?

感谢Sudheer

由于这是Java应用程序API,因此我相信您必须将数据目录属性设置为作业属性的一部分:

http://ibmstreams.github.io/streamsx.topology/doc/javadoc/com/ibm/streamsx/topology/context/JobProperties.html

然后,可以在提交作业时将属性传递到上下文:StreamsContext.submit(com.ibm.streamsx.topology.Topology,java.util.Map)

还有一个Java Application API开发指南,您可以在这里找到: http : //ibmstreams.github.io/streamsx.documentation/docs/4.1/java/java-appapi-devguide/

希望这可以帮助。

萨曼莎(Samantha)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM