K
- the key type for edge and vertex identifiers.EV
- the value type for edges.public class EdgeStream<K,EV> extends Object implements KGraphStream<K,Void,EV>
GLOBAL_KEY
Constructor and Description |
---|
EdgeStream(org.apache.kafka.streams.kstream.KStream<Edge<K>,EV> edges,
GraphSerialized<K,Void,EV> serialized)
Creates a graph from an edge stream.
|
Modifier and Type | Method and Description |
---|---|
<VV> org.apache.kafka.streams.kstream.KStream<K,VV> |
aggregate(org.apache.kafka.streams.kstream.KeyValueMapper<Edge<K>,EV,Iterable<org.apache.kafka.streams.KeyValue<K,VV>>> edgeMapper,
org.apache.kafka.streams.kstream.KeyValueMapper<K,VV,org.apache.kafka.streams.KeyValue<K,VV>> vertexMapper)
The aggregate function splits the edge stream up into a vertex stream and applies
a mapper on the resulting vertices
|
<S,T> org.apache.kafka.streams.kstream.KTable<org.apache.kafka.streams.kstream.Windowed<Short>,T> |
aggregate(SummaryAggregation<K,EV,S,T> summaryAggregation)
Applies an incremental aggregation on a graphstream and returns a stream of aggregation results
|
org.apache.kafka.streams.kstream.KStream<Edge<K>,Set<K>> |
buildNeighborhood(boolean directed)
Builds the neighborhood state by creating adjacency lists.
|
org.apache.kafka.streams.kstream.KStream<K,Long> |
degrees()
Get the degree stream
|
EdgeStream<K,EV> |
distinct()
Removes the duplicate edges by storing a neighborhood set for each vertex
|
org.apache.kafka.streams.kstream.KStream<Edge<K>,EV> |
edges() |
EdgeStream<K,EV> |
filterEdges(org.apache.kafka.streams.kstream.Predicate<Edge<K>,EV> filter)
Apply a filter to each edge in the graph stream
|
EdgeStream<K,EV> |
filterVertices(org.apache.kafka.streams.kstream.Predicate<K,Void> filter)
Apply a filter to each vertex in the graph stream
Since this is an edge-only stream, the vertex filter can only access the key of vertices
|
<VV> org.apache.kafka.streams.kstream.KStream<Short,VV> |
globalAggregate(org.apache.kafka.streams.kstream.KeyValueMapper<Edge<K>,EV,Iterable<org.apache.kafka.streams.KeyValue<K,VV>>> edgeMapper,
org.apache.kafka.streams.kstream.KeyValueMapper<K,VV,Iterable<org.apache.kafka.streams.KeyValue<Short,VV>>> vertexMapper,
boolean collectUpdates)
Returns a global aggregate on the previously split vertex stream
|
org.apache.kafka.streams.kstream.KStream<K,Long> |
inDegrees()
Get the in-degree stream
|
<NV> EdgeStream<K,NV> |
mapEdges(org.apache.kafka.streams.kstream.KeyValueMapper<Edge<K>,EV,org.apache.kafka.streams.KeyValue<Edge<K>,NV>> mapper,
org.apache.kafka.common.serialization.Serde<NV> newValueSerde)
Apply a function to the attribute of each edge in the graph stream.
|
org.apache.kafka.streams.kstream.KStream<Short,Long> |
numberOfEdges() |
org.apache.kafka.streams.kstream.KStream<Short,Long> |
numberOfVertices() |
org.apache.kafka.streams.kstream.KStream<K,Long> |
outDegrees()
Get the out-degree stream
|
EdgeStream<K,EV> |
reverse() |
KGraphWindowedStream<K,EV> |
slice(org.apache.kafka.streams.kstream.Windows<? extends org.apache.kafka.streams.kstream.Window> size)
Discretizes the edge stream into tumbling windows of the specified size.
|
KGraphWindowedStream<K,EV> |
slice(org.apache.kafka.streams.kstream.Windows<? extends org.apache.kafka.streams.kstream.Window> size,
EdgeDirection direction)
Discretizes the edge stream into tumbling windows of the specified size.
|
EdgeStream<K,EV> |
undirected() |
EdgeStream<K,EV> |
union(KGraphStream<K,Void,EV> graph) |
org.apache.kafka.streams.kstream.KStream<K,Void> |
vertices() |
public org.apache.kafka.streams.kstream.KStream<Edge<K>,EV> edges()
edges
in interface KGraphStream<K,Void,EV>
public org.apache.kafka.streams.kstream.KStream<K,Void> vertices()
vertices
in interface KGraphStream<K,Void,EV>
public <NV> EdgeStream<K,NV> mapEdges(org.apache.kafka.streams.kstream.KeyValueMapper<Edge<K>,EV,org.apache.kafka.streams.KeyValue<Edge<K>,NV>> mapper, org.apache.kafka.common.serialization.Serde<NV> newValueSerde)
mapEdges
in interface KGraphStream<K,Void,EV>
NV
- the new vertex value typemapper
- the map function to apply.newValueSerde
- the new value serdepublic EdgeStream<K,EV> filterEdges(org.apache.kafka.streams.kstream.Predicate<Edge<K>,EV> filter)
filterEdges
in interface KGraphStream<K,Void,EV>
filter
- the filter function to apply.public EdgeStream<K,EV> filterVertices(org.apache.kafka.streams.kstream.Predicate<K,Void> filter)
filterVertices
in interface KGraphStream<K,Void,EV>
filter
- the filter function to apply.public org.apache.kafka.streams.kstream.KStream<Short,Long> numberOfEdges()
numberOfEdges
in interface KGraphStream<K,Void,EV>
public org.apache.kafka.streams.kstream.KStream<Short,Long> numberOfVertices()
numberOfVertices
in interface KGraphStream<K,Void,EV>
public EdgeStream<K,EV> distinct()
distinct
in interface KGraphStream<K,Void,EV>
public EdgeStream<K,EV> undirected()
undirected
in interface KGraphStream<K,Void,EV>
public EdgeStream<K,EV> reverse()
reverse
in interface KGraphStream<K,Void,EV>
public org.apache.kafka.streams.kstream.KStream<K,Long> degrees()
degrees
in interface KGraphStream<K,Void,EV>
public org.apache.kafka.streams.kstream.KStream<K,Long> inDegrees()
inDegrees
in interface KGraphStream<K,Void,EV>
public org.apache.kafka.streams.kstream.KStream<K,Long> outDegrees()
outDegrees
in interface KGraphStream<K,Void,EV>
public EdgeStream<K,EV> union(KGraphStream<K,Void,EV> graph)
union
in interface KGraphStream<K,Void,EV>
graph
- the streamed graph to union withpublic <VV> org.apache.kafka.streams.kstream.KStream<K,VV> aggregate(org.apache.kafka.streams.kstream.KeyValueMapper<Edge<K>,EV,Iterable<org.apache.kafka.streams.KeyValue<K,VV>>> edgeMapper, org.apache.kafka.streams.kstream.KeyValueMapper<K,VV,org.apache.kafka.streams.KeyValue<K,VV>> vertexMapper)
aggregate
in interface KGraphStream<K,Void,EV>
VV
- the vertex value usededgeMapper
- the mapper that converts the edge stream to a vertex streamvertexMapper
- the mapper that aggregates vertex valuespublic <VV> org.apache.kafka.streams.kstream.KStream<Short,VV> globalAggregate(org.apache.kafka.streams.kstream.KeyValueMapper<Edge<K>,EV,Iterable<org.apache.kafka.streams.KeyValue<K,VV>>> edgeMapper, org.apache.kafka.streams.kstream.KeyValueMapper<K,VV,Iterable<org.apache.kafka.streams.KeyValue<Short,VV>>> vertexMapper, boolean collectUpdates)
globalAggregate
in interface KGraphStream<K,Void,EV>
VV
- the return value typeedgeMapper
- the mapper that converts the edge stream to a vertex streamvertexMapper
- the mapper that aggregates vertex valuescollectUpdates
- boolean specifying whether the aggregate should only be collected when there is an updatepublic org.apache.kafka.streams.kstream.KStream<Edge<K>,Set<K>> buildNeighborhood(boolean directed)
buildNeighborhood
in interface KGraphStream<K,Void,EV>
directed
- if true, only the out-neighbors will be stored
otherwise both directions are consideredpublic KGraphWindowedStream<K,EV> slice(org.apache.kafka.streams.kstream.Windows<? extends org.apache.kafka.streams.kstream.Window> size)
The edge stream is partitioned so that all neighbors of a vertex belong to the same partition. The KeyedStream is then windowed into tumbling time windows.
By default, each vertex is grouped with its outgoing edges.
Use slice(Windows, EdgeDirection)
to manually set the edge direction grouping.
slice
in interface KGraphStream<K,Void,EV>
size
- the size of the windowpublic KGraphWindowedStream<K,EV> slice(org.apache.kafka.streams.kstream.Windows<? extends org.apache.kafka.streams.kstream.Window> size, EdgeDirection direction) throws IllegalArgumentException
The edge stream is partitioned so that all neighbors of a vertex belong to the same partition. The KeyedStream is then windowed into tumbling time windows.
slice
in interface KGraphStream<K,Void,EV>
size
- the size of the windowdirection
- the EdgeDirection to key byIllegalArgumentException
public <S,T> org.apache.kafka.streams.kstream.KTable<org.apache.kafka.streams.kstream.Windowed<Short>,T> aggregate(SummaryAggregation<K,EV,S,T> summaryAggregation)
aggregate
in interface KGraphStream<K,Void,EV>
S
- initial typeT
- result typesummaryAggregation
- the summary aggregationCopyright © 2020. All rights reserved.