本文整理汇总了Java中com.pervasive.datarush.graphs.LogicalGraph类的典型用法代码示例。如果您正苦于以下问题:Java LogicalGraph类的具体用法?Java LogicalGraph怎么用?Java LogicalGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LogicalGraph类属于com.pervasive.datarush.graphs包,在下文中一共展示了LogicalGraph类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testinvalidXPath
import com.pervasive.datarush.graphs.LogicalGraph; //导入依赖的package包/类
@Test
public void testinvalidXPath() {
String invalidXML;
invalidXML = "<root><fruits><fruit name='apple' color='green'></fruits></root>";
RecordTokenType dataType = record(STRING("xmlDoc"));
RecordTokenList data = new RecordTokenList(dataType, 2);
data.append(new RecordToken(dataType, StringToken.parse(invalidXML)));
LogicalGraph g = LogicalGraphFactory.newLogicalGraph("xpath_test");
EmitRecords er = g.add(new EmitRecords());
er.setInput(data);
DeriveFields df = g.add(new DeriveFields());
df.setDropUnderivedFields(true);
df.setDerivedFields("xpath(\"//fruits/ignore/.\",xmlDoc) as result");
AssertPredicate ap = g.add(new AssertPredicate());
ap.setPredicate("result == \"The end-tag for element type \\\"fruit\\\" must end with a '>' delimiter.\"");
LogRows lr = g.add(new LogRows(1));
g.connect(er.getOutput(), df.getInput());
g.connect(df.getOutput(), lr.getInput());
g.connect(df.getOutput(), ap.getInput());
g.run();
}
示例2: main
import com.pervasive.datarush.graphs.LogicalGraph; //导入依赖的package包/类
public static void main(String[] args) {
LogicalGraph graph = LogicalGraphFactory.newLogicalGraph();
ReadDelimitedText reader = graph.add(new ReadDelimitedText("https://raw.githubusercontent.com/ActianCorp/df-jsonpath/master/examples/KNIME/twitterdemo.txt"));
reader.setHeader(false);
reader.setFieldDelimiter("\uffff");
reader.setRecordSeparator("\r\n");
reader.setFieldSeparator("\u0000");
String[] sflds = {"field0"};
String[] tflds = {"id", "hashtags"};
String[] expr = { "$.id", "$.entities.hashtags..text"};
String[] flatmap = { "false", "true"};
RunJSONPath runner = graph.add(new RunJSONPath());
runner.setExpressions(expr);
runner.setFlatMap(flatmap);
runner.setSourceFields(sflds);
runner.setTargetFields(tflds);
WriteDelimitedText writer = graph.add(new WriteDelimitedText());
writer.setFieldEndDelimiter("]]");
writer.setFieldStartDelimiter("[[");
writer.setFieldDelimiter(",");
writer.setHeader(false);
writer.setTarget("stdout:");
writer.setMode(OVERWRITE);
graph.connect(reader.getOutput(), runner.getInput());
graph.connect(runner.getOutput(), writer.getInput());
graph.compile().run();
}
示例3: testSimpleRead
import com.pervasive.datarush.graphs.LogicalGraph; //导入依赖的package包/类
@Test
public void testSimpleRead() {
String validXML;
validXML = "<?xml version='1.0'?>"
+ "<root><fruits>"
+ "<fruit name='apple' color='green' v='true'/>"
+ "<ignore>Me</ignore>"
+ "<fruit><since/></fruit>"
+ "<fruit name='cherry' color='red'/>"
+ "<fruit name='banana' color='yellow'>Eeek!</fruit>"
+ "</fruits>"
+ "</root>";
RecordTokenType dataType = record(STRING("xmlDoc"));
RecordTokenList data = new RecordTokenList(dataType, 2);
data.append(new RecordToken(dataType, StringToken.parse(validXML)));
LogicalGraph g = LogicalGraphFactory.newLogicalGraph("xpath_test");
EmitRecords er = g.add(new EmitRecords());
er.setInput(data);
XPathTable table = g.add(new XPathTable());
table.setInputField("xmlDoc");
table.setExpression("//fruits/fruit");
table.setSchema(SchemaBuilder.define(
SchemaBuilder.STRING("name"), SchemaBuilder.STRING("color")
));
LogRows lr = g.add(new LogRows(1));
g.connect(er.getOutput(), table.getInput());
g.connect(table.getOutput(), lr.getInput());
g.run();
}
示例4: testvalidXPathScalar
import com.pervasive.datarush.graphs.LogicalGraph; //导入依赖的package包/类
@Test
public void testvalidXPathScalar() {
String validXML;
validXML = "<?xml version='1.0'?>"
+ "<root><fruits>"
+ "<fruit name='apple' color='green'/>"
+ "<ignore>Me</ignore>"
+ "<fruit name='cherry' color='red'/>"
+ "</fruits>"
+ "</root>";
RecordTokenType dataType = record(STRING("xmlDoc"));
RecordTokenList data = new RecordTokenList(dataType, 2);
data.append(new RecordToken(dataType, StringToken.parse(validXML)));
LogicalGraph g = LogicalGraphFactory.newLogicalGraph("xpath_test");
EmitRecords er = g.add(new EmitRecords());
er.setInput(data);
DeriveFields df = g.add(new DeriveFields());
df.setDropUnderivedFields(true);
df.setDerivedFields("xpath(\"//fruits/ignore/text()\",xmlDoc) as result," +
"xpath(\"//fruits/fruit[1]/@color\",xmlDoc) as attr," +
"xpath(\"name(//fruits/fruit[1])\",xmlDoc) as name");
AssertPredicate ap = g.add(new AssertPredicate());
ap.setPredicate("result = \"Me\" and attr = \"green\" and name = \"fruit\"");
LogRows lr = g.add(new LogRows(1));
g.connect(er.getOutput(), df.getInput());
g.connect(df.getOutput(), lr.getInput());
g.connect(df.getOutput(), ap.getInput());
g.run();
}
示例5: testvalidXPathNodes
import com.pervasive.datarush.graphs.LogicalGraph; //导入依赖的package包/类
@Test
public void testvalidXPathNodes() {
String validXML;
validXML = "<?xml version='1.0'?>"
+ "<root><fruits>"
+ "<fruit name='apple' color='green' v='true'/>"
+ "<ignore>Me</ignore>"
+ "<fruit name='cherry' color='red'/>"
+ "</fruits>"
+ "</root>";
RecordTokenType dataType = record(STRING("xmlDoc"));
RecordTokenList data = new RecordTokenList(dataType, 2);
data.append(new RecordToken(dataType, StringToken.parse(validXML)));
LogicalGraph g = LogicalGraphFactory.newLogicalGraph("xpath_test");
EmitRecords er = g.add(new EmitRecords());
er.setInput(data);
DeriveFields df = g.add(new DeriveFields());
df.setDropUnderivedFields(true);
df.setDerivedFields("xpath(\"//fruits/fruit\",xmlDoc) as result");
AssertPredicate ap = g.add(new AssertPredicate());
ap.setPredicate("result is not null");
LogRows lr = g.add(new LogRows(1));
g.connect(er.getOutput(), df.getInput());
g.connect(df.getOutput(), lr.getInput());
g.connect(df.getOutput(), ap.getInput());
g.run();
}
示例6: testvalidNull
import com.pervasive.datarush.graphs.LogicalGraph; //导入依赖的package包/类
@Test
public void testvalidNull() {
String validXML;
validXML = "<?xml version='1.0'?>"
+ "<root><fruits>"
+ "<fruit name='apple' color='green' v='true'/>"
+ "<ignore>Me</ignore>"
+ "<fruit name='cherry' color='red'/>"
+ "</fruits>"
+ "</root>";
RecordTokenType dataType = record(STRING("xmlDoc"));
RecordTokenList data = new RecordTokenList(dataType, 2);
data.append(new RecordToken(dataType, StringToken.parse(validXML)));
LogicalGraph g = LogicalGraphFactory.newLogicalGraph("xpath_test");
EmitRecords er = g.add(new EmitRecords());
er.setInput(data);
DeriveFields df = g.add(new DeriveFields());
df.setDropUnderivedFields(true);
df.setDerivedFields("xpath(\"//fruits/fruit[2]/@v\",xmlDoc) as result");
AssertPredicate ap = g.add(new AssertPredicate());
ap.setPredicate("result is null");
LogRows lr = g.add(new LogRows(1));
g.connect(er.getOutput(), df.getInput());
g.connect(df.getOutput(), lr.getInput());
g.connect(df.getOutput(), ap.getInput());
g.run();
}