HashPartitioner.class.getName()).build();
/**
* Connect the join vertex with the stream side
*/
Edge e1 = Edge.create(streamFileVertex, joinVertex, streamConf.createDefaultEdgeProperty());
EdgeProperty hashSideEdgeProperty = null;
if (doBroadcast) {
/**
* This option can be used when the hash side is small. We can broadcast the entire data to
* all fragments of the stream side. This avoids re-partitioning the fragments of the stream
* side to match the partitioning scheme of the hash side and avoids costly network data
* transfer. However, in this example the stream side is being partitioned in both cases for
* brevity of code. The join task can perform the join of its fragment of keys with all the
* keys of the hash side.
* Using an unpartitioned edge to transfer the complete output of the hash side to be
* broadcasted to all fragments of the streamed side. Again, since the data is the key, the
* value is null.
*/
UnorderedKVEdgeConfig broadcastConf = UnorderedKVEdgeConfig.newBuilder(Text.class.getName(),
NullWritable.class.getName()).build();
hashSideEdgeProperty = broadcastConf.createDefaultBroadcastEdgeProperty();
} else {
/**
* The hash side is also being partitioned into fragments with the same key going to the same
* fragment using hash partitioning. This way all keys with the same hash value will go to the
* same fragment from both sides. Thus the join task handling that fragment can join both data
* set fragments.
*/
hashSideEdgeProperty = streamConf.createDefaultEdgeProperty();
}
/**
* Connect the join vertex to the hash side.
* The join vertex is connected with 2 upstream vertices that provide it with inputs
*/
Edge e2 = Edge.create(hashFileVertex, joinVertex, hashSideEdgeProperty);
/**
* Connect everything up by adding them to the DAG
*/
dag.addVertex(streamFileVertex).addVertex(hashFileVertex).addVertex(joinVertex)