Github user roshannaik commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1914#discussion_r99227816
  
    --- Diff: storm-core/src/jvm/org/apache/storm/bolt/JoinBolt.java ---
    @@ -0,0 +1,428 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.storm.bolt;
    +
    +
    +import org.apache.storm.task.OutputCollector;
    +import org.apache.storm.task.TopologyContext;
    +import org.apache.storm.topology.OutputFieldsDeclarer;
    +import org.apache.storm.topology.base.BaseWindowedBolt;
    +import org.apache.storm.tuple.Fields;
    +import org.apache.storm.tuple.Tuple;
    +import org.apache.storm.windowing.TupleWindow;
    +
    +import java.io.Serializable;
    +import java.util.ArrayList;
    +import java.util.Collection;
    +import java.util.HashMap;
    +import java.util.LinkedHashMap;
    +import java.util.List;
    +import java.util.Map;
    +
    +
    +public class JoinBolt extends BaseWindowedBolt {
    +
    +    private OutputCollector collector;
    +
    +    // Map[StreamName -> Map[Key -> List<Tuple>]  ]
    +    HashMap<String, HashMap<Object, ArrayList<Tuple> >> hashedInputs = new 
HashMap<>(); // holds remaining streams
    +
    +    // Map[StreamName -> JoinInfo]
    +    protected LinkedHashMap<String, JoinInfo> joinCriteria = new 
LinkedHashMap<>();
    +    protected String[][] outputKeys;  // specified via bolt.select() ... 
used in declaring Output fields
    +    protected String[] dotSeparatedOutputKeyNames; // flattened (de 
nested) keyNames, used for naming output fields
    +    protected String outputStreamName;
    +
    +    // Use streamId, source component name OR field in tuple to 
distinguish incoming tuple streams
    +    public enum Selector { STREAM, SOURCE }
    +    protected final Selector selectorType;
    +
    +
    +    /**
    +     * StreamId to start the join with. Equivalent SQL ...
    +     *       select .... from streamId ...
    +     * @param type Specifies whether 'streamId' refers to stream 
name/source component
    +     * @param streamId name of stream/source component
    +     * @param key the fieldName to use as key for the stream (used for 
performing joins)
    +     */
    +    public JoinBolt(Selector type, String streamId, String key) {
    +        selectorType = type;
    +        joinCriteria.put(streamId, new JoinInfo(key) );
    +    }
    +
    +    /**
    +     * Defines the name of the output stream
    +     */
    +    public JoinBolt withOutputStream(String streamName) {
    +        this.outputStreamName = streamName;
    +        return this;
    +    }
    +
    +    /**
    +     * Performs inner Join.
    +     *  SQL    :   from priorStream inner join newStream on newStream.key 
= priorStream.key1
    +     *  same as:   new WindowedQueryBolt(priorStream,key1). 
join(newStream, key, priorStream);
    +     *
    +     *  Note: priorStream must be previously joined.
    +     *    Valid ex:    new WindowedQueryBolt(s1,k1). join(s2,k2, s1). 
join(s3,k3, s2);
    --- End diff --
    
    It is necessary to specify which stream s3 should be joined with (s2 or 
s1?) .... as the results will differ accordingly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to