Beispiel #1
0
        /// <summary> Builds a tree of <see cref="BaseAssemblyNode" /> from join strategy information.</summary>
        /// <param name="rootStream">the root stream supplying the event to evaluate
        /// </param>
        /// <param name="streamsJoinedPerStream">a map in which the key is the stream number to supply an event,
        /// and the value is an array of streams to find events in for the given event
        /// </param>
        /// <param name="isRequiredPerStream">indicates which streams are required join streams versus optional streams
        /// </param>
        /// <returns> root assembly node
        /// </returns>

        public static BaseAssemblyNodeFactory Build(int rootStream, IDictionary <Int32, int[]> streamsJoinedPerStream, bool[] isRequiredPerStream)
        {
            if (streamsJoinedPerStream.Count < 3)
            {
                throw new ArgumentException("Not a 3-way join");
            }
            if ((rootStream < 0) || (rootStream >= streamsJoinedPerStream.Count))
            {
                throw new ArgumentException("Invalid root stream");
            }
            if (isRequiredPerStream.Length != streamsJoinedPerStream.Count)
            {
                throw new ArgumentException("Arrays not matching up");
            }

            NStreamOuterQueryPlanBuilder.VerifyJoinedPerStream(rootStream, streamsJoinedPerStream);

            if (Log.IsDebugEnabled)
            {
                Log.Debug(
                    ".build Building node for root stream " + rootStream +
                    " streamsJoinedPerStream=" + NStreamOuterQueryPlanBuilder.Print(streamsJoinedPerStream) +
                    " isRequiredPerStream=" + isRequiredPerStream.Render());
            }

            BaseAssemblyNodeFactory topNode = CreateNode(
                true,
                rootStream,
                streamsJoinedPerStream.Count,
                streamsJoinedPerStream[rootStream],
                isRequiredPerStream);

            RecursiveBuild(rootStream, topNode, streamsJoinedPerStream, isRequiredPerStream);

            if (Log.IsDebugEnabled)
            {
                StringWriter buf          = new StringWriter();
                IndentWriter indentWriter = new IndentWriter(buf, 0, 2);
                topNode.PrintDescendends(indentWriter);

                Log.Debug(".build Dumping root node for stream " + rootStream + ": \n" + buf.ToString());
            }

            return(topNode);
        }