Beispiel #1
0
 /// <summary>Ctor. </summary>
 /// <param name="tableLookupPlan">plan for performing lookup</param>
 public TableOuterLookupNode(TableLookupPlan tableLookupPlan)
 {
     _tableLookupPlan = tableLookupPlan;
 }
        private static IList <LookupInstructionPlan> BuildLookupInstructions(
            int rootStreamNum,
            LinkedHashMap <int, int[]> substreamsPerStream,
            bool[] requiredPerStream,
            string[] streamNames,
            QueryGraph queryGraph,
            QueryPlanIndex[] indexSpecs,
            EventType[] typesPerStream,
            OuterJoinDesc[] outerJoinDescList,
            bool[] isHistorical,
            HistoricalStreamIndexList[] historicalStreamIndexLists,
            ExprEvaluatorContext exprEvaluatorContext,
            TableMetadata[] tablesPerStream)
        {
            IList <LookupInstructionPlan> result = new List <LookupInstructionPlan>();

            foreach (int fromStream in substreamsPerStream.Keys)
            {
                var substreams = substreamsPerStream.Get(fromStream);

                // for streams with no substreams we don't need to look up
                if (substreams.Length == 0)
                {
                    continue;
                }

                var plans           = new TableLookupPlan[substreams.Length];
                var historicalPlans = new HistoricalDataPlanNode[substreams.Length];

                for (var i = 0; i < substreams.Length; i++)
                {
                    var toStream = substreams[i];

                    if (isHistorical[toStream])
                    {
                        // There may not be an outer-join descriptor, use if provided to build the associated expression
                        ExprNode outerJoinExpr = null;
                        if (outerJoinDescList.Length > 0)
                        {
                            OuterJoinDesc outerJoinDesc;
                            if (toStream == 0)
                            {
                                outerJoinDesc = outerJoinDescList[0];
                            }
                            else
                            {
                                outerJoinDesc = outerJoinDescList[toStream - 1];
                            }
                            outerJoinExpr = outerJoinDesc.MakeExprNode(exprEvaluatorContext);
                        }

                        if (historicalStreamIndexLists[toStream] == null)
                        {
                            historicalStreamIndexLists[toStream] = new HistoricalStreamIndexList(toStream, typesPerStream, queryGraph);
                        }
                        historicalStreamIndexLists[toStream].AddIndex(fromStream);
                        historicalPlans[i] = new HistoricalDataPlanNode(toStream, rootStreamNum, fromStream, typesPerStream.Length, outerJoinExpr);
                    }
                    else
                    {
                        plans[i] = NStreamQueryPlanBuilder.CreateLookupPlan(queryGraph, fromStream, toStream, indexSpecs[toStream], typesPerStream, tablesPerStream[toStream]);
                    }
                }

                var fromStreamName = streamNames[fromStream];
                var instruction    = new LookupInstructionPlan(fromStream, fromStreamName, substreams, plans, historicalPlans, requiredPerStream);
                result.Add(instruction);
            }

            return(result);
        }