本文整理了Java中org.apache.edgent.graph.Vertex.getConnectors()
方法的一些代码示例,展示了Vertex.getConnectors()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.getConnectors()
方法的具体详情如下:
包路径:org.apache.edgent.graph.Vertex
类名称:Vertex
方法名:getConnectors
[英]Get the vertice's collection of output connectors.
[中]获取vertice的输出连接器集合。
代码示例来源:origin: org.apache.edgent/edgent-spi-graph
@Override
public <N extends Source<P>, P> Connector<P> source(N oplet) {
return insert(oplet, 0, 1).getConnectors().get(0);
}
代码示例来源:origin: apache/incubator-edgent
@Override
public <N extends Source<P>, P> Connector<P> source(N oplet) {
return insert(oplet, 0, 1).getConnectors().get(0);
}
代码示例来源:origin: apache/incubator-edgent
@Override
public <N extends Oplet<C, P>, C, P> Connector<P> pipe(Connector<C> output, N oplet) {
Vertex<N, C, P> pipeVertex = insert(oplet, 1, 1);
output.connect(pipeVertex, 0);
return pipeVertex.getConnectors().get(0);
}
代码示例来源:origin: org.apache.edgent/edgent-spi-graph
@Override
public <N extends Oplet<C, P>, C, P> Connector<P> pipe(Connector<C> output, N oplet) {
Vertex<N, C, P> pipeVertex = insert(oplet, 1, 1);
output.connect(pipeVertex, 0);
return pipeVertex.getConnectors().get(0);
}
代码示例来源:origin: org.apache.edgent/edgent-spi-topology
@Override
public <U> TStream<U> fanin(FanIn<T,U> fanin, List<TStream<T>> others) {
if (others.isEmpty() || others.size() == 1 && others.contains(this))
throw new IllegalArgumentException("others"); // use pipe()
if (new HashSet<>(others).size() != others.size())
throw new IllegalArgumentException("others has dups");
for (TStream<T> other : others)
verify(other);
others = new ArrayList<>(others);
others.add(0, this);
Vertex<Oplet<T,U>, T, U> fanInVertex = graph().insert(fanin, others.size(), 1);
int inputPort = 0;
for (TStream<T> other : others) {
@SuppressWarnings("unchecked")
ConnectorStream<G,T> cs = (ConnectorStream<G, T>) other;
cs.connector.connect(fanInVertex, inputPort++);
}
return derived(fanInVertex.getConnectors().get(0));
}
代码示例来源:origin: apache/incubator-edgent
@Override
public <U> TStream<U> fanin(FanIn<T,U> fanin, List<TStream<T>> others) {
if (others.isEmpty() || others.size() == 1 && others.contains(this))
throw new IllegalArgumentException("others"); // use pipe()
if (new HashSet<>(others).size() != others.size())
throw new IllegalArgumentException("others has dups");
for (TStream<T> other : others)
verify(other);
others = new ArrayList<>(others);
others.add(0, this);
Vertex<Oplet<T,U>, T, U> fanInVertex = graph().insert(fanin, others.size(), 1);
int inputPort = 0;
for (TStream<T> other : others) {
@SuppressWarnings("unchecked")
ConnectorStream<G,T> cs = (ConnectorStream<G, T>) other;
cs.connector.connect(fanInVertex, inputPort++);
}
return derived(fanInVertex.getConnectors().get(0));
}
代码示例来源:origin: org.apache.edgent/edgent-spi-topology
@Override
public List<TStream<T>> split(int n, ToIntFunction<T> splitter) {
if (n <= 0)
throw new IllegalArgumentException("n <= 0");
Split<T> splitOp = new Split<T>(splitter);
Vertex<Split<T>, T, T> splitVertex = graph().insert(splitOp, 1, n);
connector.connect(splitVertex, 0);
List<TStream<T>> outputs = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
outputs.add(derived(splitVertex.getConnectors().get(i)));
}
return outputs;
}
代码示例来源:origin: apache/incubator-edgent
@Override
public List<TStream<T>> split(int n, ToIntFunction<T> splitter) {
if (n <= 0)
throw new IllegalArgumentException("n <= 0");
Split<T> splitOp = new Split<T>(splitter);
Vertex<Split<T>, T, T> splitVertex = graph().insert(splitOp, 1, n);
connector.connect(splitVertex, 0);
List<TStream<T>> outputs = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
outputs.add(derived(splitVertex.getConnectors().get(i)));
}
return outputs;
}
代码示例来源:origin: apache/incubator-edgent
@Override
public TStream<T> union(Set<TStream<T>> others) {
if (others.isEmpty())
return this;
if (others.size() == 1 && others.contains(this))
return this;
for (TStream<T> other : others)
verify(other);
// Create a set we can modify and add this stream
others = new HashSet<>(others);
others.add(this);
Union<T> fanInOp = new Union<T>();
Vertex<Union<T>, T, T> fanInVertex = graph().insert(fanInOp, others.size(), 1);
int inputPort = 0;
for (TStream<T> other : others) {
@SuppressWarnings("unchecked")
ConnectorStream<G,T> cs = (ConnectorStream<G, T>) other;
cs.connector.connect(fanInVertex, inputPort++);
}
return derived(fanInVertex.getConnectors().get(0));
}
代码示例来源:origin: org.apache.edgent/edgent-spi-topology
@Override
public TStream<T> union(Set<TStream<T>> others) {
if (others.isEmpty())
return this;
if (others.size() == 1 && others.contains(this))
return this;
for (TStream<T> other : others)
verify(other);
// Create a set we can modify and add this stream
others = new HashSet<>(others);
others.add(this);
Union<T> fanInOp = new Union<T>();
Vertex<Union<T>, T, T> fanInVertex = graph().insert(fanInOp, others.size(), 1);
int inputPort = 0;
for (TStream<T> other : others) {
@SuppressWarnings("unchecked")
ConnectorStream<G,T> cs = (ConnectorStream<G, T>) other;
cs.connector.connect(fanInVertex, inputPort++);
}
return derived(fanInVertex.getConnectors().get(0));
}
代码示例来源:origin: org.apache.edgent/edgent-spi-graph
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void peekAll(Supplier<? extends Peek<?>> supplier, Predicate<Vertex<?, ?, ?>> select) {
// Select vertices which satisfy the specified predicate
List<Vertex<?, ?, ?>> vertices = new ArrayList<>();
for (Vertex<?, ?, ?> v : getVertices()) {
if (select.test(v)) {
vertices.add(v);
}
}
// Insert peek oplets on isConnected() output ports
for (Vertex<?, ?, ?> v : vertices) {
List<? extends Connector<?>> connectors = v.getConnectors();
for (Connector<?> c : connectors) {
if (c.isConnected()) {
Peek<?> oplet = supplier.get();
c.peek((Peek) oplet);
}
}
}
}
}
代码示例来源:origin: apache/incubator-edgent
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void peekAll(Supplier<? extends Peek<?>> supplier, Predicate<Vertex<?, ?, ?>> select) {
// Select vertices which satisfy the specified predicate
List<Vertex<?, ?, ?>> vertices = new ArrayList<>();
for (Vertex<?, ?, ?> v : getVertices()) {
if (select.test(v)) {
vertices.add(v);
}
}
// Insert peek oplets on isConnected() output ports
for (Vertex<?, ?, ?> v : vertices) {
List<? extends Connector<?>> connectors = v.getConnectors();
for (Connector<?> c : connectors) {
if (c.isConnected()) {
Peek<?> oplet = supplier.get();
c.peek((Peek) oplet);
}
}
}
}
}
代码示例来源:origin: apache/incubator-edgent
@Test
public void testGraphToJson2() {
Graph g = getGraph();
TestOp<String, Integer> op1 = new TestOp<>();
Vertex<TestOp<String, Integer>, String, Integer> v = g.insert(op1, 1, 1);
TestOp<Integer, Integer> op2 = new TestOp<>();
/*Connector<Integer> out2 = */g.pipe(v.getConnectors().get(0), op2);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(new GraphType(g));
GraphType gt2 = new Gson().fromJson(json, GraphType.class);
assertEquals(2, gt2.getVertices().size());
assertEquals(1, gt2.getEdges().size());
}
代码示例来源:origin: apache/incubator-edgent
new SupplierPeriodicSource<>(100, TimeUnit.MILLISECONDS, () -> (r.nextDouble() * 3)),
0, 1);
Connector<Double> out0 = v0.getConnectors().get(0);
out0.tag("dots", "hashes", "ats");
v1.getConnectors().get(0).connect(v2, 0);
v1.getConnectors().get(0).tag("dots");
v1.getConnectors().get(1).connect(v3, 0);
v1.getConnectors().get(1).tag("hashes");
v1.getConnectors().get(2).connect(v4, 0);
v1.getConnectors().get(2).tag("ats");
代码示例来源:origin: apache/incubator-edgent
@Test
public void testGraphToJson4() {
Graph g = getGraph();
/* /-- V2
* V0(Integer)-- V1(Double)-- FanOut
* \-- V3
*/
Vertex<TestOp<String, Integer>, String, Integer> v0 = g.insert(new TestOp<>(), 1, 1);
Connector<Integer> out0 = v0.getConnectors().get(0);
Connector<Double> out1 = g.pipe(out0, new TestOp<Integer, Double>());
Vertex<TestOp<Double, String>, Double, String> v2 = g.insert(new TestOp<Double, String>(), 1, 1);
Vertex<TestOp<Double, String>, Double, String> v3 = g.insert(new TestOp<Double, String>(), 1, 1);
out1.connect(v2, 0);
out1.connect(v3, 0);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(new GraphType(g));
GraphType gt2 = new Gson().fromJson(json, GraphType.class);
assertEquals(5, gt2.getVertices().size());
assertEquals(4, gt2.getEdges().size());
}
代码示例来源:origin: apache/incubator-edgent
v.getConnectors().get(0).connect(v2, 0);
内容来源于网络,如有侵权,请联系作者删除!