Package org.apache.storm.bolt
Class JoinBolt
java.lang.Object
org.apache.storm.topology.base.BaseWindowedBolt
org.apache.storm.bolt.JoinBolt
- All Implemented Interfaces:
- Serializable,- IComponent,- IWindowedBolt
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classprotected classprotected static classDescribes how to join the other stream with the current stream.protected static enumprotected classstatic enumNested classes/interfaces inherited from class org.apache.storm.topology.base.BaseWindowedBoltBaseWindowedBolt.Count, BaseWindowedBolt.Duration
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected LinkedHashMap<String,JoinBolt.JoinInfo> protected JoinBolt.FieldSelector[]protected Stringprotected final JoinBolt.SelectorFields inherited from class org.apache.storm.topology.base.BaseWindowedBolttimestampExtractor, windowConfiguration
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoiddeclareOutputFields(OutputFieldsDeclarer declarer) Declare the output schema for all the streams of this topology.protected JoinBolt.JoinAccumulatordoInnerJoin(JoinBolt.JoinAccumulator probe, Map<Object, ArrayList<Tuple>> buildInput, JoinBolt.JoinInfo joinInfo, boolean finalJoin) protected JoinBolt.JoinAccumulatordoJoin(JoinBolt.JoinAccumulator probe, HashMap<Object, ArrayList<Tuple>> buildInput, JoinBolt.JoinInfo joinInfo, boolean finalJoin) protected JoinBolt.JoinAccumulatordoLeftJoin(JoinBolt.JoinAccumulator probe, Map<Object, ArrayList<Tuple>> buildInput, JoinBolt.JoinInfo joinInfo, boolean finalJoin) doProjection(ArrayList<Tuple> tuples, JoinBolt.FieldSelector[] projectionFields) voidexecute(TupleWindow inputWindow) Process the tuple window and optionally emit new tuples based on the tuples in the input window.protected JoinBolt.JoinAccumulatorPerforms inner Join with the newStream.Performs left Join with the newStream.protected ObjectlookupField(JoinBolt.FieldSelector fieldSelector, Tuple tuple) voidprepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) This is similar to theIBolt.prepare(Map, TopologyContext, OutputCollector)except that while emitting, the tuples are automatically anchored to the tuples in the inputWindow.Specify projection fields.withLag(BaseWindowedBolt.Duration duration) Specify the maximum time lag of the tuple timestamp in milliseconds.withLateTupleStream(String streamId) Specify a stream id on which late tuples are going to be emitted.withOutputStream(String streamName) Optional.withTimestampExtractor(TimestampExtractor timestampExtractor) Specify the timestamp extractor implementation.withTimestampField(String fieldName) Specify a field in the tuple that represents the timestamp as a long value.A count based tumbling window.withTumblingWindow(BaseWindowedBolt.Duration duration) A time duration based tumbling window.Specify the watermark event generation interval.withWindow(BaseWindowedBolt.Count windowLength) A tuple count based window that slides with every incoming tuple.withWindow(BaseWindowedBolt.Count windowLength, BaseWindowedBolt.Count slidingInterval) Tuple count based sliding window configuration.withWindow(BaseWindowedBolt.Count windowLength, BaseWindowedBolt.Duration slidingInterval) Tuple count and time duration based sliding window configuration.withWindow(BaseWindowedBolt.Duration windowLength) A time duration based window that slides with every incoming tuple.withWindow(BaseWindowedBolt.Duration windowLength, BaseWindowedBolt.Count slidingInterval) Time duration and count based sliding window configuration.withWindow(BaseWindowedBolt.Duration windowLength, BaseWindowedBolt.Duration slidingInterval) Time duration based sliding window configuration.Methods inherited from class org.apache.storm.topology.base.BaseWindowedBoltcleanup, getComponentConfiguration, getTimestampExtractor
- 
Field Details- 
selectorType
- 
joinCriteria
- 
outputFields
- 
outputStreamName
 
- 
- 
Constructor Details- 
JoinBoltCalls JoinBolt(Selector.SOURCE, sourceId, fieldName)- Parameters:
- sourceId- Id of source component (spout/bolt) from which this bolt is receiving data
- fieldName- the field to use for joining the stream (x.y.z format)
 
- 
JoinBoltIntroduces the first stream to start the join with. Equivalent SQL ... select .... from srcOrStreamId ...- Parameters:
- type- Specifies whether 'srcOrStreamId' refers to stream name/source component
- srcOrStreamId- name of stream OR source component
- fieldName- the field to use for joining the stream (x.y.z format)
 
 
- 
- 
Method Details- 
withOutputStreamOptional. Allows naming the output stream of this bolt. If not specified, the emits will happen on 'default' stream.
- 
joinPerforms inner Join with the newStream. SQL:from priorStream inner join newStream on newStream.field = priorStream.field1same as:new WindowedQueryBolt(priorStream,field1). join(newStream, field, priorStream);Note: priorStream must be previously joined. Valid ex:new WindowedQueryBolt(s1,k1). join(s2,k2, s1). join(s3,k3, s2);Invalid ex:new WindowedQueryBolt(s1,k1). join(s3,k3, s2). join(s2,k2, s1);- Parameters:
- newStream- Either stream name or name of upstream component
- field- the field on which to perform the join
 
- 
leftJoinPerforms left Join with the newStream. SQL : from stream1 left join stream2 on stream2.field = stream1.field1 same as: new WindowedQueryBolt(stream1, field1). leftJoin(stream2, field, stream1);Note: priorStream must be previously joined Valid ex: new WindowedQueryBolt(s1,k1). leftJoin(s2,k2, s1). leftJoin(s3,k3, s2); Invalid ex: new WindowedQueryBolt(s1,k1). leftJoin(s3,k3, s2). leftJoin(s2,k2, s1); - Parameters:
- newStream- Either a name of a stream or an upstream component
- field- the field on which to perform the join
 
- 
selectSpecify projection fields. i.e. Specifies the fields to include in the output. e.g: .select("field1, stream2:field2, field3") Nested Key names are supported for nested types: e.g: .select("outerKey1.innerKey1, outerKey1.innerKey2, stream3:outerKey2.innerKey3)" Inner types (non leaf) must be Map<> in order to support nested lookup using this dot notation This selected fields implicitly declare the output fieldNames for the bolt based.
- 
declareOutputFieldsDescription copied from interface:IComponentDeclare the output schema for all the streams of this topology.- Specified by:
- declareOutputFieldsin interface- IComponent
- Overrides:
- declareOutputFieldsin class- BaseWindowedBolt
- Parameters:
- declarer- this is used to declare output stream ids, output fields, and whether or not each output stream is a direct stream
 
- 
preparepublic void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) Description copied from interface:IWindowedBoltThis is similar to theIBolt.prepare(Map, TopologyContext, OutputCollector)except that while emitting, the tuples are automatically anchored to the tuples in the inputWindow.- Specified by:
- preparein interface- IWindowedBolt
- Overrides:
- preparein class- BaseWindowedBolt
 
- 
executeDescription copied from interface:IWindowedBoltProcess the tuple window and optionally emit new tuples based on the tuples in the input window.
- 
hashJoin
- 
doJoinprotected JoinBolt.JoinAccumulator doJoin(JoinBolt.JoinAccumulator probe, HashMap<Object, ArrayList<Tuple>> buildInput, JoinBolt.JoinInfo joinInfo, boolean finalJoin) 
- 
doInnerJoinprotected JoinBolt.JoinAccumulator doInnerJoin(JoinBolt.JoinAccumulator probe, Map<Object, ArrayList<Tuple>> buildInput, JoinBolt.JoinInfo joinInfo, boolean finalJoin) 
- 
doLeftJoinprotected JoinBolt.JoinAccumulator doLeftJoin(JoinBolt.JoinAccumulator probe, Map<Object, ArrayList<Tuple>> buildInput, JoinBolt.JoinInfo joinInfo, boolean finalJoin) 
- 
doProjectionprotected ArrayList<Object> doProjection(ArrayList<Tuple> tuples, JoinBolt.FieldSelector[] projectionFields) 
- 
lookupField
- 
withWindowpublic JoinBolt withWindow(BaseWindowedBolt.Count windowLength, BaseWindowedBolt.Count slidingInterval) Description copied from class:BaseWindowedBoltTuple count based sliding window configuration.- Overrides:
- withWindowin class- BaseWindowedBolt
- Parameters:
- windowLength- the number of tuples in the window
- slidingInterval- the number of tuples after which the window slides
 
- 
withWindowpublic JoinBolt withWindow(BaseWindowedBolt.Count windowLength, BaseWindowedBolt.Duration slidingInterval) Description copied from class:BaseWindowedBoltTuple count and time duration based sliding window configuration.- Overrides:
- withWindowin class- BaseWindowedBolt
- Parameters:
- windowLength- the number of tuples in the window
- slidingInterval- the time duration after which the window slides
 
- 
withWindowpublic JoinBolt withWindow(BaseWindowedBolt.Duration windowLength, BaseWindowedBolt.Count slidingInterval) Description copied from class:BaseWindowedBoltTime duration and count based sliding window configuration.- Overrides:
- withWindowin class- BaseWindowedBolt
- Parameters:
- windowLength- the time duration of the window
- slidingInterval- the number of tuples after which the window slides
 
- 
withWindowpublic JoinBolt withWindow(BaseWindowedBolt.Duration windowLength, BaseWindowedBolt.Duration slidingInterval) Description copied from class:BaseWindowedBoltTime duration based sliding window configuration.- Overrides:
- withWindowin class- BaseWindowedBolt
- Parameters:
- windowLength- the time duration of the window
- slidingInterval- the time duration after which the window slides
 
- 
withWindowDescription copied from class:BaseWindowedBoltA tuple count based window that slides with every incoming tuple.- Overrides:
- withWindowin class- BaseWindowedBolt
- Parameters:
- windowLength- the number of tuples in the window
 
- 
withWindowDescription copied from class:BaseWindowedBoltA time duration based window that slides with every incoming tuple.- Overrides:
- withWindowin class- BaseWindowedBolt
- Parameters:
- windowLength- the time duration of the window
 
- 
withTumblingWindowDescription copied from class:BaseWindowedBoltA count based tumbling window.- Overrides:
- withTumblingWindowin class- BaseWindowedBolt
- Parameters:
- count- the number of tuples after which the window tumbles
 
- 
withTumblingWindowDescription copied from class:BaseWindowedBoltA time duration based tumbling window.- Overrides:
- withTumblingWindowin class- BaseWindowedBolt
- Parameters:
- duration- the time duration after which the window tumbles
 
- 
withTimestampFieldDescription copied from class:BaseWindowedBoltSpecify a field in the tuple that represents the timestamp as a long value. If this field is not present in the incoming tuple, anIllegalArgumentExceptionwill be thrown. The field MUST contain a timestamp in milliseconds- Overrides:
- withTimestampFieldin class- BaseWindowedBolt
- Parameters:
- fieldName- the name of the field that contains the timestamp
 
- 
withTimestampExtractorDescription copied from class:BaseWindowedBoltSpecify the timestamp extractor implementation.- Overrides:
- withTimestampExtractorin class- BaseWindowedBolt
- Parameters:
- timestampExtractor- the- TimestampExtractorimplementation
 
- 
withLateTupleStreamDescription copied from class:BaseWindowedBoltSpecify a stream id on which late tuples are going to be emitted. They are going to be accessible via theWindowedBoltExecutor.LATE_TUPLE_FIELDfield. It must be defined on a per-component basis, and in conjunction with theBaseWindowedBolt.withTimestampField(java.lang.String), otherwiseIllegalArgumentExceptionwill be thrown.- Overrides:
- withLateTupleStreamin class- BaseWindowedBolt
- Parameters:
- streamId- the name of the stream used to emit late tuples on
 
- 
withLagDescription copied from class:BaseWindowedBoltSpecify the maximum time lag of the tuple timestamp in milliseconds. It means that the tuple timestamps cannot be out of order by more than this amount.- Overrides:
- withLagin class- BaseWindowedBolt
- Parameters:
- duration- the max lag duration
 
- 
withWatermarkIntervalDescription copied from class:BaseWindowedBoltSpecify the watermark event generation interval. For tuple based timestamps, watermark events are used to track the progress of time- Overrides:
- withWatermarkIntervalin class- BaseWindowedBolt
- Parameters:
- interval- the interval at which watermark events are generated
 
 
-